@Override public void onLoadFinished(Loader<LoaderResult<String>> loader, final LoaderResult<String> data) { mJokeButton.setEnabled(true); toggleProgressIndicator(false); if (data.isLoadSuccessful()) { final String text = data.getData(); openJokeActivity(text); } else { showErrorMessage( R.string.message_load_failed, R.string.retry, new View.OnClickListener() { @Override public void onClick(View v) { requestJoke(); } }); } }
private void requestJoke() { mJokeButton.setEnabled(false); toggleProgressIndicator(true); getLoaderManager().restartLoader(LOADER_ID, null, this).forceLoad(); }