コード例 #1
0
 @Override
 @NonNull
 public Dialog onCreateDialog(final Bundle savedInstanceState) {
   final LayoutInflater inflater = getActivity().getLayoutInflater();
   final View layout = inflater.inflate(R.layout.dialog_reset, null);
   final Context context = getActivity();
   final AsyncQueryHandler asyncQueryHandler =
       new AsyncQueryHandler(context.getContentResolver()) {
         @Override
         protected void onDeleteComplete(final int token, final Object cookie, final int result) {
           AppWidgetUpdateHandler.createInstance().updateAllWidgets(context);
           NotificationUpdateService.updateNotification(context);
         }
       };
   final GtmManager gtmManager = GtmManager.getInstance(this);
   gtmManager.push("type", DataLayer.OBJECT_NOT_PRESENT);
   return new AlertDialog.Builder(getActivity())
       .setIcon(R.drawable.ic_dialog_alert)
       .setTitle(R.string.reset_dialog_title)
       .setView(layout)
       .setInverseBackgroundForced(true)
       .setPositiveButton(
           R.string.reset_dialog_confirm,
           new OnClickListener() {
             @Override
             public void onClick(final DialogInterface dialog, final int which) {
               if (BuildConfig.DEBUG) Log.d(TAG, "Received positive event");
               gtmManager.pushEvent("Positive");
               asyncQueryHandler.startDelete(
                   0, 0, ContractionContract.Contractions.CONTENT_URI, null, null);
             }
           })
       .setNegativeButton(
           R.string.reset_dialog_cancel,
           new OnClickListener() {
             @Override
             public void onClick(final DialogInterface dialog, final int which) {
               if (BuildConfig.DEBUG) Log.d(TAG, "Received negative event");
               gtmManager.pushEvent("Negative");
             }
           })
       .create();
 }
コード例 #2
0
 @Override
 public void onCancel(final DialogInterface dialog) {
   if (BuildConfig.DEBUG) Log.d(TAG, "Received cancelation event");
   GtmManager.getInstance(this).pushEvent("Cancel");
   super.onCancel(dialog);
 }