List of usage examples for android.content DialogInterface cancel
void cancel();
From source file:com.cmput301w15t15.travelclaimsapp.activitys.EditClaimActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case R.id.cmenu_dlist_delete: ClaimListController.removeDestination(destAdaptor.getItem(info.position), theClaim); destAdaptor.notifyDataSetChanged(); return true; case R.id.cmenu_dlist_edit: //show a dialog for editing destinations final EditText enterLocation = new EditText(this); final EditText enterReason = new EditText(this); enterLocation.setText(destAdaptor.getItem(info.position).getLocation()); enterReason.setText(destAdaptor.getItem(info.position).getReason()); enterLocation.setHint("Enter location"); enterReason.setHint("Enter reason"); LinearLayout linearLayout = new LinearLayout(this); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(enterLocation); linearLayout.addView(enterReason); AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setView(linearLayout);/* www . jav a 2 s .co m*/ alert.setPositiveButton("Add", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { destAdaptor.getItem(info.position).setLocation(enterLocation.getText().toString()); destAdaptor.getItem(info.position).setReason(enterReason.getText().toString()); destAdaptor.notifyDataSetChanged(); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); alert.show(); return true; case R.id.cmenu_dlist_geolocation: adaptorPos = info.position; AlertDialog.Builder alertGl = new AlertDialog.Builder(this); alertGl.setPositiveButton("GPS", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (GeoLocationController.checkGPSEnabled()) { GeoLocationController.setDestinationGeoLocationGPS(destAdaptor.getItem(info.position)); destAdaptor.notifyDataSetChanged(); } } }); alertGl.setNegativeButton("Map", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Open map view \ Intent intent = GeoLocationController.pickLocationIntent(EditClaimActivity.this); startActivityForResult(intent, GET_GEOLOCATION_CODE); } }); alertGl.show(); return true; case R.id.cmenu_delete_tag: ClaimListController.removeTag(theClaim, tagAdaptor.getItem(info.position)); tagAdaptor.notifyDataSetChanged(); return true; case R.id.cmenu_rename_tag: //create a Alert dialog for editing tag name final TextView enterTag = new AutoCompleteTextView(this); enterTag.setHint("Enter tag"); AlertDialog.Builder alertTag = new AlertDialog.Builder(this); alertTag.setView(enterTag); alertTag.setPositiveButton("Add", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { tagAdaptor.getItem(info.position).setName(enterTag.getText().toString()); tagAdaptor.notifyDataSetChanged(); } }); alertTag.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); alertTag.show(); return true; default: return super.onContextItemSelected(item); } }
From source file:br.liveo.ndrawer.ui.fragment.MainFragment31.java
public void useBeacon(int position) { final String beaconmac = mMyDeviceAdapter.getDeviceList().get(position).getBdAddr(); AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()); alertDialog.setTitle(" ?"); alertDialog.setMessage("? ? ?"); alertDialog.setIcon(R.drawable.alert); alertDialog.setPositiveButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { updateEvent("BEACON_USE"); UseBeacon useBeacon = new UseBeacon(); useBeacon.execute("http://125.131.73.198:3000/beaconUse", beaconmac); }// w ww . j ava 2 s . c o m }); // Setting Negative "NO" Button alertDialog.setNegativeButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Write your code here to invoke NO event dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); }
From source file:bikebadger.RideFragment.java
private void ShowAlertMessageNoGps() { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage("GPS seems to be disabled. Do you wish to enable it?").setCancelable(false) .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)); }/*from w w w . j av a2 s .co m*/ }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { dialog.cancel(); } }); final AlertDialog alert = builder.create(); alert.show(); }
From source file:com.google.android.apps.forscience.whistlepunk.EditNoteDialog.java
@Override public AlertDialog onCreateDialog(Bundle savedInstanceState) { mLabel = getArguments().getParcelable(KEY_SAVED_LABEL); String timeText = getArguments().getString(KEY_SAVED_TIME_TEXT, ""); String timeTextContentDescription = getArguments().getString(KEY_SAVED_TIME_TEXT_DESCRIPTION); mTimestamp = getArguments().getLong(KEY_SAVED_TIMESTAMP); try {//from w w w . j a v a 2 s .c o m mSelectedValue = GoosciLabelValue.LabelValue.parseFrom(getArguments().getByteArray(KEY_SELECTED_VALUE)); } catch (InvalidProtocolBufferNanoException ex) { Log.wtf(TAG, "Couldn't parse label value"); } AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()); LinearLayout rootView = (LinearLayout) LayoutInflater.from(getActivity()) .inflate(R.layout.run_review_label_edit, null); alertDialog.setView(rootView); ImageView imageView = (ImageView) rootView.findViewById(R.id.picture_note_preview_image); final EditText editText = (EditText) rootView.findViewById(R.id.edit_note_text); TextView autoTextView = (TextView) rootView.findViewById(R.id.auto_note_text); // Use mSelectedValue to load content, because the user may have changed the value since // it was stored in the label. Note that picture labels can't be edited at this time, // but in the future this will apply to picture labels as well. if (mLabel instanceof PictureLabel) { imageView.setVisibility(View.VISIBLE); autoTextView.setVisibility(View.GONE); editText.setText(PictureLabel.getCaption(mSelectedValue)); editText.setHint(R.string.picture_note_caption_hint); Glide.with(getActivity()).load(PictureLabel.getFilePath(mSelectedValue)).into(imageView); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PictureUtils.launchExternalViewer(getActivity(), (PictureLabel.getFilePath(mSelectedValue))); } }); } else if (mLabel instanceof TextLabel) { imageView.setVisibility(View.GONE); autoTextView.setVisibility(View.GONE); editText.setText(TextLabel.getText(mSelectedValue)); } else if (mLabel instanceof SensorTriggerLabel) { imageView.setVisibility(View.GONE); autoTextView.setVisibility(View.VISIBLE); editText.setText(SensorTriggerLabel.getCustomText(mSelectedValue)); String autoText = SensorTriggerLabel.getAutogenText(mSelectedValue); TriggerHelper.populateAutoTextViews(autoTextView, autoText, R.drawable.ic_label_black_24dp, getResources()); } alertDialog.setPositiveButton(R.string.action_save, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mLabel.setTimestamp(mTimestamp); if (mLabel instanceof TextLabel) { ((TextLabel) mLabel).setText(editText.getText().toString()); } else if (mLabel instanceof PictureLabel) { ((PictureLabel) mLabel).setCaption(editText.getText().toString()); } else if (mLabel instanceof SensorTriggerLabel) { ((SensorTriggerLabel) mLabel).setCustomText(editText.getText().toString()); } getDataController().editLabel(mLabel, ((EditNoteDialogListener) getParentFragment()).onLabelEdit(mLabel)); } }); alertDialog.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); alertDialog.setCancelable(true); TextView timeTextView = (TextView) rootView.findViewById(R.id.edit_note_time); timeTextView.setText(timeText); timeTextView.setContentDescription(timeTextContentDescription); if (labelBelongsToRun() && mLabel.canEditTimestamp()) { timeTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { GoosciLabelValue.LabelValue value = new GoosciLabelValue.LabelValue(); if (mLabel instanceof PictureLabel) { // Captions can be edited, but the picture path cannot be edited at this // time. PictureLabel.populateStorageValue(value, ((PictureLabel) mLabel).getFilePath(), editText.getText().toString()); ((EditNoteDialogListener) getParentFragment()).onEditNoteTimestampClicked(mLabel, value, mTimestamp); } else if (mLabel instanceof TextLabel) { TextLabel.populateStorageValue(value, editText.getText().toString()); ((EditNoteDialogListener) getParentFragment()).onEditNoteTimestampClicked(mLabel, value, mTimestamp); } } }); } else if (labelBelongsToRun()) { Drawable lockDrawable = getResources().getDrawable(R.drawable.ic_lock_black_18dp); DrawableCompat.setTint(lockDrawable, getResources().getColor(R.color.text_color_light_grey)); // There is already a start drawable. Use it again. Drawable[] drawables = timeTextView.getCompoundDrawablesRelative(); timeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(drawables[0], null, lockDrawable, null); } AlertDialog dialog = alertDialog.create(); if (mLabel instanceof TextLabel || mLabel instanceof SensorTriggerLabel) { dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); } return dialog; }
From source file:com.coinprism.wallet.fragment.SendTab.java
private void onConfirm(final Transaction result, final BigDecimal decimalAmount, final AssetDefinition selectedAsset, final String to) { final AlertDialog.Builder alertDialog = new AlertDialog.Builder(this.getActivity()); // Setting Dialog Title alertDialog.setTitle(getString(R.string.tab_send_dialog_confirm_transaction)); final String assetName; if (selectedAsset == null) assetName = getString(R.string.tab_send_dialog_confirm_message_amount_bitcoin); else {// www .j a v a 2s. c o m if (selectedAsset.getName() != null && selectedAsset.getTicker() != null) { assetName = String.format(getString(R.string.tab_send_dialog_confirm_message_amount_known_asset), selectedAsset.getTicker(), selectedAsset.getName()); } else { assetName = String.format(getString(R.string.tab_send_dialog_confirm_message_amount_unknown_asset), selectedAsset.getAssetId()); } } final String message = String.format(getString(R.string.tab_send_dialog_confirm_message), Formatting.formatNumber(decimalAmount), assetName, to); final View dialogView = getActivity().getLayoutInflater().inflate(R.layout.dialog_confirm_send, null); if (!WalletState.getState().getConfiguration().isPasswordEnabled()) dialogView.findViewById(R.id.passwordContainer).setVisibility(View.GONE); final TextView messageText = (TextView) dialogView.findViewById(R.id.sendSummary); messageText.setText(message); alertDialog.setView(dialogView); alertDialog.setPositiveButton(getString(R.string.tab_send_dialog_confirm_button), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { final EditText walletPasswordText = (EditText) dialogView.findViewById(R.id.walletPassword); final String password = walletPasswordText.getText().toString(); if (!WalletState.getState().getConfiguration().isPasswordEnabled() || WalletState.getState().getConfiguration().comparePassword(password)) onConfirmed(result); else showError(getString(R.string.tab_send_dialog_confirm_password_incorrect)); } }); alertDialog.setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); alertDialog.show(); }
From source file:com.fa.mastodon.activity.MainActivity.java
private void setupDrawer() { headerResult = new AccountHeaderBuilder().withActivity(this).withSelectionListEnabledForSingleProfile(false) .withDividerBelowHeader(false) .withOnAccountHeaderProfileImageListener(new AccountHeader.OnAccountHeaderProfileImageListener() { @Override/*from w w w . j a va 2s .co m*/ public boolean onProfileImageClick(View view, IProfile profile, boolean current) { if (current && loggedInAccountId != null) { Intent intent = new Intent(MainActivity.this, AccountActivity.class); intent.putExtra("id", loggedInAccountId); startActivity(intent); return true; } return false; } @Override public boolean onProfileImageLongClick(View view, IProfile profile, boolean current) { return false; } }).withCompactStyle(true).build(); headerResult.getView().findViewById(R.id.material_drawer_account_header_current) .setContentDescription(getString(R.string.action_view_profile)); DrawerImageLoader.init(new AbstractDrawerImageLoader() { @Override public void set(ImageView imageView, Uri uri, Drawable placeholder) { Picasso.with(imageView.getContext()).load(uri).placeholder(placeholder).into(imageView); } @Override public void cancel(ImageView imageView) { Picasso.with(imageView.getContext()).cancelRequest(imageView); } }); VectorDrawableCompat muteDrawable = VectorDrawableCompat.create(getResources(), R.drawable.ic_mute_24dp, getTheme()); ThemeUtils.setDrawableTint(this, muteDrawable, R.attr.toolbar_icon_tint); drawer = new DrawerBuilder().withActivity(this) //.withToolbar(toolbar) .withAccountHeader(headerResult).withTranslucentStatusBar(false).withHasStableIds(true) .withSelectedItem(-1) .addDrawerItems( new PrimaryDrawerItem().withIdentifier(8).withName(getString(R.string.discover)) .withIcon(GoogleMaterial.Icon.gmd_explore), new PrimaryDrawerItem().withIdentifier(0).withName(getString(R.string.action_edit_profile)) .withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_face), new PrimaryDrawerItem().withIdentifier(1) .withName(getString(R.string.action_view_favourites)).withSelectable(false) .withIcon(GoogleMaterial.Icon.gmd_star), new PrimaryDrawerItem().withIdentifier(2).withName(getString(R.string.action_view_mutes)) .withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_volume_mute), new PrimaryDrawerItem().withIdentifier(3).withName(getString(R.string.action_view_blocks)) .withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_block), new DividerDrawerItem(), new PrimaryDrawerItem().withIdentifier(4) .withName(getString(R.string.action_view_preferences)).withSelectable(false) .withIcon(GoogleMaterial.Icon.gmd_settings), new PrimaryDrawerItem().withIdentifier(6).withName(getString(R.string.action_logout)) .withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_power_settings_new)) .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { if (drawerItem != null) { long drawerItemIdentifier = drawerItem.getIdentifier(); if (drawerItemIdentifier == 0) { Intent intent = new Intent(MainActivity.this, EditProfileActivity.class); startActivity(intent); } else if (drawerItemIdentifier == 1) { Intent intent = new Intent(MainActivity.this, FavoritesActivity.class); startActivity(intent); } else if (drawerItemIdentifier == 2) { Intent intent = new Intent(MainActivity.this, AccountListActivity.class); intent.putExtra("type", AccountListActivity.Type.MUTES); startActivity(intent); } else if (drawerItemIdentifier == 3) { Intent intent = new Intent(MainActivity.this, AccountListActivity.class); intent.putExtra("type", AccountListActivity.Type.BLOCKS); startActivity(intent); } else if (drawerItemIdentifier == 4) { Intent intent = new Intent(MainActivity.this, PreferencesActivity.class); startActivity(intent); } else if (drawerItemIdentifier == 5) { Intent intent = new Intent(MainActivity.this, AboutActivity.class); startActivity(intent); } else if (drawerItemIdentifier == 6) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle(R.string.areyousure); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { logout(); } }); builder.setNegativeButton(R.string.abort, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); builder.show(); logout(); } else if (drawerItemIdentifier == 7) { Intent intent = new Intent(MainActivity.this, AccountListActivity.class); intent.putExtra("type", AccountListActivity.Type.FOLLOW_REQUESTS); startActivity(intent); } else if (drawerItemIdentifier == 8) { drawer.closeDrawer(); } } return false; } }).build(); drawer.setSelection(8); }
From source file:com.iride.ayride.HomePageActivity.java
private void exitFromTheApp() { String exitMessage = "Do you want to exit?"; AlertDialog.Builder builder = new AlertDialog.Builder(HomePageActivity.this); builder.setMessage(exitMessage);// ww w . j a v a2s .com builder.setCancelable(true); builder.setNegativeButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); builder.setPositiveButton("Logout", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { rideLocalStorage.clearStorage(); vehicleLocalStorage.clearStorage(); userLocalStorage.clearStorage(); if (isFacebookUser()) { LoginManager.getInstance().logOut(); } startActivity(new Intent(HomePageActivity.this, EntranceActivity.class)); finish(); } }); AlertDialog alert11 = builder.create(); alert11.show(); }
From source file:ca.xecure.easychip.MainActivity.java
private void show_payment_confirmation() { AlertDialog.Builder builder = new AlertDialog.Builder(this); double money = ((double) amount) / 100; int slashslash = callback_url.indexOf("//") + 2; String domain = callback_url.substring(slashslash, callback_url.indexOf('/', slashslash)); builder.setTitle("Payment Confirmation") .setMessage("Are you sure to pay " + String.format("($%.2f) ", money) + "to " + domain + "?") .setCancelable(false).setPositiveButton("Yeah, I want to", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { String value_message; try { value_message = createValueMessage(amount, payee_id, annotation); } catch (Exception ex) { Log.e(LOG_TAG, ex.getMessage()); return; }//from w w w. j av a 2s . c o m HashMap<String, String> post_data = new HashMap<String, String>(); post_data.put("channel_id", channel_id); post_data.put("value_message", value_message); try { http_post(callback_url, post_data); } catch (IOException ex) { Log.e(LOG_TAG, ex.getMessage()); } } }).setNegativeButton("No, I don't", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:com.github.wakhub.monodict.activity.FlashcardActivity.java
@UiThread void showAutoPlayAlertDialog() { if (autoPlayDialog != null) { return;//w ww . jav a 2 s . c om } LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); layout.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); layout.setPadding(20, 20, 20, 20); autoPlayDisplayText = new TextView(this); autoPlayDisplayText.setTypeface(Typeface.DEFAULT_BOLD); layout.addView(autoPlayDisplayText); autoPlayTranslateText = new TextView(this); autoPlayTranslateText.setText(R.string.message_in_processing); layout.addView(autoPlayTranslateText); autoPlayDialog = new AlertDialog.Builder(this).setTitle(R.string.action_auto_play) .setIcon(R.drawable.ic_action_play).setView(layout) .setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { autoPlayDisplayText = null; autoPlayTranslateText = null; stopAutoPlay(); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.cancel(); } }).show(); }
From source file:com.freeme.filemanager.FileExplorerTabActivity.java
private void hotKnotInit(Activity activity) { Log.d(TAG, "hotKnotInit"); mHotContext = activity;//from ww w . j a va 2s . c o m mHotKnotAdapter = HotKnotAdapter.getDefaultAdapter(mHotContext); if (mHotKnotAdapter == null) { mHotKnotEnable = false; Log.d(TAG, "hotKnotInit, mHotKnotAdapter is null, disable hotKnot feature"); return; } mHotKnotEnable = true; mHotKnotAdapter.setOnHotKnotCompleteCallback(new HotKnotAdapter.OnHotKnotCompleteCallback() { public void onHotKnotComplete(int reason) { Log.d(TAG, "onHotKnotComplete reason:" + reason); mHotKnotAdapter.setHotKnotBeamUris(null, mHotContext); if (mHotKnotListener != null) { setHotknotCompleteListener(null); mHotKnotListener.onHotKnotSendComplete(); } } }, mHotContext); OnClickListener onClick = new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (DialogInterface.BUTTON_POSITIVE == which) { Log.d(TAG, "hotKnot start setting"); Intent intent = new Intent("mediatek.settings.HOTKNOT_SETTINGS"); startActivity(intent); dialog.cancel(); } else { Log.d(TAG, "onClick cancel dialog"); dialog.cancel(); } } }; mHotKnotDialog = new AlertDialog.Builder(mHotContext).setMessage(R.string.turn_on_hotknot) .setNegativeButton(android.R.string.cancel, onClick).setPositiveButton(android.R.string.ok, onClick) .create(); }