use of android.content.DialogInterface.BUTTON_NEGATIVE in project collect by opendatakit.
the class DeleteRepeatDialogFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
super.onCreateDialog(savedInstanceState);
String name = formController.getLastRepeatedGroupName();
int repeatCount = formController.getLastRepeatedGroupRepeatCount();
if (repeatCount != -1) {
name += " (" + (repeatCount + 1) + ")";
}
AlertDialog alertDialog = new MaterialAlertDialogBuilder(getActivity()).create();
alertDialog.setTitle(getActivity().getString(R.string.delete_repeat_ask));
alertDialog.setMessage(getActivity().getString(R.string.delete_repeat_confirm, name));
DialogInterface.OnClickListener quitListener = (dialog, i) -> {
if (i == BUTTON_POSITIVE) {
// yes
formController.getAuditEventLogger().logEvent(AuditEvent.AuditEventType.DELETE_REPEAT, true, System.currentTimeMillis());
formController.deleteRepeat();
callback.deleteGroup();
}
alertDialog.cancel();
dismiss();
};
setCancelable(false);
alertDialog.setCancelable(false);
alertDialog.setButton(BUTTON_POSITIVE, getActivity().getString(R.string.discard_group), quitListener);
alertDialog.setButton(BUTTON_NEGATIVE, getActivity().getString(R.string.delete_repeat_no), quitListener);
return alertDialog;
}
use of android.content.DialogInterface.BUTTON_NEGATIVE in project collect by opendatakit.
the class AddRepeatDialog method show.
public static void show(Context context, String groupLabel, Listener listener) {
AlertDialog alertDialog = new MaterialAlertDialogBuilder(context).create();
DialogInterface.OnClickListener repeatListener = (dialog, i) -> {
switch(i) {
case BUTTON_POSITIVE:
listener.onAddRepeatClicked();
break;
case BUTTON_NEGATIVE:
listener.onCancelClicked();
break;
}
};
alertDialog.setMessage(context.getString(R.string.add_repeat_question, groupLabel));
alertDialog.setButton(BUTTON_POSITIVE, context.getString(R.string.add_repeat), repeatListener);
alertDialog.setButton(BUTTON_NEGATIVE, context.getString(R.string.dont_add_repeat), repeatListener);
alertDialog.setCancelable(false);
alertDialog.show();
}
Aggregations