List of usage examples for android.app AlertDialog setOnDismissListener
public void setOnDismissListener(@Nullable OnDismissListener listener)
From source file:com.otaupdater.utils.UserUtils.java
public static void showAccountDialog(final Context ctx, final DialogCallback dlgCallback) { final Config cfg = Config.getInstance(ctx); final AlertDialog dlg = new AlertDialog.Builder(ctx).setTitle("OTA Update Center Account") .setMessage("Logged in as: " + cfg.getUsername()) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override//from ww w .j a v a 2 s . c o m public void onClick(DialogInterface dialogInterface, int i) { } }).setNegativeButton("Sign Out", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { APIUtils.userLogout(ctx, new APIUtils.APIAdapter() { @Override public void onSuccess(String message, JSONObject respObj) { cfg.clearLogin(); } }); } }).create(); dlg.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { if (dlgCallback != null) dlgCallback.onDialogShown(dlg); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (dlgCallback != null) dlgCallback.onDialogClosed(dlg); } }); dlg.show(); }
From source file:com.nks.nksmod.otaupdater.DownloadsActivity.java
private void showNoFlashDialog(String file) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.alert_install_title); builder.setMessage(getString(R.string.alert_noinstall_message, file)); builder.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override/*from w w w .ja v a 2 s . c o m*/ 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) { onDialogShown(dlg); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { onDialogClosed(dlg); } }); dlg.show(); }
From source file:com.nks.nksmod.otaupdater.DownloadsActivity.java
protected void showFlashDialog(final BaseInfo info) { if (PropUtils.getNoFlash()) { //can't flash programmatically, must flash manually showNoFlashDialog(info.getDownloadFileName()); }/*w w w . ja v a2s . c om*/ String[] installOpts = getResources().getStringArray(R.array.install_options); final boolean[] selectedOpts = new boolean[installOpts.length]; selectedOpts[selectedOpts.length - 1] = true; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.alert_install_title); builder.setMultiChoiceItems(installOpts, selectedOpts, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { selectedOpts[which] = isChecked; } }); builder.setPositiveButton(R.string.install, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); AlertDialog.Builder builder = new AlertDialog.Builder(DownloadsActivity.this); builder.setTitle(R.string.alert_install_title); builder.setMessage(R.string.alert_install_message); builder.setPositiveButton(R.string.install, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { flashFiles(new String[] { info.getRecoveryFilePath() }, selectedOpts[0], selectedOpts[2], selectedOpts[1]); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.show(); } }); 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) { onDialogShown(dlg); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { onDialogClosed(dlg); } }); dlg.show(); }
From source file:nz.ac.auckland.lablet.script.ScriptRunnerActivity.java
private void showErrorAndFinish(String error, @Nullable String message) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(error);//from w ww .jav a 2 s. c om if (message != null) { builder.setMessage(message); } builder.setNeutralButton("Ok", null); AlertDialog dialog = builder.create(); dialog.setOnDismissListener(dialogInterface -> finish()); dialog.show(); }
From source file:com.hybris.mobile.app.commerce.adapter.CartProductListAdapter.java
/** * Display the delete item dialog//from w w w . j a va 2s . c o m * * @param positionToDelete */ private void showDeleteItemDialog(final int positionToDelete) { // Creating the dialog AlertDialog.Builder builder = new AlertDialog.Builder( new ContextThemeWrapper(getContext(), R.style.AlertDialogCustom)); builder.setMessage(R.string.cart_menu_delete_item_confirmation_title).setPositiveButton( R.string.cart_menu_delete_item_remove_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { QueryCartEntry queryCartEntry = new QueryCartEntry(); queryCartEntry.setEntryNumber(positionToDelete + ""); CommerceApplication.getContentServiceHelper() .deleteCartEntry(new ResponseReceiver<CartModification>() { @Override public void onResponse(Response<CartModification> response) { updateCart(); } @Override public void onError(Response<ErrorList> response) { UIUtils.showError(response, getContext()); // Update the cart SessionHelper.updateCart(getContext(), mRequestId, false); } }, mRequestId, queryCartEntry, null, false, null, mOnRequestListener); } }).setNegativeButton(R.string.cancel, null); AlertDialog alert = builder.create(); // The dialog is cancelable by 3 ways: cancel button, click outside the dialog, click on the back button alert.setCancelable(true); alert.setCanceledOnTouchOutside(true); alert.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { // We revert to the default quantity when we dismiss the dialog if (mSelectedQuantity != null) { mSelectedQuantity.getEditText().clearFocus(); mSelectedQuantity.getEditText().setText(mSelectedQuantity.getDefaultValue() + ""); } } }); alert.show(); }
From source file:com.otaupdater.SettingsActivity.java
private void showGetProKeyDialog() { if (cfg.hasProKey()) return;//from ww w .jav a2s . c o m AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.settings_prokey_title); final boolean playServices = Utils.checkPlayServices(this); builder.setItems(playServices ? R.array.prokey_ops : R.array.prokey_ops_nomarket, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { which -= playServices ? 1 : 0; switch (which) { case -1: try { Bundle buyIntentBundle = service.getBuyIntent(3, getPackageName(), Config.PROKEY_SKU, "inapp", null); PendingIntent buyIntent = buyIntentBundle.getParcelable("BUY_INTENT"); if (buyIntent != null) startIntentSenderForResult(buyIntent.getIntentSender(), PROKEY_REQ_CODE, new Intent(), 0, 0, 0); } catch (Exception e) { Toast.makeText(SettingsActivity.this, R.string.prokey_error_init, Toast.LENGTH_SHORT).show(); } break; case 0: redeemProKey(); break; // case 1: // startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Config.SITE_BASE_URL + Config.DONATE_URL))); // break; } } }); final AlertDialog dlg = builder.create(); dlg.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { onDialogShown(dlg); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { onDialogClosed(dlg); } }); dlg.show(); }
From source file:link.kjr.file_manager.MainActivity.java
public void deleteFiles(MenuItem item) { if (selectedFiles == null || (selectedFiles.size() == 0)) { Toast.makeText(this, R.string.no_files_selected, Toast.LENGTH_SHORT).show(); return;/*from w w w .j av a 2 s . c om*/ } AlertDialog.Builder ab = new AlertDialog.Builder(this); View view = getLayoutInflater().inflate(R.layout.confirm_dialog, null); ((TextView) view.findViewById(R.id.title)).setText("Delete the following files:"); ((TextView) view.findViewById(R.id.body)).setText(getSelectedFiles()); final MainActivity activity = this; ab.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { deleteFiles(activity); } }); ab.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { refresh(); } }); ab.setView(view); AlertDialog ad = ab.create(); ad.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { refresh(); } }); ad.show(); }
From source file:link.kjr.file_manager.MainActivity.java
public void moveFiles(MenuItem item) { if (selectedFiles == null || (selectedFiles.size() == 0)) { Toast.makeText(this, "no files selected", Toast.LENGTH_SHORT).show(); return;/*ww w . j a v a 2s. c o m*/ } AlertDialog.Builder ab = new AlertDialog.Builder(this); View view = getLayoutInflater().inflate(R.layout.confirm_dialog, null); ((TextView) view.findViewById(R.id.title)).setText("move the following files to :" + currentPath); ((TextView) view.findViewById(R.id.body)).setText(getSelectedFiles()); final MainActivity activity = this; ab.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { activity.handler.post(new Runnable() { @Override public void run() { moveFiles(activity); } }); } }); ab.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); ab.setView(view); AlertDialog ad = ab.create(); ad.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { } }); ad.show(); }
From source file:link.kjr.file_manager.MainActivity.java
public void copyFiles(MenuItem item) { if (selectedFiles == null || (selectedFiles.size() == 0)) { Toast.makeText(this, R.string.no_files_selected, Toast.LENGTH_SHORT).show(); return;/* w ww .j a v a 2 s . co m*/ } AlertDialog.Builder ab = new AlertDialog.Builder(this); View view = getLayoutInflater().inflate(R.layout.confirm_dialog, null); ((TextView) view.findViewById(R.id.title)).setText(R.string.move_selected_files_here + ":" + currentPath); ((TextView) view.findViewById(R.id.body)).setText(getSelectedFiles()); final MainActivity activity = this; ab.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { activity.handler.post(new Runnable() { @Override public void run() { copyFiles(activity); refresh(); } }); } }); ab.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { refresh(); } }); ab.setView(view); AlertDialog ad = ab.create(); ad.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { refresh(); } }); ad.show(); }
From source file:link.kjr.file_manager.MainActivity.java
public void mkdir(MenuItem item) { AlertDialog.Builder ab = new AlertDialog.Builder(this); View view = getLayoutInflater().inflate(R.layout.mkdir_dialog, null); final EditText et = (EditText) view.findViewById(R.id.searchdialogedittext); TextView title = (TextView) view.findViewById(R.id.title); title.setText(getString(R.string.make_directory) + currentPath); final MainActivity activity = this; ab.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() { @Override/*from www . jav a 2 s . co m*/ public void onClick(DialogInterface dialog, int which) { Log.i(BuildConfig.APPLICATION_ID, "will now mkdir"); activity.handler.post(new Runnable() { @Override public void run() { mkdir(currentPath + "/" + et.getText(), activity); } }); Toast.makeText(getApplicationContext(), "mkdir " + currentPath + "/" + et.getText(), Toast.LENGTH_SHORT).show(); } }); ab.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { refresh(); } }); ab.setView(view); AlertDialog ad = ab.create(); ad.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { refresh(); } }); ad.show(); }