use of com.nostra13.universalimageloader.cache.disc.impl.LimitedAgeDiskCache in project CustomViews by AndroidStudy233.
the class MyApplication method initImageLoader.
/**
* 初始化ImageLoader
*/
private void initImageLoader() {
File cacheDir = getCacheDir();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).memoryCacheExtraOptions(480, // max width, max height,即保存的每个缓存文件的最大长宽
800).threadPoolSize(// 线程池内加载的数量
3).threadPriority(// 线程优先级
Thread.NORM_PRIORITY - 1).denyCacheImageMultipleSizesInMemory().memoryCache(new WeakMemoryCache()).memoryCacheSize(// 内存缓存2MB
2 * 1024 * 1024).tasksProcessingOrder(QueueProcessingType.LIFO).diskCache(// 限制缓存时长
new LimitedAgeDiskCache(cacheDir, 7 * 24 * 60 * 60)).diskCacheSize(// 本地缓存50MB
50 * 1024 * 1024).diskCacheFileNameGenerator(// MD5加密名字
new Md5FileNameGenerator()).defaultDisplayImageOptions(// 设置默认选项
DisplayImageOptions.createSimple()).imageDownloader(// connectTimeout (5 s), readTimeout (30 s)超时时间
new BaseImageDownloader(getApplicationContext(), 5 * 1000, 20 * 1000)).build();
// 开始构建
ImageLoader.getInstance().init(config);
}
Aggregations