Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top