List of usage examples for android.app AlertDialog setOnDismissListener
public void setOnDismissListener(@Nullable OnDismissListener listener)
From source file:com.appfirst.activities.details.AFServerDetail.java
/** * Draw a view to display disk status.//from ww w. j a v a 2s. co m * * @return a AlertDialog containing the view. */ @Override protected Dialog createDiskBusyDialog() { AlertDialog.Builder builder; AlertDialog alertDialog; builder = new AlertDialog.Builder(this); builder.setView(createDiskBusyListDialog()); builder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { removeDialog(DISK_BUSY_DIALOG); } }); if (MainHelper.isScreenVertical(this, WINDOW_SERVICE)) { builder.setMessage("Disk busy"); } alertDialog = builder.create(); alertDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface arg0) { // TODO Auto-generated method stub currentDialogId = -1; } }); return alertDialog; }
From source file:com.nachiket.titan.LibraryActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case MENU_SEARCH: setSearchBoxVisible(!mSearchBoxVisible); return true; case MENU_PLAYBACK: openPlaybackActivity();// w ww.j a v a 2s.com return true; case MENU_SORT: { MediaAdapter adapter = (MediaAdapter) mCurrentAdapter; int mode = adapter.getSortMode(); int check; if (mode < 0) { check = R.id.descending; mode = ~mode; } else { check = R.id.ascending; } int[] itemIds = adapter.getSortEntries(); String[] items = new String[itemIds.length]; Resources res = getResources(); for (int i = itemIds.length; --i != -1;) { items[i] = res.getString(itemIds[i]); } RadioGroup header = (RadioGroup) getLayoutInflater().inflate(R.layout.sort_dialog, null); header.check(check); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.sort_by); builder.setSingleChoiceItems(items, mode + 1, this); // add 1 for header builder.setNeutralButton(R.string.done, null); AlertDialog dialog = builder.create(); dialog.getListView().addHeaderView(header); dialog.setOnDismissListener(this); dialog.show(); return true; } default: return super.onOptionsItemSelected(item); } }
From source file:com.otaupdater.utils.UserUtils.java
public static void showLoginDialog(final Context ctx, String defUsername, final DialogCallback dlgCallback, final LoginCallback loginCallback) { @SuppressLint("InflateParams") View view = LayoutInflater.from(ctx).inflate(R.layout.login_dialog, null); if (view == null) return;//from w w w .ja v a2 s . c o m final EditText inputUsername = (EditText) view.findViewById(R.id.auth_username); final EditText inputPassword = (EditText) view.findViewById(R.id.auth_password); if (defUsername != null) inputUsername.setText(defUsername); AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setTitle(R.string.alert_login_title); builder.setView(view); builder.setPositiveButton(R.string.login, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { /* set below */ } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); if (loginCallback != null) loginCallback.onCancel(); } }); final AlertDialog dlg = builder.create(); dlg.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { if (dlgCallback != null) dlgCallback.onDialogShown(dlg); Button button = dlg.getButton(DialogInterface.BUTTON_POSITIVE); if (button == null) return; button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final String username = inputUsername.getText().toString(); final String password = inputPassword.getText().toString(); if (username.length() == 0 || password.length() == 0) { Toast.makeText(ctx, R.string.toast_blank_userpass_error, Toast.LENGTH_LONG).show(); return; } dlg.dismiss(); APIUtils.userLogin(ctx, username, password, new APIUtils.ProgressDialogAPICallback(ctx, ctx.getString(R.string.alert_logging_in), dlgCallback) { @Override public void onSuccess(String message, JSONObject respObj) { try { String realUsername = respObj.getString("username"); String hmacKey = respObj.getString("key"); Config.getInstance(ctx).storeLogin(realUsername, hmacKey); if (loginCallback != null) loginCallback.onLoggedIn(realUsername); } catch (JSONException e) { e.printStackTrace(); } } @Override public void onError(String message, JSONObject respObj) { //TODO show some error } }); } }); } }); dlg.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (dlgCallback != null) dlgCallback.onDialogClosed(dlg); } }); dlg.show(); }
From source file:ca.mimic.apphangar.Settings.java
protected void launchDonate() { final Donate donate = new Donate(this); donate.bindServiceConn();// ww w . j a v a2s.c o m 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); }
From source file:com.cleanwiz.applock.ui.activity.SplashActivity.java
public void showUpdateDialog(String intro) { final AlertDialog updateDialogDlg = new AlertDialog.Builder(this).create(); updateDialogDlg.show();/*from w ww. j av a 2 s. c o m*/ Window win = updateDialogDlg.getWindow(); win.setContentView(R.layout.dialog_update); TextView tvMsg = (TextView) win.findViewById(R.id.tvMsg); tvMsg.setText(intro); Button btOk = (Button) win.findViewById(R.id.btOk); ImageView closeImageView = (ImageView) win.findViewById(R.id.updateclose); closeImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub updateDialogDlg.dismiss(); SplashHandler handler = new SplashHandler(); Message msg = new Message(); msg.what = CHECKVERSION_CANCEL; handler.sendMessage(msg); } }); btOk.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { SplashHandler handler = new SplashHandler(); Message msg = new Message(); msg.what = CHECKVERSION_DOWN; handler.sendMessage(msg); } }); updateDialogDlg.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { // TODO Auto-generated method stub List<UpdateVersionManafer> updateVersionManafers = updateVersionManagerService.getVersionManafers(); for (UpdateVersionManafer updateVersionManafer : updateVersionManafers) { updateVersionManafer.setLasttipdate(new Date().getTime()); updateVersionManagerService.modifyTipsDate(updateVersionManafer); break; } SplashHandler handler = new SplashHandler(); Message msg = new Message(); msg.what = CHECKVERSION_CANCEL; handler.sendMessage(msg); } }); }
From source file:no.barentswatch.fiskinfo.BaseActivity.java
/** * This function creates a "<code>positive</code>:see google docs" pop up * dialog which takes in the context of the current activity * // w ww. j a va2 s.c o m * @param activityContext * the context of the current activity * @param rPathToTitleOfPopup * The R.path to the title * @param rPathToTextInTheBodyOfThePopup * The R.path to the text which will be contained in the body */ public void createNewPositiveDialog(Context activityContext, int rPathToTitleOfPopup, int rPathToTextInTheBodyOfThePopup) { AlertDialog.Builder builder = new AlertDialog.Builder(activityContext); builder.setTitle(rPathToTitleOfPopup); builder.setMessage(rPathToTextInTheBodyOfThePopup); builder.setPositiveButton("OK", null); AlertDialog dialog = builder.show(); dialog.setCanceledOnTouchOutside(false); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { // TODO Auto-generated method stub actionBar.setSelectedNavigationItem(adapter.getCount()); } }); TextView messageView = (TextView) dialog.findViewById(android.R.id.message); messageView.setGravity(Gravity.CENTER); }
From source file:com.mishiranu.dashchan.ui.navigator.NavigatorActivity.java
private void showRestartDialogIfNeeded() { if (ChanManager.getInstance().checkNewExtensionsInstalled() && mayShowRestartDialog) { mayShowRestartDialog = false;//from w ww . j av a2 s .c om AlertDialog dialog = new AlertDialog.Builder(this).setMessage(R.string.message_packages_installed) .setPositiveButton(R.string.action_restart, (d, which) -> { Bundle outState = new Bundle(); writePagesState(outState); pageManager.writeToStorage(outState); NavigationUtils.restartApplication(this); }).setNegativeButton(android.R.string.cancel, null).create(); dialog.setOnDismissListener(d -> mayShowRestartDialog = true); dialog.setCanceledOnTouchOutside(false); dialog.show(); uiManager.dialog().notifySwitchBackground(); } }
From source file:com.agustinprats.myhrv.fragment.MonitorFragment.java
/** Shows the connect dialog displaying a list of available devices to connect */ private void showConnectDialog() { LayoutInflater inflater = getMainActivity().getLayoutInflater(); // Init view/*from w w w.j av a 2 s. c o m*/ RelativeLayout devicesDialogView = (RelativeLayout) inflater.inflate(R.layout.devices_dialog, null); AlertDialog.Builder devicesDialogBuilder = new AlertDialog.Builder(getMainActivity()); devicesDialogBuilder.setTitle(R.string.devices_available); devicesDialogBuilder.setView(devicesDialogView); final AlertDialog devicesDialog = devicesDialogBuilder.create(); _searchingDevicesText = (TextView) devicesDialogView.findViewById(R.id.searchingText); ListView listView = (ListView) devicesDialogView.findViewById(R.id.listView); listView.setEmptyView(_searchingDevicesText); final HeartRateDeviceListAdapter mHeartRateDeviceListAdapter = new HeartRateDeviceListAdapter(inflater); _heartRateDeviceListAdapter = mHeartRateDeviceListAdapter; final HeartRateService service = getMainActivity().getHeartRateService(); service.startScanningDevices(); listView.setAdapter(mHeartRateDeviceListAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { final HeartRateDevice device = mHeartRateDeviceListAdapter.getDevice(position); if (device != null) { if (service.isScanning()) service.stopScanningDevices(); Log.d(TAG, "connecting from devices dialog"); service.connect(device.getAddress()); } devicesDialog.dismiss(); } }); devicesDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { service.stopScanningDevices(); _heartRateDeviceListAdapter = null; } }); devicesDialog.show(); }
From source file:no.barentswatch.fiskinfo.BaseActivity.java
public void createConfirmLogoutDialog(Context activityContext, int rPathToTitleOfPopup, int rPathToTextInTheBodyOfThePopup) { AlertDialog.Builder builder = new AlertDialog.Builder(activityContext); AlertDialog dialog; builder.setTitle(rPathToTitleOfPopup); builder.setMessage(rPathToTextInTheBodyOfThePopup); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override// ww w.j a v a 2 s .c om public void onClick(DialogInterface dialog, int which) { invalidateAuthenticationData(); dialog.dismiss(); loadView(MainActivity.class); } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog = builder.create(); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { actionBar.setSelectedNavigationItem(adapter.getCount()); } }); dialog.show(); dialog.setCanceledOnTouchOutside(false); TextView messageView = (TextView) dialog.findViewById(android.R.id.message); messageView.setGravity(Gravity.CENTER); }
From source file:net.nightwhistler.pageturner.fragment.ReadingFragment.java
private void showSearchResultDialog(final List<SearchResult> results) { if (isSearchResultsDialogShowing) { return;//w w w. j a v a2s.c o m } isSearchResultsDialogShowing = true; AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.search_results); SearchResultAdapter adapter = new SearchResultAdapter(context, bookView, results); builder.setAdapter(adapter, adapter); AlertDialog dialog = builder.create(); dialog.setOwnerActivity(getActivity()); dialog.setOnDismissListener(d -> isSearchResultsDialogShowing = false); dialog.show(); }