80,351
社区成员
发帖
与我相关
我的任务
分享
ImageLoaderConfiguration config = ImageLoaderConfigurationUtil.getCustomImageLoaderConfiguration(getApplicationContext());
ImageLoader.getInstance().init(config);
public class ImageLoaderConfigurationUtil {
public static ImageLoaderConfiguration getCustomImageLoaderConfiguration(Context context) {
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).memoryCacheExtraOptions(640, 640)
// default = device screen dimensions
.threadPoolSize(5)
// default
.threadPriority(Thread.MAX_PRIORITY - 1)
// default
.tasksProcessingOrder(QueueProcessingType.FIFO)
// default
// memoryCache
.memoryCache(new UsingFreqLimitedMemoryCache(16 * 1024 * 1024))
// memoryCacheSizePercentage
.memoryCacheSizePercentage(12)
// default
.diskCacheSize(50 * 1024 * 1024)
// diskCacheFileCount
.diskCacheFileCount(100)
// cacheFileNameGenerator
.diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
.imageDownloader(new BaseImageDownloader(context)) // default
.imageDecoder(new BaseImageDecoder(true)) // default
// logs,delete it when release
.writeDebugLogs()
// build
.build();
return config;
}
}
public static DisplayImageOptions getDefaultOptions() {
DisplayImageOptions options = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.default_img).showImageForEmptyUri(R.drawable.default_img)
.showImageOnFail(R.drawable.default_img).resetViewBeforeLoading(false).cacheOnDisk(true).imageScaleType(ImageScaleType.IN_SAMPLE_INT)
.bitmapConfig(Bitmap.Config.RGB_565).displayer(new FadeInBitmapDisplayer(0)).build();
return options;
}