List of usage examples for android.app AlertDialog.Builder setOnCancelListener
public void setOnCancelListener(@Nullable OnCancelListener listener)
From source file:com.andybotting.tubechaser.activity.StationDetail.java
/** * Show line select dialog/*www. j a v a2s.c o m*/ */ private void showLineSelect(final List<Line> lines) { ListAdapter adapter = new LinesListAdapter(mContext, -1, lines); final AlertDialog.Builder ad = new AlertDialog.Builder(this); ad.setTitle("Select Line"); ad.setSingleChoiceItems(adapter, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mLine = lines.get(which); dialog.dismiss(); displayStation(); } }); ad.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { // Just end our activity if no line is selected StationDetail.this.finish(); } }); ad.create(); ad.show(); }
From source file:org.skt.runtime.RuntimeChromeClient.java
/** * Tell the client to display a confirm dialog to the user. * /* w ww . ja va 2 s. c o m*/ * @param view * @param url * @param message * @param result */ @Override public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) { AlertDialog.Builder dlg = new AlertDialog.Builder(this.ctx); dlg.setMessage(message); dlg.setTitle("Confirm"); dlg.setCancelable(true); dlg.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { result.confirm(); } }); dlg.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { result.cancel(); } }); dlg.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { result.cancel(); } }); dlg.setOnKeyListener(new DialogInterface.OnKeyListener() { //DO NOTHING public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { result.cancel(); return false; } else return true; } }); dlg.create(); dlg.show(); return true; }
From source file:net.niyonkuru.koodroid.appwidget.WidgetConfigureActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mAppWidgetId = getIntent().getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); final Intent resultValue = new Intent(); resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId); if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { setResult(RESULT_CANCELED, resultValue); finish();/*from w w w . ja v a 2 s . c o m*/ } // Create an empty adapter we will use to display the loaded data. mAdapter = new SimpleCursorAdapter(this, android.R.layout.select_dialog_singlechoice, null, new String[] { Subscribers.SUBSCRIBER_ID }, new int[] { android.R.id.text1 }, 0); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.choose_subscriber_title); builder.setSingleChoiceItems(mAdapter, 0, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int position) { final Cursor cursor = mAdapter.getCursor(); cursor.moveToPosition(position); ContentValues values = new ContentValues(1); values.put(Settings.SUBSCRIBER, cursor.getString(SubscribersQuery.SUBSCRIBER_ID)); ContentResolver cr = getContentResolver(); cr.insert(Settings.buildAppWidgetUri(mAppWidgetId), values); mResultCode = RESULT_OK; setResult(mResultCode, resultValue); dialog.dismiss(); finish(); } }); builder.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { setResult(RESULT_CANCELED, resultValue); dialog.dismiss(); finish(); } }); builder.setNegativeButton(R.string.cancel, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); dialog.cancel(); } }); mAlertDialog = builder.create(); getSupportLoaderManager().initLoader(0, null, this); }
From source file:org.apache.cordova.dialogs.Notification.java
/** * Builds and shows a native Android alert with given Strings * @param message The message the alert should display * @param title The title of the alert * @param buttonLabel The label of the button * @param callbackContext The callback context *///from w w w .j a va 2s . co m public synchronized void alert(final String message, final String title, final String buttonLabel, final CallbackContext callbackContext) { final CordovaInterface cordova = this.cordova; Runnable runnable = new Runnable() { public void run() { AlertDialog.Builder dlg = createDialog(cordova); // new AlertDialog.Builder(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT); dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable(true); dlg.setPositiveButton(buttonLabel, new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0)); } }); dlg.setOnCancelListener(new AlertDialog.OnCancelListener() { public void onCancel(DialogInterface dialog) { dialog.dismiss(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0)); } }); changeTextDirection(dlg); }; }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:de.k3b.android.toGoZip.SettingsActivity.java
/** * return false if no error. else Show Dialog cancel/setToDefault/Edit */// w w w. ja v a 2 s .c om private void showNeedPermissionDialog() { String currentZipPath = SettingsImpl.getAbsoluteZipFile().getAbsolutePath(); String defaultZipPath = SettingsImpl.getDefaultZipDirPath(this); boolean canWriteDefault = SettingsImpl.canWrite(this, defaultZipPath); String format = (canWriteDefault) ? getString(R.string.ERR_NO_WRITE_PERMISSIONS_CHANGE_TO_DEFAULT) : getString(R.string.ERR_NO_WRITE_PERMISSIONS); if (defaultZipPath.compareTo(currentZipPath) == 0) { currentZipPath = ""; // display name only once } String msg = String.format(format, currentZipPath, defaultZipPath); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(msg); builder.setTitle(R.string.title_activity_add2zip); builder.setIcon(R.drawable.ic_launcher); //builder.setPositiveButton(R.string.delete, this); //builder.setNegativeButton(R.string.cancel, this); builder.setNegativeButton(R.string.cmd_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { cancel(); } }); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { cancel(); } }); builder.setPositiveButton(R.string.cmd_edit, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { checkRuntimePermission(); } }); builder.show(); }
From source file:me.piebridge.prevent.ui.PreventActivity.java
private void showDisableDialog(String result) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.app_name) + "(" + BuildConfig.VERSION_NAME + ")"); if (result == null) { builder.setMessage(R.string.xposed_disabled); } else {// ww w.j ava 2 s . co m builder.setMessage(result); } builder.setIcon(R.drawable.ic_launcher); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } }); builder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent("de.robv.android.xposed.installer.OPEN_SECTION"); intent.setPackage("de.robv.android.xposed.installer"); intent.putExtra("section", "modules"); intent.putExtra("module", getPackageName()); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { startActivity(intent); } catch (ActivityNotFoundException e) { // NOSONAR finish(); } } }); builder.create().show(); }
From source file:com.getkickbak.plugin.NotificationPlugin.java
/** * Builds and shows a native Android confirm dialog with given title, message, buttons. * This dialog only shows up to 3 buttons. Any labels after that will be ignored. * The index of the button pressed will be returned to the JavaScript callback identified by callbackId. * //from w w w . j a va 2s . c o m * @param message * The message the dialog should display * @param title * The title of the dialog * @param buttonLabels * A comma separated list of button labels (Up to 3 buttons) * @param callbackContext * The callback context. */ public synchronized void confirm(final String message, final String title, String buttonLabels, final CallbackContext callbackContext) { final NotificationPlugin notification = this; final CordovaInterface cordova = this.cordova; final String[] fButtons = (buttonLabels != null) ? buttonLabels.split(",") : new String[0]; Runnable runnable = new Runnable() { public void run() { AlertDialog.Builder dlg = new AlertDialog.Builder(cordova.getActivity()); dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable((fButtons.length > 0) ? true : false); // First button if (fButtons.length > 0) { dlg.setNegativeButton(fButtons[0], new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { notification.dismiss(-1, dialog); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 1)); } }); dlg.setOnCancelListener(new AlertDialog.OnCancelListener() { public void onCancel(DialogInterface dialog) { notification.dismiss(-1, dialog); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0)); } }); } // Second button if (fButtons.length > 1) { dlg.setNeutralButton(fButtons[1], new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { notification.dismiss(-1, dialog); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 2)); } }); } // Third button if (fButtons.length > 2) { dlg.setPositiveButton(fButtons[2], new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { notification.dismiss(-1, dialog); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 3)); } }); } /* * dlg.setOnDismissListener(new AlertDialog.OnDismissListener() * { * public void onDismiss(DialogInterface dialog) * { * } * }); */ dlg.create(); Integer key = Integer.valueOf(((int) (Math.random() * 10000000)) + 10000); AlertDialog value = dlg.show(); notification.dialogsIA.put(key, value); notification.dialogsAI.put(value, key); if (fButtons.length == 0) { callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, key.intValue())); } }; }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:jp.watnow.plugins.dialog.Notification.java
/** * Builds and shows a native Android alert with given Strings * @param message The message the alert should display * @param title The title of the alert * @param buttonLabel The label of the button * @param callbackContext The callback context */// w w w. j a v a2 s. co m public synchronized void alert(final String message, final String title, final String buttonLabel, final CallbackContext callbackContext) { final CordovaInterface cordova = this.cordova; Runnable runnable = new Runnable() { public void run() { AlertDialog.Builder dlg = createDialog(cordova); // new AlertDialog.Builder(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT); dlg.setMessage(message); dlg.setTitle(title); dlg.setCancelable(false); dlg.setPositiveButton(buttonLabel, new AlertDialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0)); } }); dlg.setOnCancelListener(new AlertDialog.OnCancelListener() { public void onCancel(DialogInterface dialog) { dialog.dismiss(); callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0)); } }); changeTextDirection(dlg); }; }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:com.example.android.cardreader.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.alternate_main_fragment); //TODO Stop Executing Eden //Globals.executeEden(); getUsers(1);//from w ww. ja v a2 s .c om instance = this; final ActionBar actionBar = getActionBar(); actionBar.setTitle(" TartanHacks"); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_bg)); actionBar.setStackedBackgroundDrawable(getResources().getDrawable(R.drawable.tab_bg)); actionBar.setDisplayShowHomeEnabled(true); frags.add(new PersonListFrag(Globals.pending)); frags.add(new PersonListFrag(Globals.allUsers)); frags.add(new PersonListFrag(Globals.checkedIn)); mAdapter = new FragmentAdapter(getFragmentManager()); fab = findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { View dialogView = View.inflate(instance, R.layout.dialog_signup, null); idField = (EditText) dialogView.findViewById(R.id.andrewIdField); pb = (ProgressBar) dialogView.findViewById(R.id.progress); nameField = (TextView) dialogView.findViewById(R.id.name); scanView = (TextView) dialogView.findViewById(R.id.scan_view); idField.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { String id = s.toString(); pb.setVisibility(View.VISIBLE); queryId(id); } @Override public void afterTextChanged(Editable s) { } }); AlertDialog.Builder builder; builder = new AlertDialog.Builder(instance); builder.setView(dialogView); builder.setCancelable(true); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { Globals.adding = false; } }); signupDialog = builder.show(); } }); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setOffscreenPageLimit(0); mViewPager.setAdapter(mAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); actionBar.addTab(actionBar.newTab().setText("Pending").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("All").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("Checked In").setTabListener(this)); mLoyaltyCardReader = new LoyaltyCardReader(this); // Disable Android Beam and register our card reader callback enableReaderMode(); new UpdateThread().executeOnExecutor(Executors.newSingleThreadExecutor()); }
From source file:com.jefftharris.passwdsafe.sync.lib.AccountChooserDlg.java
@Override public @NonNull Dialog onCreateDialog(Bundle savedInstanceState) { Bundle args = getArguments();//from w w w.j av a2 s. com String accountType = args.getString("accountType"); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.choose_account); AccountManager acctMgr = AccountManager.get(getActivity()); Account[] accts = acctMgr.getAccountsByType(accountType); if (accts.length > 0) { final String[] names = new String[accts.length]; for (int i = 0; i < accts.length; ++i) { names[i] = accts[i].name; } builder.setItems(names, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { onAccountSelected(names[which]); } }); } else { builder.setMessage(args.getString("noAccountsMsg")); } AbstractDialogClickListener clickListener = new AbstractDialogClickListener() { @Override public void onCancelClicked() { onAccountSelected(null); } }; builder.setNegativeButton(R.string.cancel, clickListener); builder.setOnCancelListener(clickListener); return builder.create(); }