List of usage examples for android.app AlertDialog.Builder setCancelable
public void setCancelable(boolean flag)
From source file:net.sourceforge.kalimbaradio.androidapp.activity.DownloadActivity.java
@Override protected Dialog onCreateDialog(int id) { if (id == DIALOG_SAVE_PLAYLIST) { AlertDialog.Builder builder; LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); final View layout = inflater.inflate(R.layout.save_playlist, (ViewGroup) findViewById(R.id.save_playlist_root)); playlistNameView = (EditText) layout.findViewById(R.id.save_playlist_name); builder = new AlertDialog.Builder(this); builder.setTitle(R.string.download_playlist_title); builder.setMessage(R.string.download_playlist_name); builder.setPositiveButton(R.string.common_save, new DialogInterface.OnClickListener() { @Override//from ww w .ja v a 2 s . c o m public void onClick(DialogInterface dialog, int id) { savePlaylistInBackground(String.valueOf(playlistNameView.getText())); } }); builder.setNegativeButton(R.string.common_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); builder.setView(layout); builder.setCancelable(true); return builder.create(); } else { return super.onCreateDialog(id); } }
From source file:com.xrmaddness.offthegrid.ListActivity.java
void remove(final contact c) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(R.string.action_remove); alert.setMessage(getString(R.string.dialog_remove) + ": " + c.name_get()); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String address = c.address_get(); if (c.id_get() == 1) { warn_remove_self();//w w w . j a va 2 s. c o m return; } Log.d("remove", "remove contact"); if (c.type_get() == contact.TYPE_PERSON) { List<contact> contacts = db.contact_get_by_address(address); for (int i = 0; i < contacts.size(); i++) db.contact_remove(contacts.get(i)); if (!address.equals(pgp.my_user_id)) pgp.public_keyring_remove_by_address(address); } else { db.contact_remove(c); } view_contacts(); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }); alert.setCancelable(true); alert.show(); }
From source file:com.csipsimple.ui.favorites.FavAdapter.java
private void showDialogForGroupSelection(final Context context, final Long profileId, final String groupName) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.set_android_group); final Cursor choiceCursor = ContactsWrapper.getInstance().getGroups(context); int selectedIndex = -1; if (choiceCursor != null) { if (choiceCursor.moveToFirst()) { int i = 0; int colIdx = choiceCursor.getColumnIndex(ContactsWrapper.FIELD_GROUP_NAME); do {/*from www. j a va 2s . c om*/ String name = choiceCursor.getString(colIdx); if (!TextUtils.isEmpty(name) && name.equalsIgnoreCase(groupName)) { selectedIndex = i; break; } i++; } while (choiceCursor.moveToNext()); } } builder.setSingleChoiceItems(choiceCursor, selectedIndex, ContactsWrapper.FIELD_GROUP_NAME, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (choiceCursor != null) { choiceCursor.moveToPosition(which); String name = choiceCursor .getString(choiceCursor.getColumnIndex(ContactsWrapper.FIELD_GROUP_NAME)); ContentValues cv = new ContentValues(); cv.put(SipProfile.FIELD_ANDROID_GROUP, name); context.getContentResolver().update( ContentUris.withAppendedId(SipProfile.ACCOUNT_ID_URI_BASE, profileId), cv, null, null); choiceCursor.close(); } dialog.dismiss(); } }); builder.setCancelable(true); builder.setNeutralButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (choiceCursor != null) { choiceCursor.close(); } dialog.dismiss(); } }); builder.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (choiceCursor != null) { choiceCursor.close(); } } }); final Dialog dialog = builder.create(); dialog.show(); }
From source file:cgeo.geocaching.CacheListActivity.java
private void showLicenseConfirmationDialog() { final AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.setTitle(res.getString(R.string.license)); dialog.setMessage(res.getString(R.string.err_license)); dialog.setCancelable(true); dialog.setNegativeButton(res.getString(R.string.license_dismiss), new DialogInterface.OnClickListener() { @Override/*from www . ja v a 2s. c om*/ public void onClick(final DialogInterface dialog, final int id) { Cookies.clearCookies(); dialog.cancel(); } }); dialog.setPositiveButton(res.getString(R.string.license_show), new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int id) { Cookies.clearCookies(); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.geocaching.com/software/agreement.aspx?ID=0"))); } }); final AlertDialog alert = dialog.create(); alert.show(); }
From source file:it.unipr.ce.dsg.gamidroid.activities.NAM4JAndroidActivity.java
private void showAddress(final String addressTouch) { Log.d(NAM4JAndroidActivity.TAG, "Tapped address: " + addressTouch); AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.setMessage("Do you want to see information about building located in " + addressTouch + " ?"); dialog.setCancelable(true); dialog.setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss();//w ww . java 2 s . c o m Intent intent = new Intent(NAM4JAndroidActivity.this, BuildingLookupActivity.class); intent.putExtra("AddressBuilding", addressTouch); NAM4JAndroidActivity.this.startActivity(intent); } }); dialog.setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); dialog.show(); }
From source file:com.instiwork.RegistrationFacebookActivity.java
public void getTermsUse(final String URL) { Logger.showMessage(TAG, "Privacy " + URL); JsonObjectRequest jsonReq = new JsonObjectRequest(Request.Method.GET, URL, null, new Response.Listener<JSONObject>() { @Override/* w w w . j a v a 2 s. c o m*/ public void onResponse(JSONObject response) { pBarTermsUse.setVisibility(View.GONE); webViewTermsUse.setVisibility(View.VISIBLE); try { if (response.getString("status").equalsIgnoreCase("Success")) { // txtTermsUse.setText(Html.fromHtml(response.getString("Terms"))); webViewTermsUse.loadDataWithBaseURL(URL, response.getString("Terms"), "text/html", "UTF-8", null); } } catch (Exception e) { e.printStackTrace(); // txtTermsUse.setText(""); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError volleyError) { pBarTermsUse.setVisibility(View.GONE); if (volleyError instanceof NoConnectionError) { android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder( RegistrationFacebookActivity.this); builder.setTitle("Instiwork"); builder.setMessage("You do not have internet connection!"); builder.setPositiveButton("retry", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); pBarTermsUse.setVisibility(View.VISIBLE); webViewTermsUse.setVisibility(View.GONE); getTermsUse(URL); } }); builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); builder.setCancelable(false); builder.show(); } } }); jsonReq.setRetryPolicy(new DefaultRetryPolicy(10000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); InstiworkApplication.getInstance().addToRequestQueue(jsonReq); }
From source file:com.instiwork.RegistrationFacebookActivity.java
public void getCountryList() { final String URL = InstiworkConstants.URL_DOMAIN + "Councurr_control"; JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET, URL, null, new Response.Listener<JSONObject>() { @Override//from w w w. j a va 2 s . com public void onResponse(JSONObject response) { Logger.showMessage(TAG, URL); Logger.showMessage(TAG, response.toString()); countryPbar.setVisibility(View.GONE); objectsCountry = new LinkedList<JSONObject>(); try { JSONObject makeJSONObject = new JSONObject(); makeJSONObject.put("country_id", "0"); makeJSONObject.put("country_name", "Select Country From List"); makeJSONObject.put("country_2_code", "0"); makeJSONObject.put("currency_name", ""); makeJSONObject.put("currency_code", ""); objectsCountry.add(makeJSONObject); } catch (Exception e) { e.printStackTrace(); } country_spinner.setVisibility(View.VISIBLE); try { JSONArray jsonArray = response.getJSONArray("response"); for (int i = 0; i < jsonArray.length(); i++) { objectsCountry.add(jsonArray.getJSONObject(i)); } country_spinner.setAdapter( new CountrySpinnerAdapter(RegistrationFacebookActivity.this, objectsCountry)); try { for (int s = 0; s < objectsCountry.size(); s++) { if (objectsCountry.get(s).getString("country_name") .equalsIgnoreCase(currentCountry)) { Logger.showMessage(TAG, "MyCheck: " + "IF"); country_spinner.setSelection(s); break; } else { Logger.showMessage(TAG, "MyCheck: " + "ELSE"); country_spinner.setSelection(0); } } } catch (Exception e) { // e.printStackTrace(); country_spinner.setSelection(0); } } catch (Exception e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Logger.showMessage(TAG, "Error: " + error.getMessage()); countryPbar.setVisibility(View.GONE); if (error instanceof NoConnectionError) { android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder( RegistrationFacebookActivity.this); builder.setTitle("Instiwork"); builder.setMessage("You do not have internet connection!"); builder.setPositiveButton("retry", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); countryPbar.setVisibility(View.VISIBLE); country_spinner.setVisibility(View.GONE); getCountryList(); } }); builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); builder.setCancelable(false); builder.show(); } else { try { String json = null; NetworkResponse response = error.networkResponse; if (response != null && response.data != null) { json = new String(response.data); json = trimMessage(json, "message"); if (json != null) // displayMessage(json); displayMessage(json + " Error Code : " + response.statusCode); } } catch (Exception e) { e.printStackTrace(); } } } }); jsonObjReq.setRetryPolicy(new DefaultRetryPolicy(30000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); InstiworkApplication.getInstance().addToRequestQueue(jsonObjReq); }
From source file:jmri.enginedriver.threaded_application.java
public void checkExit(final Activity activity) { final AlertDialog.Builder b = new AlertDialog.Builder(activity); b.setIcon(android.R.drawable.ic_dialog_alert); b.setTitle(R.string.exit_title);/* www.java2 s . com*/ b.setMessage(R.string.exit_text); b.setCancelable(true); b.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { firstCreate = true; sendMsg(comm_msg_handler, message_type.DISCONNECT, ""); //trigger disconnect / shutdown sequence } }); b.setNegativeButton(R.string.no, null); AlertDialog alert = b.create(); alert.show(); }
From source file:com.example.android.bluepayandroidsdk.MainActivity.java
public void openReaderSelectDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Select a reader:"); builder.setCancelable(false); builder.setItems(R.array.reader_type, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: readerType = 0;/*from ww w .j a va2s . c om*/ initializeReader(uniMagReader.ReaderType.UM_OR_PRO); Toast.makeText(getApplicationContext(), "UniMag / UniMag Pro selected", Toast.LENGTH_SHORT) .show(); break; case 1: readerType = 1; initializeReader(uniMagReader.ReaderType.SHUTTLE); Toast.makeText(getApplicationContext(), "UniMag II / Shuttle selected", Toast.LENGTH_SHORT) .show(); break; default: readerType = 1; initializeReader(uniMagReader.ReaderType.SHUTTLE); Toast.makeText(getApplicationContext(), "UniMag II / Shuttle selected", Toast.LENGTH_SHORT) .show(); break; } showAboutInfo(); } }); builder.create().show(); }
From source file:com.free.searcher.MainFragment.java
@Override public boolean onQueryTextSubmit(String query) { currentSearching = query;// ww w .j a v a 2 s. c o m findBox.setText(currentSearching); statusView.setText("Query = '" + query + "' : submitted"); webView.requestFocus(); try { // cha load source files if (query.trim().length() == 0) { status = "Nothing to search. Please type something for searching"; showToast(status.toString()); statusView.setText(status); return true; } Log.d("selectedFiles", selectedFiles + ""); if (selectedFiles == null || selectedFiles.length == 0 || selectedFiles[0].length() == 0) { // (cache == // null && // (!new // File(folderStr).exists())) status = "No file to search. Please select files or folders for searching"; showToast(status.toString()); statusView.setText(status); Log.d("search", "No file to search"); return true; } if (getSourceFileTask == null) { // Zip Reader or Restart app if (currentZipFileName.length() > 0) { // Zip reader AlertDialog.Builder alert = new AlertDialog.Builder(activity); alert.setTitle("Searching files"); alert.setMessage("Do you want to search this file " + currentZipFileName + "?"); alert.setCancelable(true); alert.setNegativeButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showToast("Start loading files, please wait..."); requestSearching = true; getSourceFileTask = new GetSourceFileTask(MainFragment.this); getSourceFileTask.execute(); } }); alert.setPositiveButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog alertDialog = alert.create(); alertDialog.show(); } else { // SEARCH Dup Comp showToast("Start loading files, please wait..."); requestSearching = true; getSourceFileTask = new GetSourceFileTask(MainFragment.this); getSourceFileTask.execute(); } } else if (getSourceFileTask.getStatus() == Status.RUNNING || getSourceFileTask.getStatus() == Status.PENDING) { showToast("Still loading files, please wait..."); requestSearching = true; } else if (searchTask == null || searchTask.getStatus() == Status.FINISHED) { // load ri nhng cha chy g searchView(query); } else if (searchTask.getStatus() == Status.RUNNING || searchTask.getStatus() == Status.PENDING) { // load source file nhng ang chy ci khc showToast("Stopping previous seaching, please wait..."); searchTask.cancel(true); searchTask = null; searchView(query); } } catch (Throwable e) { Log.d("onQueryTextSubmit()", e.getMessage(), e); statusView.setText(e.getMessage()); } return true; }