2014-01-14 15 views
0

我在我的应用程序中使用UIL lib,我从我的Amazon S3服务器获取图像。
我已经覆盖了BaseImageDownloader类:Android通用图像加载器,停止重试

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不断重试一遍又一遍地加载图像。如果没有这样的图像,我希望不要再试一次。

回答

2

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

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

相关问题