List of usage examples for android.app ProgressDialog setButton
@Deprecated public void setButton(CharSequence text, Message msg)
From source file:org.odk.collect.android.fragments.dialogs.FormLoadingDialogFragment.java
@NonNull @Override//w ww . ja v a 2 s.c o m public Dialog onCreateDialog(Bundle savedInstanceState) { setCancelable(false); ProgressDialog dialog = new ProgressDialog(getActivity(), getTheme()); dialog.setTitle(R.string.loading_form); dialog.setMessage(getString(R.string.please_wait)); dialog.setButton(getString(R.string.cancel_loading_form), (dialog1, which) -> listener.onCancelFormLoading()); return dialog; }
From source file:com.google.android.apps.tvremote.PairingActivity.java
private ProgressDialog buildProgressDialog() { ProgressDialog dialog = new ProgressDialog(this); dialog.setMessage(getString(R.string.pairing_waiting)); dialog.setOnKeyListener(new DialogInterface.OnKeyListener() { public boolean onKey(DialogInterface dialogInterface, int which, KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { cancelPairing();// w ww. j a v a 2s . com return true; } return false; } }); dialog.setButton(getString(R.string.pairing_cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int which) { cancelPairing(); } }); return dialog; }
From source file:fm.smart.r1.activity.CreateItemActivity.java
public void onClick(View v) { EditText cueInput = (EditText) findViewById(R.id.cue); EditText responseInput = (EditText) findViewById(R.id.response); Spinner posInput = (Spinner) findViewById(R.id.pos); EditText characterResponseInput = (EditText) findViewById(R.id.response_character); EditText characterCueInput = (EditText) findViewById(R.id.cue_character); final String cue = cueInput.getText().toString(); final String response = responseInput.getText().toString(); final String pos = posInput.getSelectedItem().toString(); final String character_cue = characterCueInput.getText().toString(); final String character_response = characterResponseInput.getText().toString(); String pos_code = Utils.POS_MAP.get(pos); if (TextUtils.isEmpty(pos_code)) { pos_code = "NONE"; }//from w w w . ja v a2 s . c o m final String final_pos_code = pos_code; if (Main.isNotLoggedIn(this)) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName(this, LoginActivity.class.getName()); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // avoid // navigation // back to this? LoginActivity.return_to = CreateItemActivity.class.getName(); LoginActivity.params = new HashMap<String, String>(); LoginActivity.params.put("list_id", list_id); LoginActivity.params.put("cue", cue); LoginActivity.params.put("response", response); LoginActivity.params.put("cue_language", cue_language); LoginActivity.params.put("response_language", response_language); LoginActivity.params.put("pos", pos); LoginActivity.params.put("character_cue", character_cue); LoginActivity.params.put("character_response", character_response); startActivity(intent); } else { // TODO cue and response languages need to be inferred from list we are // adding to ... Might want to fix those, i.e. not allow variation // on // search ... // TODO wondering whether there is some way to edit existing items // ... final ProgressDialog myOtherProgressDialog = new ProgressDialog(this); myOtherProgressDialog.setTitle("Please Wait ..."); myOtherProgressDialog.setMessage("Creating Item ..."); myOtherProgressDialog.setIndeterminate(true); myOtherProgressDialog.setCancelable(true); final Thread create_item = new Thread() { public void run() { // TODO make this interruptable .../*if // (!this.isInterrupted())*/ CreateItemActivity.create_item_result = createItem(cue, cue_language, character_cue, final_pos_code, response, response_language, character_response, list_id); myOtherProgressDialog.dismiss(); } }; myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { create_item.interrupt(); } }); OnCancelListener ocl = new OnCancelListener() { public void onCancel(DialogInterface arg0) { create_item.interrupt(); } }; myOtherProgressDialog.setOnCancelListener(ocl); myOtherProgressDialog.show(); create_item.start(); } }
From source file:com.entertailion.android.dial.ServerFinder.java
private ProgressDialog buildProgressDialog(String message, DialogInterface.OnClickListener cancelListener) { ProgressDialog dialog = new ProgressDialog(this); dialog.setMessage(message);/*from w w w.j av a 2 s . c om*/ dialog.setOnKeyListener(new DialogInterface.OnKeyListener() { public boolean onKey(DialogInterface dialogInterface, int which, KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { finish(); return true; } return false; } }); dialog.setButton(getString(R.string.finder_cancel), cancelListener); return dialog; }
From source file:fm.smart.r1.activity.CreateSoundActivity.java
public void onClick(View v) { String threegpfile_name = "test.3gp_amr"; String amrfile_name = "test.amr"; File dir = this.getDir("sounds", MODE_WORLD_READABLE); final File threegpfile = new File(dir, threegpfile_name); File amrfile = new File(dir, amrfile_name); String path = threegpfile.getAbsolutePath(); Log.d("CreateSoundActivity", path); Log.d("CreateSoundActivity", (String) button.getText()); if (button.getText().equals("Start")) { try {//from ww w. j a v a 2s.c o m recorder = new MediaRecorder(); // ContentValues values = new ContentValues(3); // // values.put(MediaStore.MediaColumns.TITLE, "test"); // values.put(MediaStore.MediaColumns.DATE_ADDED, // System.currentTimeMillis()); // values.put(MediaStore.MediaColumns.MIME_TYPE, // MediaRecorder.OutputFormat.THREE_GPP); // // ContentResolver contentResolver = new ContentResolver(this); // // Uri base = MediaStore.Audio.INTERNAL_CONTENT_URI; // Uri newUri = contentResolver.insert(base, values); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile(path); recorder.prepare(); button.setText("Stop"); recorder.start(); } catch (Exception e) { Log.w(TAG, e); } } else { FileOutputStream os = null; FileInputStream is = null; try { recorder.stop(); recorder.release(); // Now the object cannot be reused button.setEnabled(false); // ThreegpReader tr = new ThreegpReader(threegpfile); // os = new FileOutputStream(amrfile); // tr.extractAmr(os); is = new FileInputStream(threegpfile); playSound(is.getFD()); final String media_entity = "http://test.com/test.mp3"; final String author = "tansaku"; final String author_url = "http://smart.fm/users/tansaku"; if (Main.isNotLoggedIn(this)) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName(this, LoginActivity.class.getName()); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); LoginActivity.return_to = CreateSoundActivity.class.getName(); LoginActivity.params = new HashMap<String, String>(); LoginActivity.params.put("item_id", item_id); LoginActivity.params.put("list_id", list_id); LoginActivity.params.put("id", id); LoginActivity.params.put("to_record", to_record); LoginActivity.params.put("sound_type", sound_type); startActivity(intent); } else { final ProgressDialog myOtherProgressDialog = new ProgressDialog(this); myOtherProgressDialog.setTitle("Please Wait ..."); myOtherProgressDialog.setMessage("Creating Sound ..."); myOtherProgressDialog.setIndeterminate(true); myOtherProgressDialog.setCancelable(true); final Thread create_sound = new Thread() { public void run() { // TODO make this interruptable .../*if // (!this.isInterrupted())*/ CreateSoundActivity.create_sound_result = createSound(threegpfile, media_entity, author, author_url, "1", id); myOtherProgressDialog.dismiss(); } }; myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { create_sound.interrupt(); } }); OnCancelListener ocl = new OnCancelListener() { public void onCancel(DialogInterface arg0) { create_sound.interrupt(); } }; myOtherProgressDialog.setOnCancelListener(ocl); myOtherProgressDialog.show(); create_sound.start(); } } catch (Exception e) { Log.w(TAG, e); } finally { if (os != null) { try { os.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (is != null) { try { is.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } }
From source file:org.odk.collect.android.activities.GoogleDriveActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case PROGRESS_DIALOG: Collect.getInstance().getActivityLogger().logAction(this, "onCreateDialog.PROGRESS_DIALOG", "show"); ProgressDialog progressDialog = new ProgressDialog(this); DialogInterface.OnClickListener loadingButtonListener = new DialogInterface.OnClickListener() { @Override//w ww. j a v a 2s. c om public void onClick(DialogInterface dialog, int which) { Collect.getInstance().getActivityLogger().logAction(this, "onCreateDialog.PROGRESS_DIALOG", "cancel"); dialog.dismiss(); getFileTask.cancel(true); getFileTask.setGoogleDriveFormDownloadListener(null); } }; progressDialog.setTitle(getString(R.string.downloading_data)); progressDialog.setMessage(alertMsg); progressDialog.setIndeterminate(true); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setCancelable(false); progressDialog.setButton(getString(R.string.cancel), loadingButtonListener); return progressDialog; case GOOGLE_USER_DIALOG: AlertDialog.Builder gudBuilder = new AlertDialog.Builder(this); gudBuilder.setTitle(getString(R.string.no_google_account)); gudBuilder.setMessage(getString(R.string.google_set_account)); gudBuilder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); gudBuilder.setCancelable(false); return gudBuilder.create(); } return null; }
From source file:fm.smart.r1.ItemActivity.java
public void addToList(final String item_id) { final ProgressDialog myOtherProgressDialog = new ProgressDialog(this); myOtherProgressDialog.setTitle("Please Wait ..."); myOtherProgressDialog.setMessage("Adding item to study goal ..."); myOtherProgressDialog.setIndeterminate(true); myOtherProgressDialog.setCancelable(true); final Thread add = new Thread() { public void run() { ItemActivity.add_item_result = new AddItemResult( Main.lookup.addItemToGoal(Main.transport, Main.default_study_goal_id, item_id, null)); myOtherProgressDialog.dismiss(); ItemActivity.this.runOnUiThread(new Thread() { public void run() { final AlertDialog dialog = new AlertDialog.Builder(ItemActivity.this).create(); dialog.setTitle(ItemActivity.add_item_result.getTitle()); dialog.setMessage(ItemActivity.add_item_result.getMessage()); ItemActivity.add_item_result = null; dialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { }/* ww w. j a v a2 s . c o m*/ }); dialog.show(); } }); } }; myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { add.interrupt(); } }); OnCancelListener ocl = new OnCancelListener() { public void onCancel(DialogInterface arg0) { add.interrupt(); } }; myOtherProgressDialog.setOnCancelListener(ocl); closeMenu(); myOtherProgressDialog.show(); add.start(); }
From source file:fm.smart.r1.activity.CreateExampleActivity.java
public void onClick(View v) { EditText exampleInput = (EditText) findViewById(R.id.create_example_sentence); EditText translationInput = (EditText) findViewById(R.id.create_example_translation); EditText exampleTransliterationInput = (EditText) findViewById(R.id.sentence_transliteration); EditText translationTransliterationInput = (EditText) findViewById(R.id.translation_transliteration); final String example = exampleInput.getText().toString(); final String translation = translationInput.getText().toString(); if (TextUtils.isEmpty(example) || TextUtils.isEmpty(translation)) { Toast t = Toast.makeText(this, "Example and translation are required fields", 150); t.setGravity(Gravity.CENTER, 0, 0); t.show();//from ww w . jav a2 s. c o m } else { final String example_language_code = Utils.LANGUAGE_MAP.get(example_language); final String translation_language_code = Utils.LANGUAGE_MAP.get(translation_language); final String example_transliteration = exampleTransliterationInput.getText().toString(); final String translation_transliteration = translationTransliterationInput.getText().toString(); if (Main.isNotLoggedIn(this)) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName(this, LoginActivity.class.getName()); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // avoid // navigation // back to this? LoginActivity.return_to = CreateExampleActivity.class.getName(); LoginActivity.params = new HashMap<String, String>(); LoginActivity.params.put("list_id", list_id); LoginActivity.params.put("item_id", item_id); LoginActivity.params.put("example", example); LoginActivity.params.put("translation", translation); LoginActivity.params.put("example_language", example_language); LoginActivity.params.put("translation_language", translation_language); LoginActivity.params.put("example_transliteration", example_transliteration); LoginActivity.params.put("translation_transliteration", translation_transliteration); startActivity(intent); } else { final ProgressDialog myOtherProgressDialog = new ProgressDialog(this); myOtherProgressDialog.setTitle("Please Wait ..."); myOtherProgressDialog.setMessage("Creating Example ..."); myOtherProgressDialog.setIndeterminate(true); myOtherProgressDialog.setCancelable(true); final Thread create_example = new Thread() { public void run() { // TODO make this interruptable .../*if // (!this.isInterrupted())*/ try { // TODO failures here could derail all ... CreateExampleActivity.add_item_list_result = ItemActivity.addItemToList(list_id, item_id, CreateExampleActivity.this); CreateExampleActivity.create_example_result = createExample(example, example_language_code, example_transliteration, translation, translation_language_code, translation_transliteration, item_id, list_id); CreateExampleActivity.add_sentence_list_result = ItemActivity.addSentenceToList( CreateExampleActivity.create_example_result.http_response, item_id, list_id, CreateExampleActivity.this); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } myOtherProgressDialog.dismiss(); } }; myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { create_example.interrupt(); } }); OnCancelListener ocl = new OnCancelListener() { public void onCancel(DialogInterface arg0) { create_example.interrupt(); } }; myOtherProgressDialog.setOnCancelListener(ocl); myOtherProgressDialog.show(); create_example.start(); } } }
From source file:fm.smart.r1.activity.ItemActivity.java
public void addToList(final String item_id) { final ProgressDialog myOtherProgressDialog = new ProgressDialog(this); myOtherProgressDialog.setTitle("Please Wait ..."); myOtherProgressDialog.setMessage("Adding item to study list ..."); myOtherProgressDialog.setIndeterminate(true); myOtherProgressDialog.setCancelable(true); final Thread add = new Thread() { public void run() { ItemActivity.add_item_result = addItemToList(Main.default_study_list_id, item_id, ItemActivity.this); myOtherProgressDialog.dismiss(); ItemActivity.this.runOnUiThread(new Thread() { public void run() { final AlertDialog dialog = new AlertDialog.Builder(ItemActivity.this).create(); dialog.setTitle(ItemActivity.add_item_result.getTitle()); dialog.setMessage(ItemActivity.add_item_result.getMessage()); ItemActivity.add_item_result = null; dialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { }/* w w w. j a v a 2 s.c om*/ }); dialog.show(); } }); } }; myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { add.interrupt(); } }); OnCancelListener ocl = new OnCancelListener() { public void onCancel(DialogInterface arg0) { add.interrupt(); } }; myOtherProgressDialog.setOnCancelListener(ocl); closeMenu(); myOtherProgressDialog.show(); add.start(); }
From source file:fm.smart.r1.CreateExampleActivity.java
public void onClick(View v) { EditText exampleInput = (EditText) findViewById(R.id.create_example_sentence); EditText translationInput = (EditText) findViewById(R.id.create_example_translation); EditText exampleTransliterationInput = (EditText) findViewById(R.id.sentence_transliteration); EditText translationTransliterationInput = (EditText) findViewById(R.id.translation_transliteration); final String example = exampleInput.getText().toString(); final String translation = translationInput.getText().toString(); if (TextUtils.isEmpty(example) || TextUtils.isEmpty(translation)) { Toast t = Toast.makeText(this, "Example and translation are required fields", 150); t.setGravity(Gravity.CENTER, 0, 0); t.show();// w ww.j a va 2 s. co m } else { final String example_language_code = Utils.LANGUAGE_MAP.get(example_language); final String translation_language_code = Utils.LANGUAGE_MAP.get(translation_language); final String example_transliteration = exampleTransliterationInput.getText().toString(); final String translation_transliteration = translationTransliterationInput.getText().toString(); if (LoginActivity.isNotLoggedIn(this)) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName(this, LoginActivity.class.getName()); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // avoid // navigation // back to this? LoginActivity.return_to = CreateExampleActivity.class.getName(); LoginActivity.params = new HashMap<String, String>(); LoginActivity.params.put("goal_id", goal_id); LoginActivity.params.put("item_id", item_id); LoginActivity.params.put("example", example); LoginActivity.params.put("translation", translation); LoginActivity.params.put("example_language", example_language); LoginActivity.params.put("translation_language", translation_language); LoginActivity.params.put("example_transliteration", example_transliteration); LoginActivity.params.put("translation_transliteration", translation_transliteration); startActivity(intent); } else { final ProgressDialog myOtherProgressDialog = new ProgressDialog(this); myOtherProgressDialog.setTitle("Please Wait ..."); myOtherProgressDialog.setMessage("Creating Example ..."); myOtherProgressDialog.setIndeterminate(true); myOtherProgressDialog.setCancelable(true); final Thread create_example = new Thread() { public void run() { // TODO make this interruptable .../*if // (!this.isInterrupted())*/ try { // TODO failures here could derail all ... CreateExampleActivity.add_item_goal_result = new AddItemResult( Main.lookup.addItemToGoal(Main.transport, goal_id, item_id, null)); Result result = null; try { result = Main.lookup.createExample(Main.transport, translation, translation_language_code, translation, null, null, null); JSONObject json = new JSONObject(result.http_response); String text = json.getString("text"); String translation_id = json.getString("id"); result = Main.lookup.createExample(Main.transport, example, example_language_code, example_transliteration, translation_id, item_id, goal_id); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } CreateExampleActivity.create_example_result = new CreateExampleResult(result); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } myOtherProgressDialog.dismiss(); } }; myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { create_example.interrupt(); } }); OnCancelListener ocl = new OnCancelListener() { public void onCancel(DialogInterface arg0) { create_example.interrupt(); } }; myOtherProgressDialog.setOnCancelListener(ocl); myOtherProgressDialog.show(); create_example.start(); } } }