【问题标题】:Android Universal image loader, stop retryAndroid通用图片加载器,停止重试
【发布时间】:2014-02-02 07:29:48
【问题描述】:

我在我的应用程序中使用 UIL 库,我从我的 Amazon S3 服务器获取图像。
我已经覆盖了BaseImageDownloader 类:

protected InputStream getStreamFromOtherSource(String imageId, Object extra)
        throws IOException {

    TransferManager manager = AmazonParams.getTransferManager();


    File file = null; 
    GetObjectRequest req = new GetObjectRequest(AmazonParams.BUCKET, imageId);
    try{

        file = ImageLoader.getInstance().getDiscCache().get(imageId);

        Download d = manager.download(req, file);

        while (d.isDone() == false);

    }catch (Exception e){
        return null;
    }

    return new FileInputStream(file);


}

但是当我在服务器上遇到 404 错误(没有这样的图像)时,UIL,我返回 null,UIL 不断重试加载图像。如果没有这样的图像,我希望它不要再试了。

【问题讨论】:

    标签: android universal-image-loader


    【解决方案1】:

    UIL 不会自行重试图像加载。如果你返回 null 那么你会得到 onLoadingFailed(...) 回调。如果您再次为同一 URL 调用 displayImage(...),则 UIL 将再次尝试加载图像。

    如果你想阻止它,那么你应该将“坏”的 URL 保留在某个地方,而不是为这些 URL 调用 ImageLoader,或者在 ImageDownloader 中为这些 URL 返回 null。

    【讨论】:

      猜你喜欢
      • 2014-03-21
      • 2013-08-08
      • 1970-01-01
      • 1970-01-01
      • 2011-07-05
      • 2013-03-09
      • 1970-01-01
      • 1970-01-01
      • 2022-12-06
      相关资源
      最近更新 更多