public void put(String key, Bitmap image) {
    if (key == null || image == null) {
      return;
    }

    addBitmapToMemoryCache(key, image);

    DiskLruCache.Editor editor = null;
    try {
      editor = _diskCache.edit(key);
      if (editor == null || image == null) {
        return;
      }

      if (writeBitmapToFile(image, editor)) {
        _diskCache.flush();
        editor.commit();
      } else {
        editor.abort();
      }
    } catch (IOException e) {
      try {
        if (editor != null) {
          editor.abort();
        }
      } catch (IOException ignored) {
      }
    }
  }
Esempio n. 2
0
    public void run() {
      // Make sure we're running with a background priority
      Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);

      try {
        mDiskCache.flush();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }