@Override
 protected void onPostExecute(Void result) {
   // If after terminating there are still requests in the load queue, the task needs
   //  to be restarted to serve them. This will barely happen, but it is plausible.
   if (isReopenNeeded()) {
     Log.d("CacheWorker", "Reopening");
     File dir = new File(mContext.getCacheDir().getPath() + File.separator + DISK_CACHE_SUB_DIR);
     workerTask = new CacheWorkerTask();
     workerTask.execute(dir);
   } else {
     workerTask = null;
   }
 }
  /**
   * Loads the bitmap at the provided url, but checks the cache first.
   *
   * @param view the view to where the bitmap shall be set.
   * @param url the urk of the bitmap. This acts as a key for the cache.
   * @param flinging avoid downloading on cache miss.
   * @param usePlaceholder use a placeholder while the bitmap loads.
   */
  public static void loadBitmap(
      ImageView view, String url, boolean flinging, boolean usePlaceholder) {
    // 1.- Check memory cache
    Bitmap bitmap = MemoryCache.instance().getBitmapFromMemCache(url);
    // 2.- On hit, load, on miss, check disk cache
    if (bitmap != null) {
      Log.d("MemoryCache", "Hit: " + url);
      view.setImageBitmap(bitmap);
    } else {
      Log.d("MemoryCache", "Miss: " + url);

      // Add to queue and start the task if necessary
      queueLoadRequest(new LoadRequest(view, url, flinging, usePlaceholder));
      if (workerTask == null) {
        File dir = new File(mContext.getCacheDir().getPath() + File.separator + DISK_CACHE_SUB_DIR);
        workerTask = new CacheWorkerTask();
        workerTask.execute(dir);
      }
    }
  }