Image工具类

来源:互联网 发布:js 重置按钮 编辑:程序博客网 时间:2024/05/20 11:21
public class ImageLoaderUtils {
/**
*
* @param context
*/
public static void initConfiguration(Context context) {
Builder configuration = new ImageLoaderConfiguration.Builder(context);


// --------------------------------------------------------------------
configuration
.threadPoolSize(3)
.threadPriority(Thread.NORM_PRIORITY - 2)
.tasksProcessingOrder(QueueProcessingType.FIFO)
.denyCacheImageMultipleSizesInMemory()
.memoryCache(new LruMemoryCache(6 * 1024 * 1024))
.memoryCacheSize(2 * 1024 * 1024)
.memoryCacheSizePercentage(13)
.diskCacheSize(50 * 1024 * 1024)
.diskCacheFileCount(100)
.diskCacheFileNameGenerator(new HashCodeFileNameGenerator())
.imageDecoder(new BaseImageDecoder(true))
.defaultDisplayImageOptions(DisplayImageOptions.createSimple())
.writeDebugLogs();


// ---------------------------------------------------------------------
ImageLoader.getInstance().init(configuration.build());
}


/**
*
* @return
*/
public static DisplayImageOptions initOptions() {
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.iv_user)
.showImageOnFail(R.drawable.iv_user)
.showImageForEmptyUri(R.drawable.iv_user)
.cacheInMemory(true)
.cacheOnDisc(true)


.considerExifParams(true)
.imageScaleType(ImageScaleType.EXACTLY_STRETCHED)
.bitmapConfig(Bitmap.Config.RGB_565)
.resetViewBeforeLoading(true)
.displayer(new RoundedBitmapDisplayer(20))
.displayer(new CircleBitmapDisplayer())
// -------------------------------------------------------------------
.build();
return options;

}



}
原创粉丝点击