1

我在Android 4.2.2上遇到Universal Image Loader 1.9.1的問題。 這裏描述的相同:Android Universal image loader, stop retry。我多次閱讀NOSTRA的答案,但我無法弄清楚如何實現這一點。我應該擴展BaseImageDownloader並重寫getStream方法嗎?我想使用答案的最後部分:通用圖像加載程序停止重試

UIL不會重新嘗試加載圖像。如果你返回null,那麼你會得到onLoadingFailed(...)回調。如果再次爲同一個URL調用displayImage(...),則UIL將嘗試再次加載圖像。 如果您想阻止它,那麼您應該在某處保留「壞」URL,並且不要將這些URL調用ImageLoader,,或者在ImageDownloader中返回null,以返回這些URL

基本上,避免UIL嘗試聯繫有效URL指向無效圖像文件的最簡單方法是什麼?我不知道它是否有用,在這裏我的配置:

DisplayImageOptions options = new DisplayImageOptions.Builder() 
     .resetViewBeforeLoading(true).cacheInMemory(true) 
     .cacheOnDisc(true) 
     .imageScaleType(ImageScaleType.EXACTLY_STRETCHED) 
     .showImageForEmptyUri(R.drawable.photo_placeholder) 
     .showImageOnFail(R.drawable.photo_placeholder).build(); 

ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
     context).memoryCacheExtraOptions(200, 200) 
     .discCacheExtraOptions(200, 200, CompressFormat.JPEG, 75, null) 
     .threadPoolSize(5).denyCacheImageMultipleSizesInMemory() 
     .memoryCache(new LruMemoryCache(2 * 1024 * 1024)) 
     .imageDownloader(new BaseImageDownloader(context) { 

     }) 
     .defaultDisplayImageOptions(options).build(); 

我真的需要一些幫助,我的應用大量使用UIL。

回答

0

正如UIL的作者所言,UIL不會重新嘗試加載圖片。沒有必要擔心這個