@Override public void onClick(DialogInterface dialog, int which) { ConfirmationDialogBaseListener ctx = (ConfirmationDialogBaseListener) getActivity(); if (ctx == null) { return; } Bundle bundle = getArguments(); String prefKey = bundle.getString(KEY_PREFKEY); if (prefKey != null && checkBox.isChecked()) { SharedPreferencesCompat.apply( MyApplication.getInstance().getSettings().edit().putBoolean(prefKey, true)); } if (which == AlertDialog.BUTTON_POSITIVE) { if (bundle.getInt(KEY_CHECKBOX_LABEL, 0) == 0) { ((ConfirmationDialogListener) ctx).onPositive(bundle); } else { ((ConfirmationDialogCheckedListener) ctx).onPositive(bundle, checkBox.isChecked()); } } else { int negativeCommand = getArguments().getInt(KEY_COMMAND_NEGATIVE); if (negativeCommand != 0) { ctx.onNegative(bundle); } else { onCancel(dialog); } } }
@Override public void onCancel(DialogInterface dialog) { ConfirmationDialogBaseListener ctx = (ConfirmationDialogBaseListener) getActivity(); if (ctx != null) { ctx.onDismissOrCancel(getArguments()); } }