I am using nostra's Universal Image Loader , I am using it to load images on the gridview, with size of 100*100, but exception is raised WHEN scrolling really fast through grid view(just for demo, i have 13000 images on grid adapter), although the library handle the exception and user is not notified about it, below is the exception
06-21 11:13:17.748: E/ImageLoader(2070): No such file or directory
06-21 11:13:17.748: E/ImageLoader(2070): java.io.FileNotFoundException: No such file or directory
06-21 11:13:17.748: E/ImageLoader(2070): at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:145)
06-21 11:13:17.748: E/ImageLoader(2070): at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:612)
06-21 11:13:17.748: E/ImageLoader(2070): at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:607)
06-21 11:13:17.748: E/ImageLoader(2070): at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:536)
06-21 11:13:17.748: E/ImageLoader(2070): at android.content.ContentResolver.openInputStream(ContentResolver.java:371)
06-21 11:13:17.748: E/ImageLoader(2070): at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStreamFromContent(BaseImageDownloader.java:177)
06-21 11:13:17.748: E/ImageLoader(2070): at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:88)
06-21 11:13:17.748: E/ImageLoader(2070): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.downloadImage(LoadAndDisplayImageTask.java:290)
06-21 11:13:17.748: E/ImageLoader(2070): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryCacheImageOnDisk(LoadAndDisplayImageTask.java:273)
06-21 11:13:17.748: E/ImageLoader(2070): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:229)
06-21 11:13:17.748: E/ImageLoader(2070): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:135)
06-21 11:13:17.748: E/ImageLoader(2070): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
06-21 11:13:17.748: E/ImageLoader(2070): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
06-21 11:13:17.748: E/ImageLoader(2070): at java.lang.Thread.run(Thread.java:856)
Code in place are:
WRITE_EXTERNAL_STORAGE is added
Both memory and disk cache
UnlimitedDiskCache for disk cache
Using latest library 1.9.2
That being said, the library crashes and no longer able to load the images and repeats all previous images, how to reset the library in such cases and start fresh, in-case of such crashes?
Below is the configuration of ImageLoader
String cacheDirectory=context.getCacheDir()+ImageLoaderConstants.IMAGE_CACHE_DIRECTOY_PATH;
File cacheDir=new File(cacheDirectory);
DisplayImageOptions options = new DisplayImageOptions.Builder()
.delayBeforeLoading(0)
.cacheInMemory(true)
.cacheOnDisk(true)
.imageScaleType(ImageScaleType.EXACTLY)
.bitmapConfig(Bitmap.Config.RGB_565)
.displayer(new SimpleBitmapDisplayer())
.build();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).threadPoolSize(5)
.threadPriority(Thread.NORM_PRIORITY)
.denyCacheImageMultipleSizesInMemory()
.memoryCacheExtraOptions(1280, 720)
.diskCacheExtraOptions(1280, 720,null)
.memoryCache(new LruMemoryCache(5*1024*1024))
.diskCache(new UnlimitedDiscCache(cacheDir))
.defaultDisplayImageOptions(options)
.build();
UPDATE:
Adapter Code has nothing much,
imageLoader.displayImage(uriPath, holder.imgThumbnail);
I have all the configurations as defined in Usage section at UIL GitHub
One of my favorite library,
first of all please add
DisplayImageOptions options = new DisplayImageOptions.Builder()
.delayBeforeLoading(0)
.cacheInMemory(true)
.cacheOnDisk(true)
.resetViewBeforeLoading(true) // add this line
.imageScaleType(ImageScaleType.EXACTLY)
.bitmapConfig(Bitmap.Config.RGB_565)
.displayer(new SimpleBitmapDisplayer())
.build();
by adding this line image will not reflact when you scroll.
and second thing is, Check below links
https://github.com/nostra13/Android-Universal-Image-Loader#useful-info
in that link read point no 8. stop loading when user scroll list/gridview.
boolean pauseOnScroll = false; // or true
boolean pauseOnFling = true; // or false
PauseOnScrollListener listener = new PauseOnScrollListener(imageLoader, pauseOnScroll, pauseOnFling);
listView.setOnScrollListener(listener);
Note: Above code is just suggestion, i don't know it will solve your problem or not.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.