Java Code Examples for android.support.v7.app.AlertDialog#setOnDismissListener()
The following examples show how to use
android.support.v7.app.AlertDialog#setOnDismissListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemFragment.java From Companion-For-PUBG-Android with MIT License | 6 votes |
private void showDisclaimerForFirstTime() { final SharedPreferences preferences = getActivity().getSharedPreferences("temp", Context.MODE_PRIVATE); final String hasShown = "hasShown"; if (preferences.getBoolean(hasShown, false)) { return; } AlertDialog alertDialog = new AlertDialog.Builder(getActivity()) .setTitle("This is still in beta!") .setMessage("Data is not yet finished nor complete. Please help us via Github. Links available in the drawer.") .setPositiveButton("Ok no problem!", null) .show(); alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { preferences.edit().putBoolean(hasShown, true).apply(); } }); }
Example 2
Source File: DialogPreference.java From Nimingban with Apache License 2.0 | 6 votes |
/** * Shows the dialog associated with this Preference. This is normally initiated * automatically on clicking on the preference. Call this method if you need to * show the dialog on some other event. * * @param state Optional instance state to restore on the dialog */ protected void showDialog(Bundle state) { mWhichButtonClicked = DialogInterface.BUTTON_NEGATIVE; PreferenceUtils.registerOnActivityDestroyListener(this, this); // Create the dialog final AlertDialog dialog = mDialog = onCreateDialog(getContext()); if (state != null) { dialog.onRestoreInstanceState(state); } if (needInputMethod()) { requestInputMethod(dialog); } dialog.setOnDismissListener(this); dialog.show(); onDialogCreated(dialog); }
Example 3
Source File: NGActivity.java From android_maplibui with GNU Lesser General Public License v3.0 | 6 votes |
protected void requestPermissions(int title, int message, final int requestCode, final String... permissions) { boolean shouldShowDialog = false; for (String permission : permissions) { if (ActivityCompat.shouldShowRequestPermissionRationale(this, permission)) { shouldShowDialog = true; break; } } if (shouldShowDialog) { final Activity activity = this; AlertDialog builder = new AlertDialog.Builder(this).setTitle(title) .setMessage(message) .setPositiveButton(android.R.string.ok, null).create(); builder.setCanceledOnTouchOutside(false); builder.show(); builder.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { ActivityCompat.requestPermissions(activity, permissions, requestCode); } }); } else ActivityCompat.requestPermissions(this, permissions, requestCode); }
Example 4
Source File: CrashReportActivity.java From fdroidclient with GNU General Public License v3.0 | 6 votes |
@Override protected void init(Bundle savedInstanceState) { super.init(savedInstanceState); final AlertDialog dialog = new AlertDialog.Builder(this) .setTitle(R.string.crash_dialog_title) .setView(R.layout.crash_report_dialog) .setPositiveButton(R.string.ok, this) .setNegativeButton(R.string.cancel, this) .create(); dialog.setCanceledOnTouchOutside(false); dialog.setOnDismissListener(this); dialog.show(); comment = (EditText) dialog.findViewById(android.R.id.input); if (savedInstanceState != null) { comment.setText(savedInstanceState.getString(STATE_COMMENT)); } }
Example 5
Source File: PostFragment.java From Nimingban with Apache License 2.0 | 4 votes |
public void setPositiveButtonClickListener(AlertDialog dialog) { mDialog = dialog; dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(this); dialog.setOnDismissListener(this); }
Example 6
Source File: XmppActivity.java From Conversations with GNU General Public License v3.0 | 4 votes |
@SuppressLint("InflateParams") private void quickEdit(final String previousValue, final OnValueEdited callback, final @StringRes int hint, boolean password, boolean permitEmpty) { AlertDialog.Builder builder = new AlertDialog.Builder(this); DialogQuickeditBinding binding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.dialog_quickedit, null, false); if (password) { binding.inputEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } builder.setPositiveButton(R.string.accept, null); if (hint != 0) { binding.inputLayout.setHint(getString(hint)); } binding.inputEditText.requestFocus(); if (previousValue != null) { binding.inputEditText.getText().append(previousValue); } builder.setView(binding.getRoot()); builder.setNegativeButton(R.string.cancel, null); final AlertDialog dialog = builder.create(); dialog.setOnShowListener(d -> SoftKeyboardUtils.showKeyboard(binding.inputEditText)); dialog.show(); View.OnClickListener clickListener = v -> { String value = binding.inputEditText.getText().toString(); if (!value.equals(previousValue) && (!value.trim().isEmpty() || permitEmpty)) { String error = callback.onValueEdited(value); if (error != null) { binding.inputLayout.setError(error); return; } } SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText); dialog.dismiss(); }; dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(clickListener); dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setOnClickListener((v -> { SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText); dialog.dismiss(); })); dialog.setCanceledOnTouchOutside(false); dialog.setOnDismissListener(dialog1 -> { SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText); }); }