コード例 #1
0
 /**
  * Global method to show a dialog fragment including adding it to back stack and handling the case
  * where the dialog is shown from an async task, by showing the message in the notification bar if
  * the activity was stopped before the AsyncTask completed
  *
  * @param newFragment the AsyncDialogFragment you want to show
  */
 public void showAsyncDialogFragment(AsyncDialogFragment newFragment) {
   try {
     showDialogFragment(newFragment);
   } catch (IllegalStateException e) {
     String title = newFragment.getNotificationTitle();
     String message = newFragment.getNotificationMessage();
     AnkiDroidApp.setStoredDialogHandlerMessage(newFragment.getDialogHandlerMessage());
     showSimpleNotification(title, message);
   }
 }
コード例 #2
0
 @Override
 protected void onResume() {
   super.onResume();
   ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE))
       .cancel(SIMPLE_NOTIFICATION_ID);
   // Show any pending dialogs
   Message handlerMsg = AnkiDroidApp.getStoredDialogHandlerMessage();
   if (handlerMsg != null) {
     // TODO: Confirm whether or not it's ok to send the message without checking if the collection
     // is open.
     mHandler.sendMessage(handlerMsg);
     AnkiDroidApp.setStoredDialogHandlerMessage(null);
   }
 }