Android Universal image loader, stop retry

你说的曾经没有我的故事 提交于 2019-12-04 06:16:16

问题


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);


}

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.


回答1:


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.

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.



来源:https://stackoverflow.com/questions/21110153/android-universal-image-loader-stop-retry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!