List of usage examples for android.app AlertDialog.Builder show
public void show()
From source file:de.quadrillenschule.azocamsynca.job.JobProcessor.java
public void processingLoop() { if (getRequestStatus() == ProcessorStatus.PAUSED) { setStatus(ProcessorStatus.PAUSED); return;/*from w w w. ja v a2s . c o m*/ } setStatus(ProcessorStatus.PROCESSING); TriggerPhotoSerie currentJobT = null; for (TriggerPhotoSerie j : jobs) { if (j.getTriggerStatus() != TriggerPhotoSerie.TriggerJobStatus.FINISHED_TRIGGERING) { currentJobT = j; if ((j.getTriggerStatus() == PhotoSerie.TriggerJobStatus.WAITFORUSER) && ((alertDialog != null) && (alertDialog.isShowing()))) { return; } if ((j.getTriggerStatus() == PhotoSerie.TriggerJobStatus.WAITFORUSER)) { currentJobT.setTriggerStatus(PhotoSerie.TriggerJobStatus.NEW); } break; } } if (currentJobT == null) { setStatus(ProcessorStatus.PAUSED); return; } final TriggerPhotoSerie currentJob = currentJobT; final NikonIR camera = ((AzoTriggerServiceApplication) getActivity().getApplication()).getCamera(); if (currentJob.getTriggerStatus() == PhotoSerie.TriggerJobStatus.NEW) { currentJob.setTriggerStatus(PhotoSerie.TriggerJobStatus.WAITFORUSER); if (currentJob.getSeriesName().equals(PhotoSerie.TESTSHOTS)) { doTestShots(currentJob); return; } AlertDialog.Builder ad = new AlertDialog.Builder(getActivity(), R.style.dialog); ad.setTitle(currentJob.getProject() + ": " + currentJob.getSeriesName()); ad.setMessage( currentJob.getNumber() + " x " + (int) (currentJob.getExposure() / 1000) + "s\n\n" + "Delay after each exposure:" + currentJob.getDelayAfterEachExposure() / 1000 + "s\n" + "Camera controls time: " + camera.isExposureSetOnCamera(currentJob.getExposure()) + "\n" + "Total time: " + ((currentJob.getNumber() * (currentJob.getExposure() + currentJob.getDelayAfterEachExposure())) / 1000) + "s"); ad.setPositiveButton("Confirm", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { currentJob.setTriggerStatus(PhotoSerie.TriggerJobStatus.PREPARED); processingLoop(); } }); ad.setNegativeButton("Pause", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { currentJob.setTriggerStatus(PhotoSerie.TriggerJobStatus.NEW); pause(); } }); MediaPlayer mediaPlayer = MediaPlayer.create(activity, R.raw.oida_peda); mediaPlayer.start(); ad.create(); alertDialog = ad.show(); } final Handler handler = new Handler(); if ((currentJob.getTriggerStatus() == PhotoSerie.TriggerJobStatus.PREPARED || currentJob.getTriggerStatus() == PhotoSerie.TriggerJobStatus.RUNNING)) { handler.postDelayed(new Runnable() { public void run() { if ((((AzoTriggerServiceApplication) getActivity().getApplication()).getJobProcessor() .getStatus() == ProcessorStatus.PAUSED) && (!currentJob.isToggleIsOpen())) { return; } camera.trigger(); for (JobProgressListener j : jobProgressListeners) { j.jobProgressed(currentJob); } if (currentJob.getFirstTriggerTime() == 0) { currentJob.setFirstTriggerTime(System.currentTimeMillis()); } currentJob.setTriggerStatus(PhotoSerie.TriggerJobStatus.RUNNING); if (!camera.isExposureSetOnCamera(currentJob.getExposure())) { if (!currentJob.isToggleIsOpen()) { currentJob.setToggleIsOpen(!currentJob.isToggleIsOpen()); currentJob.setLastTriggerTime(System.currentTimeMillis()); } else { currentJob.setToggleIsOpen(!currentJob.isToggleIsOpen()); currentJob.setTriggered(currentJob.getTriggered() + 1); } } else { currentJob.setTriggered(currentJob.getTriggered() + 1); } if (currentJob.getTriggered() < currentJob.getNumber()) { long time; if (camera.isExposureSetOnCamera(currentJob.getExposure())) { time = currentJob.getExposure() + currentJob.getDelayAfterEachExposure(); } else { if (currentJob.isToggleIsOpen()) { time = currentJob.getExposure(); } else { time = currentJob.getDelayAfterEachExposure(); } } handler.postDelayed(this, time); } else { currentJob.setTriggerStatus(PhotoSerie.TriggerJobStatus.FINISHED_TRIGGERING); processingLoop(); } } }, currentJob.getInitialDelay()); } else { } }
From source file:br.com.GUI.perfil.MeuPersonal.java
public void adicionarRemoverMeuPersonal() { AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()); alertDialog.setTitle("Confirme esta ao"); alertDialog.setMessage("Voc realmente deseja remover seu treinador?"); alertDialog.setIcon(R.drawable.profile); alertDialog.setNegativeButton("Sim", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (a.getUsuarioPersonal().equals(p.getUsuario())) { if (a.removerAlunoWeb(a.getUsuario()) && a.removerAluno(b)) { Toast.makeText(getActivity(), "Removido com Sucesso", Toast.LENGTH_SHORT).show(); // Exclui todas as aulas marcadas com o personal ArrayList<Aula> aulasParaExcluir = new ArrayList<Aula>(); aulasParaExcluir = new Aula().buscarAulasPorAlunoWeb(a.getUsuario(), ""); for (Aula c : aulasParaExcluir) { if (c.excluirAulaWeb() && c.excluirAula(b)) { Log.i("INFORMAO", "Aulas excluidas com sucesso!"); }/*from w w w . j av a2s .com*/ } atualizarMeuPersonal(); } else { Toast.makeText(getActivity(), "Falha ao Remover o aluno", Toast.LENGTH_SHORT).show(); } } atualizarMeuPersonal(); } }); alertDialog.setPositiveButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); // Showing Alert Message alertDialog.show(); }
From source file:com.google.zxing.client.android.history.HistoryActivity.java
public void enviaTodosDados() { /*/* w ww. j a v a 2 s .com*/ * enviar todos os qr's lidos */ AlertDialog.Builder builder1 = new AlertDialog.Builder(this, 3); builder1.setMessage(R.string.enviar_todos); builder1.setCancelable(true); builder1.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int i2) { boolean conectado = verificaConexao(); if (conectado) { try { progDialog.setTitle(R.string.alerta_enviando_dados); progDialog.setMessage( getBaseContext().getResources().getString(R.string.alerta_dados_sendo_enviados)); progDialog.setIcon(android.R.drawable.ic_menu_upload); progDialog.show(); enviarListaHistorico(); } catch (Exception e) { // TODO: handle exception progDialog.setIcon(android.R.drawable.ic_dialog_alert); progDialog.setTitle(R.string.alerta_erro); progDialog.setMessage( getBaseContext().getResources().getString(R.string.alerta_erro_ao_enviar_dados) + " - " + e.getMessage()); progDialog.dismiss(); } } dialog.dismiss(); } }); builder1.setNegativeButton(R.string.button_cancel, null); builder1.show(); }
From source file:com.sssemil.sonyirremote.ir.ir.java
public void startLearning(final String filename) { File to = new File(filename); if (to.exists()) { AlertDialog.Builder adb1 = new AlertDialog.Builder(this); adb1.setTitle(getString(R.string.warning)); adb1.setMessage(getString(R.string.alredy_exists)); adb1.setIcon(android.R.drawable.ic_dialog_alert); adb1.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { learnAction(filename);//from ww w . j a va2 s. c o m } }); adb1.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); adb1.show(); } else { learnAction(filename); } }
From source file:za.co.neilson.alarm.preferences.AlarmPreferencesActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_item_save: Database.init(getApplicationContext()); Database.setEmail(email);//from w w w.jav a2 s . com if (getMathAlarm().getId() < 1) { getMathAlarm().setEmail(email); Database.create(getMathAlarm()); Bundle bundle = getIntent().getExtras(); if (bundle != null && bundle.containsKey("user")) { User user = (User) bundle.getSerializable("user"); Group group = new Group(getMathAlarm(), user); Database.addGroup(group); } params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("email", email)); Log.d("??? ? : ", "" + email); params.add(new BasicNameValuePair("time", getMathAlarm().getAlarmTimeString())); params.add(new BasicNameValuePair("difficulty", Integer.toString(getMathAlarm().getDifficulty().ordinal()))); params.add(new BasicNameValuePair("tone", getMathAlarm().getAlarmTonePath())); params.add(new BasicNameValuePair("vibrate", Boolean.toString(getMathAlarm().getVibrate()))); params.add(new BasicNameValuePair("name", getMathAlarm().getAlarmName())); //params.add(new BasicNameValuePair("days", Arrays.toString(getMathAlarm().getDays()))); for (int i = 0; i < getMathAlarm().getDays().length; i++) { params.add(new BasicNameValuePair("days", getMathAlarm().getDays()[i].toString())); } ServerRequest sr = new ServerRequest(); JSONObject json = sr.getJSON("http://168.188.123.218:8080/alarmdata", params); if (json != null) { try { String jsonstr = json.getString("response"); //JSONObject json2 = sr.getJSON("http://168.188.123.218:8080/useralarm", params); } catch (JSONException e) { e.printStackTrace(); } } } else { Database.update(getMathAlarm()); Database.setEmail(email); } callMathAlarmScheduleService(); Toast.makeText(AlarmPreferencesActivity.this, getMathAlarm().getTimeUntilNextAlarmMessage(), Toast.LENGTH_LONG).show(); finish(); break; case R.id.menu_item_delete: AlertDialog.Builder dialog = new AlertDialog.Builder(AlarmPreferencesActivity.this); dialog.setTitle("Delete"); dialog.setMessage("Delete this alarm?"); dialog.setPositiveButton("Ok", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Database.init(getApplicationContext()); Database.setEmail(email); if (getMathAlarm().getId() < 1) { // Alarm not saved } else { params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("email", email)); params.add(new BasicNameValuePair("time", alarm.getAlarmTimeString())); Log.d("??? ? : ", "" + email); ServerRequest sr = new ServerRequest(); JSONObject json = sr.getJSON("http://168.188.123.218:8080/deletealarm", params); Database.deleteEntry(alarm); callMathAlarmScheduleService(); } finish(); } }); dialog.setNegativeButton("Cancel", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.show(); break; } return super.onOptionsItemSelected(item); }
From source file:at.ac.tuwien.detlef.activities.MainActivity.java
private void startSettingsActivityIfNoDeviceIdSet() { if (Singletons.i().getGpodderSettings().getDeviceId() != null) { return;/*from www . j av a 2 s .c o m*/ } final AlertDialog.Builder b = new AlertDialog.Builder(this); b.setTitle(R.string.detlef_says_hello); b.setMessage(R.string.detlef_is_not_set_up_yet); b.setPositiveButton(android.R.string.yes, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startActivityForResult(new Intent(getApplicationContext(), SettingsActivity.class) .putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsGpodderNet.class.getName()) .putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true) .putExtra(SettingsGpodderNet.EXTRA_SETUPMODE, true), 0); } }); b.setNegativeButton(android.R.string.no, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getApplicationContext(), getString(R.string.you_can_setup_your_account_later), Toast.LENGTH_LONG).show(); } }); b.show(); }
From source file:ca.ualberta.cmput301w14t08.geochan.fragments.EditFragment.java
/** * Allows the user to change the image attached to their comment or remove it * entirely. Prompts the user with an AlertDialog as to which option they would like * to select. // w ww. jav a 2 s. com * @param view The Button pressed to call editImage. */ public void editImage(View view) { if (view.getId() == R.id.attach_image_button) { AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity()); dialog.setTitle(R.string.attach_image_title); dialog.setMessage(R.string.attach_image_dialog); dialog.setPositiveButton("Gallery", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Test"), ImageHelper.REQUEST_GALLERY); } }); dialog.setNegativeButton("Camera", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { Intent intent = new Intent(); intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); try { imageFile = ImageHelper.createImageFile(); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile)); startActivityForResult(Intent.createChooser(intent, "Test"), ImageHelper.REQUEST_CAMERA); } catch (IOException e) { e.printStackTrace(); } } }); dialog.setNeutralButton("Remove Image", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { editComment.setImage(null); editComment.setImageThumb(null); } }); dialog.show(); } }
From source file:com.t2.compassionMeditation.MeditationActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.settings: Intent intent2 = new Intent(this, BTServiceManager.class); this.startActivity(intent2); return true; case R.id.discover: mManager.discoveryWsn();/* w ww . j a v a2 s . c om*/ return true; case R.id.about: String content = "National Center for Telehealth and Technology (T2)\n\n"; content += "BioZen Application\n"; content += "Application Version: " + mApplicationVersion + "\n"; content += "Activity Version: " + mActivityVersion; AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("About"); alert.setMessage(content); alert.show(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.sssemil.sonyirremote.ir.ir.java
public void update() { final GetLastVer getLastVer1 = new GetLastVer(ir.this); try {/*w w w. j ava2s . c om*/ Log.i("Update", "last_ver : " + getLastVer1.execute().get() + " cur_ver : " + cur_ver); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } if (last_ver == "zirt") { AlertDialog.Builder adb = new AlertDialog.Builder(this); adb.setTitle(getString(R.string.update)); adb.setMessage(getString(R.string.ser3)); adb.setIcon(android.R.drawable.ic_dialog_alert); adb.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { update(); } }); adb.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //finish(); } }); adb.show(); } else { String result = compare(cur_ver, last_ver); boolean doUpdate = false; if (result == ">") { doUpdate = false; } else if (result == "<") { doUpdate = true; } else if (result == "==") { doUpdate = false; } if (doUpdate == true) { AlertDialog.Builder adb = new AlertDialog.Builder(this); adb.setTitle(getString(R.string.update)); adb.setMessage(getString(R.string.new_version_available)); adb.setIcon(android.R.drawable.ic_dialog_alert); adb.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mProgressDialog = new ProgressDialog(ir.this); mProgressDialog.setMessage(getString(R.string.downloading_new)); mProgressDialog.setIndeterminate(true); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); mProgressDialog.setCancelable(true); final DownloadApp downloadApp1 = new DownloadApp(ir.this); downloadApp1.execute(http_path_last_download1 + last_ver + http_path_last_download2); mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { downloadApp1.cancel(true); } }); } }); adb.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); adb.show(); } else if (doUpdate == false) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.update)); builder.setMessage(getString(R.string.already_new)); builder.setPositiveButton("OK", null); builder.show(); } } }
From source file:mp.paschalis.EditBookActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); app = (App) getApplication();//from w w w. j a v a2s . c o m setContentView(R.layout.activity_edit_book); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Get arguments, to determine who opened this activity final Bundle extras = getIntent().getExtras(); try { fromBookSearch = extras.getBoolean(App.ExtrasForEditBookActivityFromBookSearch); } catch (Exception e) { fromBookSearch = false; } // Set the layout's data // Get layout's Data bookISBN = (TextView) findViewById(R.id.textViewBookISBN); bookTitle = (TextView) findViewById(R.id.textViewBookTitle); bookAuthors = (TextView) findViewById(R.id.textViewBookAuthors); bookPublishedYear = (TextView) findViewById(R.id.textViewBookPublishedYear); bookPageCount = (TextView) findViewById(R.id.textViewBookPageCount); bookDateOfInsert = (TextView) findViewById(R.id.textViewBookDateOfInsert); bookCoverImage = (ImageView) findViewById(R.id.imageViewBookCover); bookLanguage = (TextView) findViewById(R.id.textViewBookLanguage); textViewCheckYourBooks = (TextView) findViewById(R.id.textViewCheckYourBooks); TextView tvnocover = (TextView) findViewById(R.id.textViewNoCover); ProgressBar pb = (ProgressBar) findViewById(R.id.progressBarLoadCover); // show The Image and save it to Library ImageLoader.DataClassDisplayBookCover bk = new ImageLoader.DataClassDisplayBookCover(); bk.iv = bookCoverImage; bk.isCover = true; bk.pb = pb; bk.tv = tvnocover; bk.book = app.selectedBook; App.imageLoader.DisplayCover(bk); // Assign the appropriate data from our alert object above bookISBN.setText(app.selectedBook.isbn); bookTitle.setText(app.selectedBook.title); bookAuthors.setText(app.selectedBook.authors); bookPublishedYear.setText(Integer.valueOf(app.selectedBook.publishedYear).toString()); bookPageCount.setText(Integer.valueOf(app.selectedBook.pageCount).toString()); bookDateOfInsert .setText(App.makeTimeStampHumanReadble(getApplicationContext(), app.selectedBook.dateOfInsert)); bookLanguage.setText(app.selectedBook.lang); progressBarChangeStatusOfBook = (ProgressBar) findViewById(R.id.progressBarChangeBookStatus); progressBarLentReturnButton = (ProgressBar) findViewById(R.id.progressBarReturnLentBook); progressBarLentDeleteButton = (ProgressBar) findViewById(R.id.progressBarBookDeleteButton); buttonDeleteBook = (Button) findViewById(R.id.buttonBookDelete); buttonLentReturnBook = (Button) findViewById(R.id.buttonLentReturnBook); spinnerEditBookStatus = (Spinner) findViewById(R.id.spinnerBookStatus); // Create adapter for the Spinner adapter = ArrayAdapter.createFromResource(this, R.array.ArrayBookSetStatus, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner spinnerEditBookStatus.setAdapter(adapter); getStatusDefaultValue(); spinnerEditBookStatus.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) { if (booleanFirstInit) { booleanFirstInit = false; return; } // your code here new AsyncTaskChangeStatusOfBook().execute( App.getBookStatusCode((String) (adapter.getItem(position)), EditBookActivity.this)); } @Override public void onNothingSelected(AdapterView<?> parentView) { } }); // Hybrid button: Lent/Return a book buttonLentReturnBook.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { { // Lent the book if (buttonLentReturnBook.getText().toString().equals(getString(R.string.lent))) { // Send ISBN As Argument Intent i = new Intent(getApplicationContext(), LentBookActivity.class); i.putExtra(App.ExtrasForLentBookActivityISBN, bookISBN.getText().toString()); EditBookActivity.this.startActivity(i); } // Return the book else { { AlertDialog.Builder alert = new AlertDialog.Builder(EditBookActivity.this); alert.setTitle(R.string.msgIsItReturnedToYou_); alert.setIcon(R.drawable.ic_menu_forward); alert.setNegativeButton(R.string.no, new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); alert.setPositiveButton(R.string.yes, new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Return the book new AsyncTaskReturnABook().execute(app.selectedBook.isbn); } }); alert.show(); } } } } });// End of Lent/Return Button! // Delete Button buttonDeleteBook.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { { AlertDialog.Builder alert = new AlertDialog.Builder(EditBookActivity.this); alert.setTitle(R.string.msgAreYouSureDelBOok_); alert.setIcon(R.drawable.ic_dialog_alert_holo_light); alert.setNegativeButton(R.string.no, new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); alert.setPositiveButton(R.string.yes, new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Return the book new AsyncTaskDeleteABook().execute(app.selectedBook.isbn); } }); alert.show(); } } }); }