List of usage examples for android.app AlertDialog setCancelable
public void setCancelable(boolean flag)
From source file:org.odk.collect.android.activities.InstanceChooserList.java
private void createErrorDialog(String errorMsg, final boolean shouldExit) { AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setIcon(android.R.drawable.ic_dialog_info); alertDialog.setMessage(errorMsg);//from ww w . jav a 2s. c o m DialogInterface.OnClickListener errorListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int i) { switch (i) { case DialogInterface.BUTTON_POSITIVE: if (shouldExit) { finish(); } break; } } }; alertDialog.setCancelable(false); alertDialog.setButton(getString(R.string.ok), errorListener); alertDialog.show(); }
From source file:cm.aptoide.pt.ScheduledDownloads.java
private void continueLoading() { lv = (ListView) findViewById(android.R.id.list); db = Database.getInstance();//from w w w .j av a 2 s. c o m adapter = new CursorAdapter(this, null, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER) { @Override public View newView(Context context, Cursor arg1, ViewGroup arg2) { return LayoutInflater.from(context).inflate(R.layout.row_sch_download, null); } @Override public void bindView(View convertView, Context arg1, Cursor c) { // Planet to display ScheduledDownload scheduledDownload = scheduledDownloadsHashMap.get(c.getString(0)); // The child views in each row. CheckBox checkBoxScheduled; TextView textViewName; TextView textViewVersion; ImageView imageViewIcon; // Create a new row view if (convertView.getTag() == null) { // Find the child views. textViewName = (TextView) convertView.findViewById(R.id.name); textViewVersion = (TextView) convertView.findViewById(R.id.appversion); checkBoxScheduled = (CheckBox) convertView.findViewById(R.id.schDwnChkBox); imageViewIcon = (ImageView) convertView.findViewById(R.id.appicon); // Optimization: Tag the row with it's child views, so we don't have to // call findViewById() later when we reuse the row. convertView.setTag(new Holder(textViewName, textViewVersion, checkBoxScheduled, imageViewIcon)); // If CheckBox is toggled, update the planet it is tagged with. checkBoxScheduled.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { CheckBox cb = (CheckBox) v; ScheduledDownload schDownload = (ScheduledDownload) cb.getTag(); schDownload.setChecked(cb.isChecked()); } }); } // Reuse existing row view else { // Because we use a ViewHolder, we avoid having to call findViewById(). Holder viewHolder = (Holder) convertView.getTag(); checkBoxScheduled = viewHolder.checkBoxScheduled; textViewVersion = viewHolder.textViewVersion; textViewName = viewHolder.textViewName; imageViewIcon = viewHolder.imageViewIcon; } // Tag the CheckBox with the Planet it is displaying, so that we can // access the planet in onClick() when the CheckBox is toggled. checkBoxScheduled.setTag(scheduledDownload); // Display planet data checkBoxScheduled.setChecked(scheduledDownload.isChecked()); textViewName.setText(scheduledDownload.getName()); textViewVersion.setText(scheduledDownload.getVername()); // Tag the CheckBox with the Planet it is displaying, so that we can // access the planet in onClick() when the CheckBox is toggled. checkBoxScheduled.setTag(scheduledDownload); // Display planet data checkBoxScheduled.setChecked(scheduledDownload.isChecked()); textViewName.setText(scheduledDownload.getName()); textViewVersion.setText("" + scheduledDownload.getVername()); ImageLoader.getInstance().displayImage(scheduledDownload.getIconPath(), imageViewIcon); } }; lv.setAdapter(adapter); getSupportLoaderManager().initLoader(0, null, this); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View item, int arg2, long arg3) { ScheduledDownload scheduledDownload = (ScheduledDownload) ((Holder) item.getTag()).checkBoxScheduled .getTag(); scheduledDownload.toggleChecked(); Holder viewHolder = (Holder) item.getTag(); viewHolder.checkBoxScheduled.setChecked(scheduledDownload.isChecked()); } }); IntentFilter filter = new IntentFilter("pt.caixamagica.aptoide.REDRAW"); registerReceiver(receiver, filter); Button installButton = (Button) findViewById(R.id.sch_down); // installButton.setText(getText(R.string.schDown_installselected)); installButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (isAllChecked()) { for (String scheduledDownload : scheduledDownloadsHashMap.keySet()) { if (scheduledDownloadsHashMap.get(scheduledDownload).checked) { ScheduledDownload schDown = scheduledDownloadsHashMap.get(scheduledDownload); ViewApk apk = new ViewApk(); apk.setApkid(schDown.getApkid()); apk.setName(schDown.getName()); apk.setVercode(schDown.getVercode()); apk.setIconPath(schDown.getIconPath()); apk.setVername(schDown.getVername()); apk.setRepoName(schDown.getRepoName()); serviceDownloadManager .startDownloadWithWebservice(serviceDownloadManager.getDownload(apk), apk); Toast toast = Toast.makeText(ScheduledDownloads.this, R.string.starting_download, Toast.LENGTH_SHORT); toast.show(); } } } else { Toast toast = Toast.makeText(ScheduledDownloads.this, R.string.schDown_nodownloadselect, Toast.LENGTH_SHORT); toast.show(); } } }); if (getIntent().hasExtra("downloadAll")) { Builder dialogBuilder = new AlertDialog.Builder(this); final AlertDialog scheduleDownloadDialog = dialogBuilder.create(); scheduleDownloadDialog.setTitle(getText(R.string.schDwnBtn)); scheduleDownloadDialog.setIcon(android.R.drawable.ic_dialog_alert); scheduleDownloadDialog.setCancelable(false); scheduleDownloadDialog.setMessage(getText(R.string.schDown_install)); scheduleDownloadDialog.setButton(Dialog.BUTTON_POSITIVE, getString(android.R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { for (String scheduledDownload : scheduledDownloadsHashMap.keySet()) { ScheduledDownload schDown = scheduledDownloadsHashMap.get(scheduledDownload); ViewApk apk = new ViewApk(); apk.setApkid(schDown.getApkid()); apk.setName(schDown.getName()); apk.setVercode(schDown.getVercode()); apk.setIconPath(schDown.getIconPath()); apk.setVername(schDown.getVername()); apk.setRepoName(schDown.getRepoName()); serviceDownloadManager .startDownloadWithWebservice(serviceDownloadManager.getDownload(apk), apk); Toast toast = Toast.makeText(ScheduledDownloads.this, R.string.starting_download, Toast.LENGTH_SHORT); toast.show(); } finish(); } }); scheduleDownloadDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.no), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { finish(); } }); scheduleDownloadDialog.show(); } }
From source file:bikebadger.RideFragment.java
public void onInit(int initStatus) { // assert (false); //check for successful instantiation if (initStatus == TextToSpeech.SUCCESS) { //if(RideManager.mTTS.isLanguageAvailable(Locale.US)==TextToSpeech.LANG_AVAILABLE) // RideManager.mTTS.setLanguage(Locale.US); } else if (initStatus == TextToSpeech.ERROR) { Toast.makeText(mRideManager.mAppContext, "Sorry! Text To Speech failed...", Toast.LENGTH_LONG).show(); AlertDialog ad = new AlertDialog.Builder(getActivity()).create(); ad.setCancelable(false); ad.setTitle("Text To Speech Engine Not Found"); ad.setMessage(/*w w w . j a v a 2 s .c o m*/ "There was a problem finding the Text To Speech Engine. Make sure it's install properly under Language and Input Settings."); ad.setButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); ad.show(); } }
From source file:bikebadger.RideFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(Constants.APP.TAG, "RideFragment.onCreate()"); //setRetainInstance(true); mRideManager = RideManager.get(getActivity()); Log.d(Constants.APP.TAG, "mRideManager set = RideManager.get(" + getActivity() + ")"); setHasOptionsMenu(true);//from w w w . j av a2 s .c o m // check for a Ride ID as an argument, and find the run Bundle args = getArguments(); if (args != null) { long runId = args.getLong(ARG_RUN_ID, -1); Log.d(Constants.APP.TAG, "RideFragment.onCreate() runId=" + runId); if (runId != -1) { LoaderManager lm = getLoaderManager(); lm.initLoader(LOAD_RUN, args, new RunLoaderCallbacks()); lm.initLoader(LOAD_LOCATION, args, new LocationLoaderCallbacks()); } } // Initialize the TextToSpeech Engine... // TODO this engine may not exist. Provide the ability to run without it. Intent checkTTSIntent = new Intent(); checkTTSIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA); if (checkTTSIntent.resolveActivity(mRideManager.mAppContext.getPackageManager()) != null) { startActivityForResult(checkTTSIntent, MY_DATA_CHECK_CODE_REQUEST); } else { Log.d(Constants.APP.TAG, "Could not find TTS Intent"); MyToast.Show(getActivity(), "Could not find Text To Speech Service", Color.RED); AlertDialog ad1 = new AlertDialog.Builder(getActivity()).create(); ad1.setCancelable(false); ad1.setTitle("Text To Speech Engine Not Found"); ad1.setMessage( "There was a problem finding the Text To Speech Engine. Make sure it's install properly under Language and Input Settings."); ad1.setButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); ad1.show(); } if (mRideManager.mLoadLastGPXFile) { Log.d(Constants.APP.TAG, "mLoadLastGPXFile=" + mRideManager.mLoadLastGPXFile); Log.d(Constants.APP.TAG, "mCurrentGPXPath=" + mRideManager.mCurrentGPXPath); OpenGPXFileOnNewThreadWithDialog(mRideManager.mCurrentGPXPath); } if (!mRideManager.IsGPSEnabled()) { ShowAlertMessageNoGps(); } // keep the screen on so it doesn't time out and turn dark getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); }
From source file:bikebadger.RideFragment.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case MY_DATA_CHECK_CODE_REQUEST: // for testing //resultCode = TextToSpeech.Engine.CHECK_VOICE_DATA_FAIL; switch (resultCode) { case TextToSpeech.Engine.CHECK_VOICE_DATA_PASS: RideManager.mTTS = new TextToSpeech(mRideManager.mAppContext, this); //RideManager.mTTS = null; Log.v(Constants.APP.TAG, "TextToSpeech installed"); break; case TextToSpeech.Engine.CHECK_VOICE_DATA_BAD_DATA: case TextToSpeech.Engine.CHECK_VOICE_DATA_MISSING_DATA: case TextToSpeech.Engine.CHECK_VOICE_DATA_MISSING_VOLUME: case TextToSpeech.Engine.CHECK_VOICE_DATA_FAIL: Log.e(Constants.APP.TAG, "Got a failure. Text To Speech not available"); AlertDialog ad = new AlertDialog.Builder(getActivity()).create(); ad.setCancelable(false); ad.setTitle("Text To Speech Engine Not Found"); ad.setMessage(//from w ww . jav a2 s .co m "There was a problem finding the Text To Speech Engine. Make sure it's install properly under Language and Input Settings."); ad.setButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); ad.show(); // missing data, install it //Log.v(Constants.APP.TAG, "Need language stuff: " + resultCode); //Intent installIntent = new Intent(); //installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA); //startActivity(installIntent); break; } break; /* No longer used as it is deprecated. Use SimpleFileDialog instead even though it blocks. TODO - integrate a slick open file that includes DropBox and Drive library! case Constants.APP.FILE_CHOOSER_REQUEST_CODE: if (resultCode == getActivity().RESULT_OK) { if (data != null) { // Get the URI of the selected file final Uri uri = data.getData(); Log.i(Constants.APP.TAG, "Uri = " + uri.toString()); try { // Get the file path from the URI final String path = FileUtils.getPath(mRideManager.mAppContext, uri); //Toast.makeText(getActivity(), "File Selected: " + path, Toast.LENGTH_LONG).show(); OpenGPXFileOnNewThreadWithDialog(path); // if(isVisible()) // updateUI(); // update title bar file loaded } catch (Exception e) { Log.e("FileSelectorTestActivity", "File select error", e); } } } break; */ case Constants.APP.ACTION_WAYPOINT_REQUEST_CODE: if (resultCode == getActivity().RESULT_OK) { if (data != null) { final Location location = data.getParcelableExtra("location"); String command = data.getStringExtra("command"); final String arg = data.getStringExtra("argument"); mRideManager.AddNewWaypoint(command, arg, location); // enable the save menu mMenu.findItem(R.id.menu_item_gpx_save).setEnabled(true); } } break; case MY_MAP_CODE_REQUEST: if (resultCode == getActivity().RESULT_OK) { Log.d(Constants.APP.TAG, "Return from map"); } break; } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.ushahidi.android.app.ui.phone.AddCheckinActivity.java
/** * Create various dialog/*www . j a v a2 s .c om*/ */ @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ERROR_NETWORK: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.network_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_ERROR_SAVING: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.file_system_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_CHOOSE_IMAGE_METHOD: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.choose_method)); dialog.setMessage(getString(R.string.how_to_select_pic)); dialog.setButton(getString(R.string.gallery_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, REQUEST_CODE_IMAGE); dialog.dismiss(); } }); dialog.setButton2(getString(R.string.cancel), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton3(getString(R.string.camera_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, PhotoUtils.getPhotoUri(photoName, AddCheckinActivity.this)); startActivityForResult(intent, REQUEST_CODE_CAMERA); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_SHOW_MESSAGE: AlertDialog.Builder messageBuilder = new AlertDialog.Builder(this); messageBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showDialog = messageBuilder.create(); showDialog.show(); break; case DIALOG_SHOW_REQUIRED: AlertDialog.Builder requiredBuilder = new AlertDialog.Builder(this); requiredBuilder.setTitle(R.string.required_fields); requiredBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showRequiredDialog = requiredBuilder.create(); showRequiredDialog.show(); break; // prompt for unsaved changes case DIALOG_SHOW_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.unsaved_changes)); dialog.setMessage(getString(R.string.want_to_cancel)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } // prompt for report deletion case DIALOG_SHOW_DELETE_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.delete_report)); dialog.setMessage(getString(R.string.want_to_delete)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete checkin deleteCheckins(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } } return null; }
From source file:foam.littlej.android.app.ui.phone.AddCheckinActivity.java
/** * Create various dialog/*from w w w .ja v a2s . c o m*/ */ @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ERROR_NETWORK: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.network_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_ERROR_SAVING: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.file_system_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_CHOOSE_IMAGE_METHOD: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.choose_method)); dialog.setMessage(getString(R.string.how_to_select_pic)); dialog.setButton(getString(R.string.gallery_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { deleteExistingPhoto(); Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, REQUEST_CODE_IMAGE); dialog.dismiss(); } }); dialog.setButton2(getString(R.string.cancel), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton3(getString(R.string.camera_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { deleteExistingPhoto(); Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, PhotoUtils.getPhotoUri(photoName, AddCheckinActivity.this)); startActivityForResult(intent, REQUEST_CODE_CAMERA); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_SHOW_MESSAGE: AlertDialog.Builder messageBuilder = new AlertDialog.Builder(this); messageBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showDialog = messageBuilder.create(); showDialog.show(); break; case DIALOG_SHOW_REQUIRED: AlertDialog.Builder requiredBuilder = new AlertDialog.Builder(this); requiredBuilder.setTitle(R.string.required_fields); requiredBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showRequiredDialog = requiredBuilder.create(); showRequiredDialog.show(); break; // prompt for unsaved changes case DIALOG_SHOW_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.unsaved_changes)); dialog.setMessage(getString(R.string.want_to_cancel)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete any existing photo in the pending folder new DiscardTask(AddCheckinActivity.this).execute((String) null); finish(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } // prompt for report deletion case DIALOG_SHOW_DELETE_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.delete_report)); dialog.setMessage(getString(R.string.want_to_delete)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete checkin deleteCheckins(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } } return null; }
From source file:cm.aptoide.pt.ScheduledDownloads.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Builder dialogBuilder = new AlertDialog.Builder(this); final AlertDialog scheduleDialog = dialogBuilder.create(); // AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); switch (item.getItemId()) { case 0://from ww w . jav a 2s .com for (String scheduledDownload : scheduledDownloadsHashMap.keySet()) { scheduledDownloadsHashMap.get(scheduledDownload).toggleChecked(); } adapter.notifyDataSetInvalidated(); break; case 1: if (isAllChecked()) { scheduleDialog.setTitle(getText(R.string.schDwnBtn)); scheduleDialog.setIcon(android.R.drawable.ic_menu_close_clear_cancel); scheduleDialog.setCancelable(false); scheduleDialog.setMessage(getText(R.string.schDown_sureremove)); scheduleDialog.setButton(Dialog.BUTTON_POSITIVE, getString(android.R.string.yes), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { for (String scheduledDownload : scheduledDownloadsHashMap.keySet()) { if (scheduledDownloadsHashMap.get(scheduledDownload).checked) { db.deleteScheduledDownload(scheduledDownload); } } getSupportLoaderManager().restartLoader(0, null, ScheduledDownloads.this); return; } }); scheduleDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.no), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int arg1) { dialog.cancel(); } }); scheduleDialog.show(); } else { Toast toast = Toast.makeText(this, getString(R.string.schDown_nodownloadselect), Toast.LENGTH_SHORT); toast.show(); } break; default: break; } return true; }
From source file:info.zamojski.soft.towercollector.MainActivity.java
private boolean displayInAirplaneModeDialog() { // check if in airplane mode boolean inAirplaneMode = NetworkUtils.isInAirplaneMode(getApplication()); if (inAirplaneMode) { Log.d("displayInAirplaneModeDialog(): Device is in airplane mode"); AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setCanceledOnTouchOutside(true); alertDialog.setCancelable(true); alertDialog.setTitle(R.string.main_dialog_in_airplane_mode_title); alertDialog.setMessage(getString(R.string.main_dialog_in_airplane_mode_message)); alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { }/*from w w w. ja v a2s .c o m*/ }); alertDialog.show(); } return inAirplaneMode; }
From source file:io.jari.geenstijl.Dialogs.ReplyDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); final View view = inflater.inflate(R.layout.dialog_reply, null); builder.setView(view).setPositiveButton(R.string.reply, null) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { ReplyDialog.this.getDialog().cancel(); }/*from w w w . ja v a 2s .c o m*/ }).setTitle(R.string.reply); final AlertDialog alertDialog = builder.create(); alertDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { final View error = view.findViewById(R.id.error); final Button positive = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); final Button negative = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE); positive.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { positive.setEnabled(false); negative.setEnabled(false); final TextView reply = (TextView) view.findViewById(R.id.reply); final View loading = view.findViewById(R.id.loading); reply.setVisibility(View.GONE); loading.setVisibility(View.VISIBLE); error.setVisibility(View.GONE); alertDialog.setCancelable(false); new Thread(new Runnable() { @Override public void run() { boolean success; try { success = API.reply(artikel, reply.getText().toString(), activity); } catch (Exception e) { e.printStackTrace(); success = false; } alertDialog.setCancelable(true); if (!success) activity.runOnUiThread(new Runnable() { @Override public void run() { reply.setVisibility(View.VISIBLE); error.setVisibility(View.VISIBLE); positive.setEnabled(true); negative.setEnabled(true); loading.setVisibility(View.GONE); } }); else activity.runOnUiThread(new Runnable() { @Override public void run() { alertDialog.dismiss(); Crouton.makeText(activity, getString(R.string.reply_success), Style.CONFIRM).show(); } }); } }).start(); } }); } }); return alertDialog; }