【发布时间】:2017-04-05 13:24:32
【问题描述】:
我正在使用通用图像加载器版本 1.5.9,这是我的代码,我想缓存图像以在每次重新加载活动时不下载,我不关闭应用程序但每次都会下载图像:
ImageLoader imageLoader = ImageLoader.getInstance();
File cacheDir = StorageUtils.getCacheDirectory(context);
config= new ImageLoaderConfiguration.Builder(context)
.memoryCacheExtraOptions(480, 800) // default = device screen dimensions
.diskCacheExtraOptions(480, 800, null)
.threadPriority(Thread.NORM_PRIORITY - 2) // default
.tasksProcessingOrder(QueueProcessingType.FIFO) // default
.diskCache(new UnlimitedDiskCache(cacheDir)) // default
.diskCacheSize(50 * 1024 * 1024)
.diskCacheFileCount(100)
.diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
.imageDownloader(new BaseImageDownloader(context)) // default
.build();
imageLoader.init(config);
imageLoader.displayImage(img, viewHolder.img);
有什么问题?为什么每次都下载图片?
【问题讨论】:
-
你是从 url 加载图片吗?
-
为什么不用glide在通用图片加载器的地方,看这个链接:github.com/bumptech/glide
-
@AishwaryaTiwari 是的,我正在从 url 加载它
-
然后使用Picasso。它可以有效地进行图像缓存。
标签: android universal-image-loader