List of usage examples for android.app AlertDialog setOnDismissListener
public void setOnDismissListener(@Nullable OnDismissListener listener)
From source file:Main.java
public static void showMessage(Context context, String title, String message, OnDismissListener listener) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context); // set title/* www . j a v a 2s . c o m*/ alertDialogBuilder.setTitle(title); // set dialog message alertDialogBuilder.setMessage(message).setCancelable(true); // create alert dialog AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.setCanceledOnTouchOutside(true); if (listener != null) alertDialog.setOnDismissListener(listener); // show it alertDialog.show(); }
From source file:org.dkf.jmule.util.UIUtils.java
/** * * @param context - containing Context. * @param showInstallationCompleteSection - true if you want to display "Your installation is now complete. Thank You" section * @param dismissListener - what happens when the dialog is dismissed. * @param referrerContextSuffix - string appended at the end of social pages click urls's ?ref=_android_ parameter. *///from www. j ava 2 s . c om public static void showSocialLinksDialog(final Context context, boolean showInstallationCompleteSection, DialogInterface.OnDismissListener dismissListener, String referrerContextSuffix) { AlertDialog.Builder builder = new AlertDialog.Builder(context); View customView = View.inflate(context, R.layout.view_social_buttons, null); builder.setView(customView); builder.setPositiveButton(context.getString(android.R.string.ok), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); final AlertDialog socialLinksDialog = builder.create(); socialLinksDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); socialLinksDialog.setOnDismissListener(dismissListener); ImageButton githubButton = (ImageButton) customView.findViewById(R.id.view_buttons_github); //ImageButton twitterButton = (ImageButton) customView.findViewById(R.id.view_social_buttons_twitter_button); //ImageButton redditButton = (ImageButton) customView.findViewById(R.id.view_social_buttons_reddit_button); //final String referrerParam = "?ref=android_" + ((referrerContextSuffix!=null) ? referrerContextSuffix.trim() : ""); githubButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { UIUtils.openURL(v.getContext(), Constants.GITHUB_PAGE); } }); /* twitterButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { UIUtils.openURL(v.getContext(), Constants.SOCIAL_URL_TWITTER_PAGE + referrerParam); } }); redditButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { UIUtils.openURL(v.getContext(), Constants.SOCIAL_URL_REDDIT_PAGE + referrerParam); } }); */ if (showInstallationCompleteSection) { LinearLayout installationCompleteLayout = (LinearLayout) customView .findViewById(R.id.view_social_buttons_installation_complete_layout); installationCompleteLayout.setVisibility(View.VISIBLE); ImageButton dismissCheckButton = (ImageButton) customView .findViewById(R.id.view_social_buttons_dismiss_check); dismissCheckButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { socialLinksDialog.dismiss(); } }); } socialLinksDialog.show(); }
From source file:com.frostwire.android.gui.util.UIUtils.java
/** * @param context - containing Context. * @param showInstallationCompleteSection - true if you want to display "Your installation is now complete. Thank You" section * @param dismissListener - what happens when the dialog is dismissed. * @param referrerContextSuffix - string appended at the end of social pages click urls's ?ref=_android_ parameter. *//*from w w w. j av a 2 s. c o m*/ public static void showSocialLinksDialog(final Context context, boolean showInstallationCompleteSection, DialogInterface.OnDismissListener dismissListener, String referrerContextSuffix) { AlertDialog.Builder builder = new AlertDialog.Builder(context); View customView = View.inflate(context, R.layout.view_social_buttons, null); builder.setView(customView); builder.setPositiveButton(context.getString(android.R.string.ok), (dialog, which) -> dialog.dismiss()); final AlertDialog socialLinksDialog = builder.create(); socialLinksDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); socialLinksDialog.setOnDismissListener(dismissListener); ImageButton fbButton = customView.findViewById(R.id.view_social_buttons_facebook_button); ImageButton twitterButton = customView.findViewById(R.id.view_social_buttons_twitter_button); ImageButton redditButton = customView.findViewById(R.id.view_social_buttons_reddit_button); final String referrerParam = "?ref=android_" + ((referrerContextSuffix != null) ? referrerContextSuffix.trim() : ""); fbButton.setOnClickListener( v -> UIUtils.openURL(v.getContext(), Constants.SOCIAL_URL_FACEBOOK_PAGE + referrerParam)); twitterButton.setOnClickListener( v -> UIUtils.openURL(v.getContext(), Constants.SOCIAL_URL_TWITTER_PAGE + referrerParam)); redditButton.setOnClickListener( v -> UIUtils.openURL(v.getContext(), Constants.SOCIAL_URL_REDDIT_PAGE + referrerParam)); if (showInstallationCompleteSection) { LinearLayout installationCompleteLayout = customView .findViewById(R.id.view_social_buttons_installation_complete_layout); installationCompleteLayout.setVisibility(View.VISIBLE); ImageButton dismissCheckButton = customView.findViewById(R.id.view_social_buttons_dismiss_check); dismissCheckButton.setOnClickListener(v -> socialLinksDialog.dismiss()); } socialLinksDialog.show(); }
From source file:com.otaupdater.utils.Utils.java
public static void showProKeyOnlyFeatureDialog(final Context ctx, final DialogCallback callback) { AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setTitle(R.string.prokey_only_feature_title); builder.setMessage(R.string.prokey_only_feature_message); builder.setPositiveButton(R.string.prokey_only_get, new DialogInterface.OnClickListener() { @Override// w ww . j a va 2 s .c om public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Intent i = new Intent(ctx, SettingsActivity.class); i.setAction(SettingsActivity.EXTRA_SHOW_GET_PROKEY_DLG); i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); ctx.startActivity(i); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); final AlertDialog dlg = builder.create(); dlg.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { if (callback != null) callback.onDialogShown(dlg); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (callback != null) callback.onDialogClosed(dlg); } }); dlg.show(); }
From source file:tr.com.turkcellteknoloji.turkcellupdater.UpdaterDialogManager.java
/** * Creates a dialog for given message./* ww w .jav a 2s . c o m*/ * * @param activity * Parent activity. * @param message * Message contents * @param dismissListener * Listener that will be called when dialog is closed or * cancelled. * @return Created dialog. */ public static Dialog createMessageDialog(Activity activity, Message message, OnDismissListener dismissListener) { final AlertDialog.Builder builder = new AlertDialog.Builder(activity); final String title = message.description == null ? null : message.description.get(MessageDescription.KEY_TITLE); if (!Utilities.isNullOrEmpty(title)) { builder.setTitle(title); } final View dialogContentsView = createMessageDialogContentsView(activity, message.description); builder.setView(dialogContentsView); initializeMessageDialogButtons(activity, builder, message); builder.setCancelable(true); final AlertDialog dialog = builder.create(); if (Utilities.isNullOrEmpty(title)) { dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); } dialog.setOnDismissListener(dismissListener); return dialog; }
From source file:nz.ac.auckland.lablet.ExperimentAnalysisBaseActivity.java
protected void showErrorAndFinish(String error) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(error);//ww w .j a v a 2 s .c o m builder.setNeutralButton("Ok", null); AlertDialog dialog = builder.create(); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { finish(); } }); dialog.show(); }
From source file:br.com.anteros.android.persistence.backup.ImportDatabaseTask.java
@Override protected void onPostExecute(final String errMsg) { if (dialog.isShowing()) { dialog.dismiss();/*www .j a v a2 s. co m*/ } AlertDialog.Builder dialog = new AlertDialog.Builder(activity); dialog.setTitle("Aviso"); if (errMsg.equals("OK")) { dialog.setMessage("Importao realizada com sucesso!"); Toast.makeText(activity, "Importao realizada com sucesso!", Toast.LENGTH_SHORT).show(); } else { dialog.setMessage("Importao falhou - " + errMsg); Toast.makeText(activity, "Importao falhou - " + errMsg, Toast.LENGTH_LONG).show(); } dialog.setCancelable(false); dialog.setPositiveButton("Ok", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog dlg = dialog.create(); dlg.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { activity.setResult(ImportDatabaseTask.TABLES_RECREATED); activity.finish(); } }); dlg.show(); }
From source file:com.vuze.android.remote.dialog.DialogFragmentRcmAuth.java
@NonNull @Override//from w w w . j a v a 2 s.co m public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialogBuilder alertDialogBuilder = AndroidUtils.createAlertDialogBuilder(getActivity(), R.layout.dialog_rcm_auth); View view = alertDialogBuilder.view; Builder builder = alertDialogBuilder.builder; AndroidUtils.linkify(view, R.id.rcm_line1); AndroidUtils.linkify(view, R.id.rcm_line2); AndroidUtils.linkify(view, R.id.rcm_line3); AndroidUtils.linkify(view, R.id.rcm_rb_all); AndroidUtils.linkify(view, R.id.rcm_rb_pre); // Add action buttons builder.setPositiveButton(R.string.accept, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { closeDialog(true); } }); builder.setNegativeButton(R.string.decline, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { closeDialog(false); DialogFragmentRcmAuth.this.getDialog().cancel(); } }); builder.setCancelable(true); AlertDialog dlg = builder.create(); dlg.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { showingDialog = false; } }); return dlg; }
From source file:com.android.screenspeak.contextmenu.ListMenuManager.java
private void showDialogMenu(String title, CharSequence[] items, final ContextMenu menu) { if (items == null || items.length == 0) { return;// w w w .jav a2s . c o m } DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { final ContextMenuItem menuItem = menu.getItem(item); if (menuItem.hasSubMenu()) { menuItem.onClickPerformed(); } else { mDeferredAction = getDeferredAction(menuItem); } } }; AlertDialog.Builder builder = new AlertDialog.Builder(mService); builder.setTitle(title); builder.setItems(items, listener); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { mMenuShown--; if (mMenuShown == 0) { long delay = 0; if (mDeferredAction != null) { mService.addEventListener(ListMenuManager.this); if (needFocusDelay(mDeferredAction.actionId)) { delay = RESET_FOCUS_DELAY; } } mService.resetFocusedNode(delay); mCurrentDialog = null; } } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { alert.getWindow().setType(WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY); } else { alert.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR); } alert.show(); mCurrentDialog = alert; mMenuShown++; }
From source file:net.granoeste.commons.ui.IconContextMenuDialogFragment.java
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); final Bundle args = getArguments(); if (mTitle == null && args != null) { mTitle = args.getString(ICON_CONTEXT_MENU_TITLE); }/* ww w . ja v a 2 s . c o m*/ if (args != null) { mMenuItems = (ArrayList<IconContextMenuItem>) args.getSerializable(ICON_CONTEXT_MENU_ITEMS); } if (mMenuAdapter == null) { if (mMenuItems != null) { mMenuAdapter = new IconMenuAdapter(getActivity()); for (final IconContextMenuItem iconContextMenuItem : mMenuItems) { mMenuAdapter.addItem(iconContextMenuItem); } } } if (!TextUtils.isEmpty(mTitle)) { builder.setTitle(mTitle); } builder.setAdapter(mMenuAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialoginterface, final int i) { final IconContextMenuItem item = (IconContextMenuItem) mMenuAdapter.getItem(i); mCallbacks.onIconContextMenuOnItemSelected(item); dismiss(); } }); builder.setInverseBackgroundForced(true); final AlertDialog dialog = builder.create(); dialog.setOnCancelListener(this); dialog.setOnDismissListener(this); return dialog; }