@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); } }); } }
@Override public void handleRetryClicked() { mQuranPageLayout.setOnClickListener(null); mQuranPageLayout.setClickable(false); downloadImage(); }