コード例 #1
0
 @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();
           }
         });
   }
 }
コード例 #2
0
 private void requestJoke() {
   mJokeButton.setEnabled(false);
   toggleProgressIndicator(true);
   getLoaderManager().restartLoader(LOADER_ID, null, this).forceLoad();
 }