ImageLoader配置

 // 初始化ImageLoader
  File cacheDir  = new File(SystemUtil.getDiskCacheDir(getApplicationContext(), "bitmap"));
  int cacheSize = SystemUtil.getAppMaxRunningMemory() / 5; // 图片缓存池大小为程序最大可用内存的1/5
  ImageLoaderConfiguration configuration = 
   new ImageLoaderConfiguration.Builder(getApplicationContext())
  .memoryCacheExtraOptions(480, 800) // default = device screen dimensions 
  .diskCacheExtraOptions(480, 800, null)
  .taskExecutor(null)
  .taskExecutorForCachedImages(null)
  // 配置线程池数量
  .threadPoolSize(8)
  // 线程优先级
  .threadPriority(Thread.NORM_PRIORITY -1)
  .tasksProcessingOrder(QueueProcessingType.FIFO)
  .denyCacheImageMultipleSizesInMemory()
   // 配置内存缓存策略 ,也可以不使用图片缓存池,以WeakMemoryCache()替代
  .memoryCache(new LruMemoryCache(cacheSize)) //
  .memoryCacheSize(cacheSize)
  .memoryCacheSizePercentage(13)
  // 配置磁盘缓存策略
  .diskCache(new UnlimitedDiscCache(cacheDir))
  .diskCacheSize(50*1024*1024)
  .diskCacheFileCount(100)
  .diskCacheFileNameGenerator(new HashCodeFileNameGenerator())
  .imageDownloader(new BaseImageDownloader(getApplicationContext()))
  .imageDecoder(new BaseImageDecoder(true))
  .defaultDisplayImageOptions(DisplayImageOptions.createSimple())
  // .writeDebugLogs() // 打印调试信息 仅用于调试 发布后关闭
  .build();
  
  ImageLoader.getInstance().init(configuration);



ImageLoaderConfiguration configuration = ImageLoaderConfiguration
        .createDefault(getApplicationContext());
ImageLoader.getInstance().init(configuration);

options = new DisplayImageOptions.Builder()
        .showImageOnLoading(R.drawable.image_default)
        .showImageForEmptyUri(R.drawable.image_default)
        .showImageOnFail(R.drawable.image_default)
        .cacheInMemory(false).cacheOnDisk(true)
        .considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565)
        .displayer(new RoundedBitmapDisplayer(2)).build();
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值