public ImageCache(Context context) {
    try {
      _memoryCache =
          new LruCache<String, Bitmap>(MEMORY_CACHE_SIZE) {
            protected int sizeOf(String key, Bitmap value) {
              return value.getRowBytes() * value.getHeight();
            }
          };

      final File diskCacheDir = getDiskCacheDir(context, DISK_CACHE_SUBDIR);
      _diskCache = DiskLruCache.open(diskCacheDir, APP_VERSION, VALUE_COUNT, DISK_CACHE_SIZE);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  public FavurlShowDiskCache(Context context) {

    File cacheDir = CommonUtils.getDiskCacheDir(context, Constants.FAVURL_CACHE_DIR);
    if (!cacheDir.exists()) {
      cacheDir.mkdirs();
    }

    try {
      diskCache =
          DiskLruCache.open(
              cacheDir, CommonUtils.getAppVersion(context), 1, Constants.BITMAP_CACHE_MAX_SIZE);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
 public CustomImageCache() {
   int maxSize = (int) Runtime.getRuntime().maxMemory() / 8;
   mMemoryCache =
       new LruCache<String, Bitmap>(maxSize) {
         @Override
         protected int sizeOf(String key, Bitmap value) {
           // 这个方法一定要重写,不然缓存没有效果
           return value.getHeight() * value.getRowBytes();
         }
       };
   try {
     // 获取图片缓存路径
     File cacheDir = FileUtils.getDiskCacheDir("thumb");
     if (!cacheDir.exists()) {
       cacheDir.mkdirs();
     }
     // 创建DiskLruCache实例,初始化缓存数据
     mDiskLruCache =
         DiskLruCache.open(cacheDir, CommonUtils.getAppVersion(), 1, DISK_CACHE_MAX_SIZE);
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
  private void initDiskCache(String path, boolean autoCreate, long maxSize) {
    if (mDiskLruCache == null && !TextUtils.isEmpty(path)) {
      File f = new File(path);
      if (!f.exists() || !f.isDirectory()) {
        boolean b = false;
        if (autoCreate && f.mkdirs()) {
          b = true;
        }
        if (!b) {
          return;
        }
      }

      if (maxSize <= 0) {
        return;
      }
      try {
        mDiskLruCache = DiskLruCache.open(f, 1, 1, maxSize);
      } catch (IOException e) {
        e.printStackTrace();
        return;
      }
    }
  }