private Bitmap tryLoadBitmap() {
    DiscCacheAware discCache = configuration.discCache;
    File imageFile = discCache.get(uri);

    Bitmap bitmap = null;
    try {
      // Try to load image from disc cache
      if (imageFile.exists()) {
        log(LOG_LOAD_IMAGE_FROM_DISC_CACHE, memoryCacheKey);

        Bitmap b = decodeImage(imageFile.toURI());
        if (b != null) {
          return b;
        }
      }

      // Load image from Web
      log(LOG_LOAD_IMAGE_FROM_INTERNET, memoryCacheKey);

      URI imageUriForDecoding;
      if (options.isCacheOnDisc()) {
        log(LOG_CACHE_IMAGE_ON_DISC, memoryCacheKey);

        saveImageOnDisc(imageFile);
        discCache.put(uri, imageFile);
        imageUriForDecoding = imageFile.toURI();
      } else {
        imageUriForDecoding = new URI(uri);
      }

      bitmap = decodeImage(imageUriForDecoding);
      if (bitmap == null) {
        fireImageLoadingFailedEvent(FailReason.IO_ERROR);
      }
    } catch (IOException e) {
      L.e(e);
      fireImageLoadingFailedEvent(FailReason.IO_ERROR);
      if (imageFile.exists()) {
        imageFile.delete();
      }
    } catch (OutOfMemoryError e) {
      L.e(e);
      fireImageLoadingFailedEvent(FailReason.OUT_OF_MEMORY);
    } catch (Throwable e) {
      L.e(e);
      fireImageLoadingFailedEvent(FailReason.UNKNOWN);
    }
    return bitmap;
  }
  private Bitmap tryLoadBitmap() throws TaskCancelledException {
    File imageFile = getImageFileInDiscCache();

    Bitmap bitmap = null;
    try {
      String cacheFileUri = Scheme.FILE.wrap(imageFile.getAbsolutePath());
      if (imageFile.exists()) {
        log(LOG_LOAD_IMAGE_FROM_DISC_CACHE);
        loadedFrom = LoadedFrom.DISC_CACHE;

        checkTaskNotActual();
        bitmap = decodeImage(cacheFileUri);
      }
      if (bitmap == null || bitmap.getWidth() <= 0 || bitmap.getHeight() <= 0) {
        log(LOG_LOAD_IMAGE_FROM_NETWORK);
        loadedFrom = LoadedFrom.NETWORK;

        String imageUriForDecoding =
            options.isCacheOnDisc() && tryCacheImageOnDisc(imageFile) ? cacheFileUri : uri;

        checkTaskNotActual();
        bitmap = decodeImage(imageUriForDecoding);

        if (bitmap == null || bitmap.getWidth() <= 0 || bitmap.getHeight() <= 0) {
          fireFailEvent(FailType.DECODING_ERROR, null);
        }
      }
    } catch (IllegalStateException e) {
      fireFailEvent(FailType.NETWORK_DENIED, null);
    } catch (TaskCancelledException e) {
      throw e;
    } catch (IOException e) {
      L.e(e);
      fireFailEvent(FailType.IO_ERROR, e);
      if (imageFile.exists()) {
        imageFile.delete();
      }
    } catch (OutOfMemoryError e) {
      L.e(e);
      fireFailEvent(FailType.OUT_OF_MEMORY, e);
    } catch (Throwable e) {
      L.e(e);
      fireFailEvent(FailType.UNKNOWN, e);
    }
    return bitmap;
  }