List of usage examples for android.app ProgressDialog setButton
public void setButton(int whichButton, CharSequence text, Message msg)
From source file:com.esri.android.ecologicalmarineunitexplorer.MainActivity.java
/** * Set up the FAB and ensure internect connectivity exists before * getting map ready.//from ww w . j av a2s .c o m * @param savedInstanceState Bundle */ @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); /* * If you have a basic license key, uncomment line 102. * See directions in the README about how to Configure a Basic License */ // ArcGISRuntimeEnvironment.setLicense(BuildConfig.LICENSE_KEY); // Initially hide the FAB mFab = (FloatingActionButton) findViewById(R.id.fab); if (mFab != null) { mFab.setVisibility(View.INVISIBLE); mFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { if (mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_COLLAPSED) { mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); } else if (mBottomSheetBehavior.getState() == BottomSheetBehavior.STATE_HIDDEN) { mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); } } }); } // Check for internet connectivity if (!checkForInternetConnectivity()) { final ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.setMessage(getString(R.string.internet_connectivity)); progressDialog.setTitle(getString(R.string.wireless_problem)); progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "CANCEL", new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { progressDialog.dismiss(); finish(); } }); progressDialog.show(); } else { // Get data access setup mDataManager = DataManager.getDataManagerInstance(getApplicationContext()); // Set up fragments setUpMagFragment(); setUpBottomSheetFragment(); } }
From source file:com.esri.arcgisruntime.generateofflinemapoverrides.MainActivity.java
/** * Shows a progress dialog for the given job. * * @param job to track progress from/*w w w . ja v a 2 s .c o m*/ */ private void showProgressDialog(Job job) { // create a progress dialog to show download progress ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.setTitle("Generate Offline Map Job"); progressDialog.setMessage("Taking map offline..."); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setIndeterminate(false); progressDialog.setProgress(0); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", (dialog, which) -> job.cancel()); progressDialog.show(); // show the job's progress with the progress dialog job.addProgressChangedListener(() -> progressDialog.setProgress(job.getProgress())); // dismiss dialog when job is done job.addJobDoneListener(progressDialog::dismiss); }
From source file:org.alfresco.mobile.android.application.fragments.operations.OperationWaitingDialogFragment.java
public Dialog onCreateDialog(final Bundle savedInstanceState) { setRetainInstance(true);// www . ja va 2 s . co m if (getArguments() != null) { operationType = getArguments().getInt(PARAM_TYPEID); intentId = getArguments().getString(PARAM_INTENTID); iconId = getArguments().getInt(PARAM_ICONID); title = getArguments().getString(PARAM_TITLEID); message = getArguments().getString(PARAM_MESSAGEID); parent = getArguments().getParcelable(PARAM_NODEID); nbItems = getArguments().getInt(PARAM_SIZE); } ProgressDialog dialog = new ProgressDialog(getActivity()); if (iconId == 0) { iconId = R.drawable.ic_alfresco_logo; } dialog.setIcon(iconId); dialog.setTitle(title); if (message == null) { message = getString(R.string.waiting_operations); } dialog.setMessage(message); boolean indeterminate = true; if (nbItems > 0) { dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setProgress(0); dialog.setMax(nbItems); indeterminate = false; } else { dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); } dialog.setIndeterminate(indeterminate); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); getActivity().getLoaderManager().restartLoader(this.hashCode(), null, this); return dialog; }
From source file:org.alfresco.mobile.android.ui.operation.OperationWaitingDialogFragment.java
public Dialog onCreateDialog(final Bundle savedInstanceState) { if (getArguments() != null) { operationType = getArguments().getInt(ARGUMENT_TYPEID); intentId = getArguments().getString(ARGUMENT_INTENTID); iconId = getArguments().getInt(ARGUMENT_ICONID); title = getArguments().getString(ARGUMENT_TITLEID); message = getArguments().getString(ARGUMENT_MESSAGEID); parent = getArguments().getParcelable(ARGUMENT_NODEID); nbItems = getArguments().getInt(ARGUMENT_SIZE); operationId = getArguments().getString(ARGUMENT_OPERATIONID); }/* ww w . j a v a2 s . co m*/ ProgressDialog dialog = new ProgressDialog(getActivity()); if (iconId == 0) { iconId = R.drawable.ic_application_logo; } dialog.setIcon(iconId); dialog.setTitle(title); if (message == null) { message = getString(R.string.waiting_operations); } dialog.setMessage(message); boolean indeterminate = true; if (nbItems > 0) { dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setProgress(0); dialog.setMax(nbItems); indeterminate = false; } else { dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); } dialog.setIndeterminate(indeterminate); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (operationId != null) { Operator.with(getActivity()).cancel(operationId); } dialog.dismiss(); } }); getActivity().getLoaderManager().restartLoader(this.hashCode(), null, this); return dialog; }
From source file:com.yeldi.yeldibazaar.AppDetails.java
private ProgressDialog createProgressDialog(String file, int p, int max) { final ProgressDialog pd = new ProgressDialog(this); pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); pd.setMessage(getString(R.string.download_server) + ":\n " + file); pd.setMax(max);/*w w w . ja v a 2s . c o m*/ pd.setProgress(p); pd.setCancelable(true); pd.setCanceledOnTouchOutside(false); pd.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { downloadHandler.cancel(); } }); pd.setButton(DialogInterface.BUTTON_NEUTRAL, getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { pd.cancel(); } }); pd.show(); return pd; }
From source file:com.xperia64.timidityae.TimidityActivity.java
public void saveCfgPart2(final String finalval, final String needToRename) { Intent new_intent = new Intent(); new_intent.setAction(getResources().getString(R.string.msrv_rec)); new_intent.putExtra(getResources().getString(R.string.msrv_cmd), 16); new_intent.putExtra(getResources().getString(R.string.msrv_outfile), finalval); sendBroadcast(new_intent); final ProgressDialog prog; prog = new ProgressDialog(TimidityActivity.this); prog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() { @Override//from w w w. j a va 2 s. co m public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); prog.setTitle("Saving CFG"); prog.setMessage("Saving..."); prog.setIndeterminate(true); prog.setCancelable(false); prog.show(); new Thread(new Runnable() { @Override public void run() { while (!localfinished && prog.isShowing()) { try { Thread.sleep(25); } catch (InterruptedException e) { } } TimidityActivity.this.runOnUiThread(new Runnable() { public void run() { String trueName = finalval; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && Globals.theFold != null && needToRename != null) { if (Globals.renameDocumentFile(TimidityActivity.this, finalval, needToRename)) { trueName = needToRename; } else { trueName = "Error"; } } Toast.makeText(TimidityActivity.this, "Wrote " + trueName, Toast.LENGTH_SHORT).show(); prog.dismiss(); fileFrag.getDir(fileFrag.currPath); } }); } }).start(); }
From source file:com.xperia64.timidityae.TimidityActivity.java
public void saveWavPart2(final String finalval, final String needToRename) { Intent new_intent = new Intent(); new_intent.setAction(getResources().getString(R.string.msrv_rec)); new_intent.putExtra(getResources().getString(R.string.msrv_cmd), 15); new_intent.putExtra(getResources().getString(R.string.msrv_outfile), finalval); sendBroadcast(new_intent); final ProgressDialog prog; prog = new ProgressDialog(TimidityActivity.this); prog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() { @Override/*from ww w. j ava 2s . c o m*/ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); prog.setTitle("Converting to WAV"); prog.setMessage("Converting..."); prog.setIndeterminate(false); prog.setCancelable(false); prog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); prog.show(); new Thread(new Runnable() { @Override public void run() { while (!localfinished && prog.isShowing()) { prog.setMax(JNIHandler.maxTime); prog.setProgress(JNIHandler.currTime); try { Thread.sleep(25); } catch (InterruptedException e) { } } if (!localfinished) { JNIHandler.stop(); TimidityActivity.this.runOnUiThread(new Runnable() { public void run() { Toast.makeText(TimidityActivity.this, "Conversion canceled", Toast.LENGTH_SHORT).show(); if (!Globals.keepWav) { if (new File(finalval).exists()) new File(finalval).delete(); } else { fileFrag.getDir(fileFrag.currPath); } } }); } else { TimidityActivity.this.runOnUiThread(new Runnable() { public void run() { String trueName = finalval; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && Globals.theFold != null && needToRename != null) { if (Globals.renameDocumentFile(TimidityActivity.this, finalval, needToRename)) { trueName = needToRename; } else { trueName = "Error"; } } Toast.makeText(TimidityActivity.this, "Wrote " + trueName, Toast.LENGTH_SHORT).show(); prog.dismiss(); fileFrag.getDir(fileFrag.currPath); } }); } } }).start(); }
From source file:ac.robinson.mediaphone.MediaPhoneActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case R.id.dialog_importing_in_progress: ProgressDialog importDialog = new ProgressDialog(MediaPhoneActivity.this); importDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); importDialog.setMessage(getString(R.string.import_progress)); importDialog.setCancelable(false); mImportFramesProgressDialog = importDialog; mImportFramesDialogShown = true; return importDialog; case R.id.dialog_export_narrative_in_progress: ProgressDialog exportDialog = new ProgressDialog(MediaPhoneActivity.this); exportDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); exportDialog.setMessage(getString(R.string.background_task_progress)); exportDialog.setCancelable(false); exportDialog.setIndeterminate(true); mExportNarrativeDialogShown = true; return exportDialog; case R.id.dialog_mov_creator_in_progress: ProgressDialog movDialog = new ProgressDialog(MediaPhoneActivity.this); movDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); movDialog.setMessage(getString(R.string.mov_export_task_progress)); movDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.mov_export_run_in_background), new DialogInterface.OnClickListener() { @Override/*from w w w . ja v a2s .c om*/ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); mExportVideoDialogShown = false; } }); movDialog.setCancelable(false); movDialog.setIndeterminate(true); mExportVideoDialogShown = true; return movDialog; case R.id.dialog_background_runner_in_progress: ProgressDialog runnerDialog = new ProgressDialog(MediaPhoneActivity.this); runnerDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); runnerDialog.setMessage(getString(R.string.background_task_progress)); runnerDialog.setCancelable(false); runnerDialog.setIndeterminate(true); mBackgroundRunnerDialogShown = true; return runnerDialog; default: return super.onCreateDialog(id); } }
From source file:id.ridon.keude.AppDetailsData.java
private ProgressDialog getProgressDialog(String file) { if (progressDialog == null) { final ProgressDialog pd = new ProgressDialog(this); pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); pd.setMessage(getString(R.string.download_server) + ":\n " + file); pd.setCancelable(true);/* w ww . j a v a 2 s. c o m*/ pd.setCanceledOnTouchOutside(false); // The indeterminate-ness will get overridden on the first progress event we receive. pd.setIndeterminate(true); pd.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { Log.d(TAG, "User clicked 'cancel' on download, attempting to interrupt download thread."); if (downloadHandler != null) { downloadHandler.cancel(); cleanUpFinishedDownload(); } else { Log.e(TAG, "Tried to cancel, but the downloadHandler doesn't exist."); } progressDialog = null; Toast.makeText(AppDetails.this, getString(R.string.download_cancelled), Toast.LENGTH_LONG) .show(); } }); pd.setButton(DialogInterface.BUTTON_NEUTRAL, getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { pd.cancel(); } }); progressDialog = pd; } return progressDialog; }
From source file:com.piusvelte.sonet.core.SonetCreatePost.java
protected void getPhoto(Uri uri) { final ProgressDialog loadingDialog = new ProgressDialog(this); final AsyncTask<Uri, Void, String> asyncTask = new AsyncTask<Uri, Void, String>() { @Override/* www . j av a 2s . co m*/ protected String doInBackground(Uri... imgUri) { String[] projection = new String[] { MediaStore.Images.Media.DATA }; String path = null; Cursor c = getContentResolver().query(imgUri[0], projection, null, null, null); if ((c != null) && c.moveToFirst()) { path = c.getString(c.getColumnIndex(projection[0])); } else { // some file manages send the path through the uri path = imgUri[0].getPath(); } c.close(); return path; } @Override protected void onPostExecute(String path) { if (loadingDialog.isShowing()) loadingDialog.dismiss(); if (path != null) setPhoto(path); else (Toast.makeText(SonetCreatePost.this, "error retrieving the photo path", Toast.LENGTH_LONG)) .show(); } }; loadingDialog.setMessage(getString(R.string.loading)); loadingDialog.setCancelable(true); loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (!asyncTask.isCancelled()) asyncTask.cancel(true); } }); loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); loadingDialog.show(); asyncTask.execute(uri); }