Java Code Examples for android.app.AlertDialog#setOnDismissListener()

The following examples show how to use android.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: FileActivity.java    From lrkFM with MIT License 7 votes vote down vote up
/**
 * Adds a bookmark. Prompts for location.
 */
private void promptAndAddBookmark() {
    Set<String> stringSet = new Pref<HashSet<String>>(BOOKMARKS).getValue();
    if (new Pref<Boolean>(BOOKMARK_CURRENT_FOLDER).getValue()) {
        stringSet.add(currentDirectory);
    } else {
        AlertDialog.Builder bookmarkDialogBuilder = new AlertDialog.Builder(this);
        bookmarkDialogBuilder
                .setNegativeButton(R.string.cancel, (dialog, which) -> Log.d(TAG, "Cancel pressed!"))
                .setNeutralButton(R.string.bookmark_this_folder, (dialog, which) -> {
                    stringSet.add(currentDirectory);
                    dialog.cancel();
                }).setView(R.layout.layout_path_prompt)
                .setTitle(R.string.bookmark_set_path);
        AlertDialog alertDialog = bookmarkDialogBuilder.create();
        alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.okay), (dialog, which) -> stringSet.add(((EditText) alertDialog.findViewById(R.id.destinationPath)).getText().toString()));
        alertDialog.setOnDismissListener(dialog -> {
            new Pref<Set<String>>(BOOKMARKS).setValue(stringSet);
            loadUserBookmarks();
        });
        alertDialog.show();
    }
}
 
Example 2
Source File: CustomizeLaunchersActivity.java    From LaunchTime with GNU General Public License v3.0 6 votes vote down vote up
Dialog createDialog() {
    mAdapter = new ArrayAdapter<>(CustomizeLaunchersActivity.this, R.layout.add_list_item);
    mAdapter.add(getString(R.string.custom_icon_select_picture));
    mAdapter.add(getString(R.string.custom_icon_icon_packs));
    if (SpecialIconStore.hasBitmap(CustomizeLaunchersActivity.this, mAppClicked.getComponentName(), SpecialIconStore.IconType.Custom)) {
        mAdapter.add(getString(R.string.custom_icon_clear_icon));
    }

    final AlertDialog.Builder builder = new AlertDialog.Builder(CustomizeLaunchersActivity.this);
    builder.setTitle(R.string.custom_icon_select_icon_type);
    builder.setAdapter(mAdapter, this);

    //builder.setInverseBackgroundForced(false);

    AlertDialog dialog = builder.create();
    dialog.setOnCancelListener(this);
    dialog.setOnDismissListener(this);
    dialog.setOnShowListener(this);
    return dialog;
}
 
Example 3
Source File: MMAlert.java    From wechatsdk-xamarin with Apache License 2.0 6 votes vote down vote up
public static AlertDialog showWebAlert(final Context context, final String title, final String rawUrl, final WebViewClient client, final DialogInterface.OnClickListener lOk,
		final DialogInterface.OnDismissListener lDismiss) {
	final View view = View.inflate(context, R.layout.webalert, null);
	final AlertDialog alert = showAlert(context, title, view, lOk);
	alert.setOnDismissListener(new DialogInterface.OnDismissListener() {

		@Override
		public void onDismiss(DialogInterface dialog) {

			if (lDismiss != null) {
				lDismiss.onDismiss(dialog);
			}
		}
	});
	final WebView info = (WebView) view.findViewById(R.id.info_wv);
	info.loadUrl(rawUrl);
	if (client != null) {
		info.setWebViewClient(client);
	}
	return alert;
}
 
Example 4
Source File: MMAlert.java    From wechatsdk-xamarin with Apache License 2.0 6 votes vote down vote up
public static AlertDialog showWebAlert(final Context context, final String title, final String rawUrl, final WebViewClient client, final String ok, final String cancel,
		final DialogInterface.OnClickListener lOk, final DialogInterface.OnClickListener lCancel, final DialogInterface.OnDismissListener lDismiss) {
	final View view = View.inflate(context, R.layout.webalert, null);
	final AlertDialog alert = showAlert(context, title, view, ok, cancel, lOk, lCancel);
	alert.setOnDismissListener(new DialogInterface.OnDismissListener() {

		@Override
		public void onDismiss(DialogInterface dialog) {
			if (lDismiss != null) {
				lDismiss.onDismiss(dialog);
			}
		}
	});

	final WebView info = (WebView) view.findViewById(R.id.info_wv);
	info.loadUrl(rawUrl);
	if (client != null) {
		info.setWebViewClient(client);
	}
	return alert;
}
 
Example 5
Source File: IconContextMenu.java    From screenstandby with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create menu
 * @return
 */
public Dialog createMenu(String menuItitle) {
	final AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
       builder.setTitle(menuItitle);
       builder.setAdapter(menuAdapter, new DialogInterface.OnClickListener() {
		@Override
		public void onClick(DialogInterface dialoginterface, int i) {
			IconContextMenuItem item = (IconContextMenuItem) menuAdapter.getItem(i);
			
			if (clickHandler != null) {
				clickHandler.onClick(item.actionTag);
			}
		}
	});

       builder.setInverseBackgroundForced(true);

       AlertDialog dialog = builder.create();
       dialog.setOnCancelListener(this);
       dialog.setOnDismissListener(this);
       dialog.setIcon(R.drawable.appico);
       return dialog;
}
 
Example 6
Source File: Settings.java    From Hangar with GNU General Public License v3.0 6 votes vote down vote up
protected void launchDonate() {
    final Donate donate = new Donate(this);
    donate.bindServiceConn();
    View mDonate = donate.getView(mContext);
    mDonate.refreshDrawableState();
    AlertDialog.Builder builder = new AlertDialog.Builder(Settings.this)
            .setTitle(R.string.donate_title)
            .setIcon(R.drawable.ic_logo)
            .setView(mDonate)
            .setPositiveButton(R.string.donate_accept_button, null);
    AlertDialog alert = builder.show();
    alert.setOnDismissListener(new AlertDialog.OnDismissListener() {
        public void onDismiss(DialogInterface dialog) {
            donate.unbindServiceConn();
        }
    });
    donate.setAlert(alert);
}
 
Example 7
Source File: UpdaterDialogManager.java    From TurkcellUpdater_android_sdk with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a dialog for given message.
 *
 * @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;
}
 
Example 8
Source File: CertificateSelectActivity.java    From Plumble with GNU General Public License v3.0 6 votes vote down vote up
private void showCertificateSelectionDialog() {
    int defaultCertificatePosition = -1;
    for (int i = 0; i < mCertificates.size(); i++) {
        if (mCertificates.get(i).isDefault()) {
            defaultCertificatePosition = i;
            break;
        }
    }

    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
    dialogBuilder.setTitle(R.string.pref_certificate_title);
    dialogBuilder.setSingleChoiceItems(
            new ArrayAdapter<>(this, R.layout.list_certificate_item, mCertificates),
            defaultCertificatePosition, this);
    dialogBuilder.setNegativeButton(android.R.string.cancel, null);
    AlertDialog dialog = dialogBuilder.show();
    dialog.setOnDismissListener(this);
}
 
Example 9
Source File: Dialog.java    From SmartFlasher with GNU General Public License v3.0 5 votes vote down vote up
@Override
public AlertDialog show() {
    try {
        AlertDialog dialog = create();
        dialog.setOnDismissListener(mOnDismissListener);
        dialog.show();
        return dialog;
    } catch (WindowManager.BadTokenException ignored) {
        return create();
    }
}
 
Example 10
Source File: DefaultDialogManager.java    From AndroidRate with MIT License 5 votes vote down vote up
/**
 * <p>Creates Rate Dialog.</p>
 *
 * @return created dialog
 */
@SuppressWarnings("unused")
@Nullable
@Override
public Dialog createDialog() {

    AlertDialog.Builder builder = getDialogBuilder(context, dialogOptions.getThemeResId());
    Context dialogContext;

    if (SDK_INT >= HONEYCOMB) {
        dialogContext = builder.getContext();
    } else {
        dialogContext = context;
    }

    final View view = dialogOptions.getView(dialogContext);

    if ((dialogOptions.getType() == CLASSIC) || (view == null)) {
        if (dialogOptions.getType() != CLASSIC) {
            builder = getDialogBuilder(context, 0);
            if (SDK_INT >= HONEYCOMB) {
                dialogContext = builder.getContext();
            }
        }
        supplyClassicDialogArguments(builder, dialogContext);
    } else {
        supplyNonClassicDialogArguments(view, dialogContext);
    }

    final AlertDialog alertDialog = builder
            .setCancelable(dialogOptions.getCancelable())
            .setView(view)
            .create();

    alertDialog.setOnShowListener(showListener);
    alertDialog.setOnDismissListener(dismissListener);

    return alertDialog;
}
 
Example 11
Source File: Dialog.java    From SmartPack-Kernel-Manager with GNU General Public License v3.0 5 votes vote down vote up
@Override
public AlertDialog show() {
    try {
        AlertDialog dialog = create();
        dialog.setOnDismissListener(mOnDismissListener);
        dialog.show();
        return dialog;
    } catch (WindowManager.BadTokenException ignored) {
        return create();
    }
}
 
Example 12
Source File: Dialog.java    From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 5 votes vote down vote up
@Override
public AlertDialog show() {
    try {
        AlertDialog dialog = create();
        dialog.setOnDismissListener(mOnDismissListener);
        dialog.show();
        return dialog;
    } catch (WindowManager.BadTokenException ignored) {
        return create();
    }
}
 
Example 13
Source File: GeckoViewPrompt.java    From focus-android with Mozilla Public License 2.0 5 votes vote down vote up
private AlertDialog createStandardDialog(final AlertDialog.Builder builder,
                                         final BasePrompt prompt,
                                         final GeckoResult<PromptResponse> response) {
    final AlertDialog dialog = builder.create();
    dialog.setOnDismissListener(dialog1 -> {
        if (!prompt.isComplete()) {
            response.complete(prompt.dismiss());
        }
    });
    return dialog;
}
 
Example 14
Source File: Dialog.java    From KernelAdiutor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public AlertDialog show() {
    try {
        AlertDialog dialog = create();
        dialog.setOnDismissListener(mOnDismissListener);
        dialog.show();
        return dialog;
    } catch (WindowManager.BadTokenException ignored) {
        return create();
    }
}