Android的通用映像加载器,停止重试 [英] Android Universal image loader, stop retry

查看:121
本文介绍了Android的通用映像加载器,停止重试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的是UIL的lib我的应用程序,我从亚马逊S3服务器上获取的图像。
我已经覆盖了 BaseImageDownloader 类:

I use the UIL lib in my app, I get the images from my Amazon S3 server.
I've overridden the BaseImageDownloader class :

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,我返回的UIL不断重新尝试一遍又一遍加载图像。如果没有这样的形象,我想它不会再次尝试。

but when I have a 404 error at the server (no such image) the UIL, and I return null the UIL keeps retrying to load the image over and over. If there is no such image I'd like it not to try again.

推荐答案

UIL不重试图像加载自身。如果返回,然后你会得到 onLoadingFailed(...)回调。如果你调用 displayImage(...)为相同的URL,然后再次将UIL尝试再次加载图像。

UIL doesn't retry image loading itself. If you return null then you'll got onLoadingFailed(...) callback. If you call displayImage(...) for the same URL again then UIL will try to load image again.

如果你想prevent它,那么你应该保持坏的网址的地方,并没有叫ImageLoader的这些网址,或在ImageDownloader返回空来回这些URL。

If you want to prevent it then you should keep "bad" URLs somewhere and not call ImageLoader for these URLs, or return null in ImageDownloader fro these URLs.

这篇关于Android的通用映像加载器,停止重试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆