2016-02-26 37 views
2

无限磁盘缓存在通用图像加载器中不起作用:1.9.5 我想将图像存储在SD卡中。 请分享此代码的替代品。 这里是我的代码:无限磁盘缓存无法在图像加载器中工作1.9.5

public void initImageLoader() { 

    try { 
     File cacheDir = StorageUtils.getOwnCacheDirectory(getApplicationContext(), getString(R.string.app_name)); 
     DisplayImageOptions options = new DisplayImageOptions.Builder().showImageForEmptyUri(R.mipmap.ic_launcher) 
       .showImageOnLoading(R.mipmap.ic_launcher).showImageOnFail(R.mipmap.ic_launcher).cacheInMemory(true).cacheOnDisk(true) 
       .bitmapConfig(Bitmap.Config.RGB_565).considerExifParams(true).build(); 

     @SuppressWarnings("deprecation") 
     ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()) 
       .discCache(new UnlimitedDiscCache(cacheDir)).defaultDisplayImageOptions(options).build(); 
     ImageLoader.getInstance().init(config); 
     L.writeLogs(false); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 

} 

摇篮依赖关系:

compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' 

回答