예제 #1
0
  @Override
  public void onLoadImageResponse(BitmapDrawable drawable, Response response) {
    pageLoadTask = null;
    if (mQuranPageLayout == null || !isAdded()) {
      return;
    }

    if (drawable != null) {
      mImageView.setImageDrawable(drawable);
      // TODO we should toast a warning if we couldn't save the image
      // (which would likely happen if we can't write to the sdcard,
      // but just got the page from the web).
    } else if (response != null) {
      // failed to get the image... let's notify the user
      final int errorCode = response.getErrorCode();
      final int errorRes;
      switch (errorCode) {
        case Response.ERROR_SD_CARD_NOT_FOUND:
          errorRes = R.string.sdcard_error;
          break;
        case Response.ERROR_DOWNLOADING_ERROR:
          errorRes = R.string.download_error_network;
          break;
        default:
          errorRes = R.string.download_error_general;
      }
      mQuranPageLayout.showError(errorRes);
      mQuranPageLayout.setOnClickListener(
          v -> {
            if (ayahSelectedListener != null) {
              ayahSelectedListener.onClick(EventType.SINGLE_TAP);
            }
          });
    }
  }
예제 #2
0
 public void cleanup() {
   android.util.Log.d(TAG, "cleaning up page " + mPageNumber);
   mImageView.setImageDrawable(null);
   mImageView = null;
   if (mTranslationDialog != null) {
     mTranslationDialog.dismiss();
     mTranslationDialog = null;
   }
 }
예제 #3
0
  public void cleanup() {
    Timber.d("cleaning up page %d", pageNumber);
    handler.removeCallbacksAndMessages(null);
    if (pageLoadTask != null) {
      pageLoadTask.cancel(false);
    }

    if (mQuranPageLayout != null) {
      mImageView.setImageDrawable(null);
      mQuranPageLayout = null;
    }
  }