use of androidx.appcompat.app.AlertDialog in project easypermissions by googlesamples.
the class AppSettingsDialogTest method shouldPositiveListener_whenClickingPositiveButtonFromSupportFragment.
@Test
public void shouldPositiveListener_whenClickingPositiveButtonFromSupportFragment() {
AlertDialog alertDialog = new AppSettingsDialog.Builder(spyFragment).setTitle(TITLE).setRationale(RATIONALE).setPositiveButton(POSITIVE).setNegativeButton(NEGATIVE).setThemeResId(R.style.Theme_AppCompat).build().showDialog(positiveListener, negativeListener);
Button positive = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
positive.performClick();
verify(positiveListener, times(1)).onClick(any(DialogInterface.class), anyInt());
}
use of androidx.appcompat.app.AlertDialog in project easypermissions by googlesamples.
the class AppSettingsDialogTest method shouldNegativeListener_whenClickingPositiveButtonFromSupportFragment.
@Test
public void shouldNegativeListener_whenClickingPositiveButtonFromSupportFragment() {
AlertDialog alertDialog = new AppSettingsDialog.Builder(spyFragment).setTitle(TITLE).setRationale(RATIONALE).setPositiveButton(POSITIVE).setNegativeButton(NEGATIVE).setThemeResId(R.style.Theme_AppCompat).build().showDialog(positiveListener, negativeListener);
Button positive = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
positive.performClick();
verify(negativeListener, times(1)).onClick(any(DialogInterface.class), anyInt());
}
use of androidx.appcompat.app.AlertDialog in project K6nele by Kaljurand.
the class Utils method getTextEntryDialog.
public static AlertDialog getTextEntryDialog(Context context, String title, String initialText, final ExecutableString ex) {
final View textEntryView = LayoutInflater.from(context).inflate(R.layout.alert_dialog_url_entry, null);
final EditText et = textEntryView.findViewById(R.id.url_edit);
if (initialText != null) {
et.setText(initialText);
et.setHint(initialText);
et.setSelection(initialText.length());
}
final AlertDialog ad = new AlertDialog.Builder(context).setTitle(title).setView(textEntryView).setPositiveButton(R.string.buttonOk, (dialog, whichButton) -> ex.execute(et.getText().toString())).setNegativeButton(R.string.buttonCancel, (dialog, whichButton) -> dialog.cancel()).create();
et.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_DONE) {
ex.execute(et.getText().toString());
ad.cancel();
return true;
}
return false;
});
return ad;
}
use of androidx.appcompat.app.AlertDialog in project J2ME-Loader by nikita36078.
the class Display method showAlert.
private void showAlert(Alert alert) {
ViewHandler.postEvent(() -> {
AlertDialog alertDialog = alert.prepareDialog();
alertDialog.show();
if (alert.finiteTimeout()) {
ViewHandler.postDelayed(alertDialog::dismiss, alert.getTimeout());
}
});
}
use of androidx.appcompat.app.AlertDialog in project J2ME-Loader by nikita36078.
the class EditNameAlert method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
LayoutInflater inflater = LayoutInflater.from(getActivity());
@SuppressLint("InflateParams") View v = inflater.inflate(R.layout.dialog_change_name, null);
EditText editText = v.findViewById(R.id.editText);
Button btNegative = v.findViewById(R.id.btNegative);
Button btPositive = v.findViewById(R.id.btPositive);
AlertDialog dialog = new AlertDialog.Builder(requireActivity()).setTitle(mTitle).setView(v).create();
btNegative.setOnClickListener(v1 -> dismiss());
btPositive.setOnClickListener(v1 -> onClickOk(editText));
return dialog;
}
Aggregations