Java Code Examples for android.app.progressdialog#setButton()

The following examples show how to use android.app.progressdialog#setButton() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DetailActivity.java    From KinoCast with MIT License 6 votes vote down vote up
public QueryPlayTask(Context context) {
    this.context = context;
    progressDialog = new ProgressDialog(context);
    progressDialog.setIndeterminate(true);
    progressDialog.setMessage(getString(R.string.loading));
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(android.R.string.cancel), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            cancel(true);
        }
    });
    progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            cancel(true);
        }
    });
}
 
Example 2
Source File: AsyncCopyMoveTask.java    From Rey-MusicPlayer with Apache License 2.0 6 votes vote down vote up
protected void onPreExecute() {
    pd = new ProgressDialog(mFragment.getActivity());
    pd.setCancelable(false);
    pd.setIndeterminate(false);

    if (mShouldMove) {
        pd.setTitle(R.string.move);
        pd.setMessage(mContext.getResources().getString(R.string.moving_file));
    } else {
        pd.setTitle(R.string.copy);
        pd.setMessage(mContext.getResources().getString(R.string.copying_file));
    }

    pd.setButton(DialogInterface.BUTTON_NEUTRAL, mContext.getResources().getString(R.string.run_in_background),
            (arg0, arg1) -> pd.dismiss());

    pd.show();

}
 
Example 3
Source File: MainActivity.java    From your-local-weather with GNU General Public License v3.0 6 votes vote down vote up
private void detectLocation() {
    if (WidgetRefreshIconService.isRotationActive) {
        return;
    }
    mProgressDialog = new ProgressDialog(MainActivity.this);
    mProgressDialog.setMessage(getString(R.string.progressDialog_gps_locate));
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setCancelable(false);
    mProgressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(android.R.string.cancel), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            try {
                dialog.dismiss();
            } catch (SecurityException e) {
                appendLog(MainActivity.this, TAG, "Cancellation error", e);
            }
        }
    });

    updateNetworkLocation();
    mProgressDialog.show();
    refreshDialogHandler = new Handler(Looper.getMainLooper());
}
 
Example 4
Source File: MaoniDoorbellListener.java    From maoni with MIT License 6 votes vote down vote up
FeedbackSenderTask(Feedback feedback) {
    this.feedback = feedback;
    alertDialog = new ProgressDialog(mActivity);
    alertDialog.setTitle(mWaitDialogTitle);
    alertDialog.setMessage(mWaitDialogMessage);
    alertDialog.setIndeterminate(false);
    alertDialog.setCancelable(false);
    alertDialog.setCanceledOnTouchOutside(false);
    alertDialog.setMax(100);
    alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, mWaitDialogCancelButtonText,
            new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            FeedbackSenderTask.this.cancel();
        }
    });
    alertDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mActivity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            alertDialog.show();
        }
    });
    this.properties = new HashMap<>();
    this.tags = new ArrayList<>();
}
 
Example 5
Source File: MainActivity.java    From arcgis-runtime-samples-android with Apache License 2.0 6 votes vote down vote up
/**
 * Shows a progress dialog for the given job.
 *
 * @param job to track progress from
 */
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);
}
 
Example 6
Source File: MainActivity.java    From android-task with Apache License 2.0 6 votes vote down vote up
private void showDialog() {
    mProgressDialog = new ProgressDialog(this);
    mProgressDialog.setMessage(getString(R.string.rotate_the_device));
    mProgressDialog.setCancelable(false);
    mProgressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(android.R.string.cancel), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (mTaskId != -1) {
                SimpleTask task = (SimpleTask) TaskExecutor.getInstance().getTask(mTaskId);
                if (task != null) {
                    task.cancel();
                }
            }
        }
    });
    mProgressDialog.show();
}
 
Example 7
Source File: FragmentTestActivity.java    From android-task with Apache License 2.0 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    ProgressDialog progressDialog = new ProgressDialog(getActivity());
    progressDialog.setMessage(getString(R.string.rotate_the_device));
    progressDialog.setCancelable(false);
    progressDialog.setIndeterminate(false);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(android.R.string.cancel), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (mTaskId != -1) {
                SimpleTask task = (SimpleTask) TaskExecutor.getInstance().getTask(mTaskId);
                if (task != null) {
                    task.cancel();
                }
            }
        }
    });

    return progressDialog;
}
 
Example 8
Source File: ShareTask.java    From geopackage-mapcache-android with MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void onPreExecute() {
    shareCopyDialog = new ProgressDialog(activity);
    shareCopyDialog
            .setMessage("Preparing internal GeoPackage for sharing");
    shareCopyDialog.setCancelable(false);
    shareCopyDialog.setIndeterminate(true);
    shareCopyDialog.setButton(ProgressDialog.BUTTON_NEGATIVE,
            "Cancel",
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    cancel(true);
                }
            });
    shareCopyDialog.show();
}
 
Example 9
Source File: ShareTask.java    From geopackage-mapcache-android with MIT License 6 votes vote down vote up
/**
 * pre execute - show dialog
 */
@Override
protected void onPreExecute() {
    saveDialog = new ProgressDialog(activity);
    saveDialog
            .setMessage("Saving GeoPackage to Downloads");
    saveDialog.setCancelable(false);
    saveDialog.setIndeterminate(true);
    saveDialog.setButton(ProgressDialog.BUTTON_NEGATIVE,
            "Cancel",
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    cancel(true);
                }
            });
    saveDialog.show();
}
 
Example 10
Source File: UploadFile.java    From BLEConnect with GNU General Public License v2.0 6 votes vote down vote up
public UploadFile(Context context, DropboxAPI<?> api, String dropboxPath,
        File file) {
    // We set the context this way so we don't accidentally leak activities
    mContext = context.getApplicationContext();

    mFileLen = file.length();
    mApi = api;
    mPath = dropboxPath;
    mFile = file;

    mDialog = new ProgressDialog(context);
    mDialog.setMax(100);
    mDialog.setMessage("Uploading " + file.getName());
    mDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mDialog.setProgress(0);
    mDialog.setButton("Cancel", new OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // This will cancel the putFile operation
            mRequest.abort();
        }
    });
    mDialog.show();
}
 
Example 11
Source File: ProgressDialogFragment.java    From arcgis-runtime-samples-android with Apache License 2.0 5 votes vote down vote up
@NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
  super.onCreateDialog(savedInstanceState);
  // create a dialog to show progress
  final ProgressDialog progressDialog = new ProgressDialog(getActivity());
  progressDialog.setTitle(mTitle);
  progressDialog.setMessage(mMessage);
  progressDialog.setIndeterminate(false);
  progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
  progressDialog.setMax(100);
  progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, mCancel, (dialog, which) -> onDismiss(dialog));
  return progressDialog;
}
 
Example 12
Source File: ProgressDialogFragment.java    From arcgis-runtime-samples-android with Apache License 2.0 5 votes vote down vote up
@NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
  super.onCreateDialog(savedInstanceState);
  // create a dialog to show progress
  final ProgressDialog progressDialog = new ProgressDialog(getActivity());
  progressDialog.setTitle(mTitle);
  progressDialog.setMessage(mMessage);
  progressDialog.setIndeterminate(false);
  progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
  progressDialog.setMax(100);
  progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, mCancel, (dialog, which) -> onDismiss(dialog));
  return progressDialog;
}
 
Example 13
Source File: MainActivity.java    From arcgis-runtime-samples-android with Apache License 2.0 5 votes vote down vote up
/**
 * Show progress UI elements.
 *
 * @param exportTileCacheJob used to track progress and cancel when required
 */
private void createProgressDialog(ExportTileCacheJob exportTileCacheJob) {

  ProgressDialog progressDialog = new ProgressDialog(this);
  progressDialog.setTitle("Export Tile Cache Job");
  progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
  progressDialog.setCanceledOnTouchOutside(false);
  progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel",
      (dialogInterface, i) -> exportTileCacheJob.cancel());
  progressDialog.show();

  exportTileCacheJob.addProgressChangedListener(() -> progressDialog.setProgress(exportTileCacheJob.getProgress()));
  exportTileCacheJob.addJobDoneListener(progressDialog::dismiss);
}
 
Example 14
Source File: Downloader.java    From AOSPBrowserInstaller with GNU General Public License v3.0 5 votes vote down vote up
protected void onPreExecute() {
    if (overrideFile)
        outputFile.delete();
    if (!outputFile.getParentFile().exists()) {
        outputFile.getParentFile().mkdir();
    }

    if (!URL.endsWith("/"))
        URL = URL + "/";
    if (!URL.startsWith("http://")
            && !URL.startsWith("https://"))
        URL = "http://" + URL;
    if (!hide) {
        downloadDialog = new ProgressDialog(mContext);
        downloadDialog.setTitle(mContext.getResources().getString(R.string.connecting));
        downloadDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        downloadDialog.setCancelable(false);
        downloadDialog.setMessage(URL);
        if (cancelable)
            downloadDialog.setButton(DialogInterface.BUTTON_NEGATIVE, mContext.getString(R.string.cancel), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    thisDownloader.cancel(false);
                    if (outputFile.exists())
                        outputFile.delete();
                }
            });
        downloadDialog.show();
    }
}
 
Example 15
Source File: LoadTilesTask.java    From geopackage-mapcache-android with MIT License 5 votes vote down vote up
/**
 * Load tiles
 *
 * @param activity
 * @param callback
 * @param active
 * @param geoPackage
 * @param tableName
 * @param tileGenerator
 */
private static void loadTiles(Activity activity, ILoadTilesTask callback,
                              GeoPackageDatabases active, GeoPackage geoPackage, String tableName, TileGenerator tileGenerator) {

    ProgressDialog progressDialog = new ProgressDialog(activity);
    final LoadTilesTask loadTilesTask = new LoadTilesTask(activity,
            callback, progressDialog, active);

    tileGenerator.setProgress(loadTilesTask);

    loadTilesTask.setTileGenerator(tileGenerator);

    progressDialog.setMessage(activity
            .getString(R.string.geopackage_create_tiles_label)
            + ": "
            + geoPackage.getName() + " - " + tableName);
    progressDialog.setCancelable(false);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setIndeterminate(false);
    progressDialog.setMax(tileGenerator.getTileCount());
    progressDialog.setButton(ProgressDialog.BUTTON_NEGATIVE,
            activity.getString(R.string.button_cancel_label),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    loadTilesTask.cancel(true);
                }
            });

    loadTilesTask.execute();
}
 
Example 16
Source File: PostingActivity.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
@Override
public void onSendPostStart(boolean progressMode) {
	progressDialog = new ProgressDialog(this);
	progressDialog.setCancelable(true);
	progressDialog.setCanceledOnTouchOutside(false);
	if (progressMode) {
		progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
		progressDialog.setProgressNumberFormat("%1$d / %2$d KB");
	}
	progressDialog.setOnCancelListener(sendPostCancelListener);
	progressDialog.setButton(ProgressDialog.BUTTON_POSITIVE, getString(R.string.action_minimize),
			sendPostMinimizeListener);
	onSendPostChangeProgressState(progressMode, SendPostTask.ProgressState.CONNECTING, -1, -1);
	progressDialog.show();
}
 
Example 17
Source File: MainActivity.java    From good-weather with GNU General Public License v3.0 5 votes vote down vote up
private void detectLocation() {
    boolean isGPSEnabled = locationManager.getAllProviders().contains(LocationManager.GPS_PROVIDER)
            && locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
    boolean isNetworkEnabled = locationManager.getAllProviders().contains(LocationManager.NETWORK_PROVIDER)
            && locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

    mProgressDialog = new ProgressDialog(MainActivity.this);
    mProgressDialog.setMessage(getString(R.string.progressDialog_gps_locate));
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setCancelable(false);
    mProgressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(android.R.string.cancel), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            try {
                locationManager.removeUpdates(mLocationListener);
            } catch (SecurityException e) {
                Log.e(TAG, "Cancellation error", e);
            }
        }
    });

    if (isNetworkEnabled) {
        networkRequestLocation();
        mProgressDialog.show();
    } else {
        if (isGPSEnabled) {
            gpsRequestLocation();
            mProgressDialog.show();
        } else {
            showSettingsAlert();
        }
    }
}
 
Example 18
Source File: DownloadTestFragment.java    From QuickDevFramework with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreateContentView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setContentView(R.layout.fragment_download_test, container);
    ButterKnife.bind(this, getContentView());
    progressDialog = new ProgressDialog(getActivity());
    progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "cancel", (dialog, which) -> {
        if (downloadTask != null) {
            downloadTask.cancel();
        }
        dialog.dismiss();
    });
    etUrl.setText("https://pkg1.zhimg.com/zhihu/futureve-app-zhihuwap-ca40fb89fbd4fb3a3884429e1c897fe2-release-6.23.0(1778).apk");
}
 
Example 19
Source File: PAudioRecorder.java    From PHONK with GNU General Public License v3.0 5 votes vote down vote up
@PhonkMethod(description = "Starts recording", example = "")
@PhonkMethodParam(params = {"showProgressBoolean"})
public PAudioRecorder record(String fileName) {
    init();

    recorder.setOutputFile(getAppRunner().getProject().getFullPathForFile(fileName));
    try {
        recorder.prepare();
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (showProgress && getActivity() != null) {
        mProgressDialog = new ProgressDialog(getActivity());
        mProgressDialog.setTitle("Record!");
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mProgressDialog.setButton(DialogInterface.BUTTON_POSITIVE, "Stop recording",
                (dialog, whichButton) -> {
                    mProgressDialog.dismiss();
                    stop();
                });

        mProgressDialog.setOnCancelListener(p1 -> stop());
        mProgressDialog.show();
    }

    recorder.start();

    return this;
}
 
Example 20
Source File: MeasurementActivity.java    From NoiseCapture with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onClick(View v) {
    Resources resources = activity.getResources();
    ImageButton buttonPause= (ImageButton) activity.findViewById(R.id.pauseBtn);
    buttonPause.setEnabled(true);
    ImageButton buttonrecord= (ImageButton) activity.findViewById(R.id.recordBtn);

    if (!activity.measurementService.isStoring()) {
        // Start recording
        buttonrecord.setImageResource(R.drawable.button_record_pressed);
        buttonrecord.setEnabled(false);
        activity.measurementService.startStorage();
        // Force service to stay alive even if this activity is killed (Foreground service)
        activity.startService(new Intent(activity, MeasurementService.class));
    } else {
        // Stop measurement
        activity.measurementService.stopRecording();

        // Show computing progress dialog
        ProgressDialog myDialog = new ProgressDialog(activity);
        if (!activity.measurementService.isCanceled()) {
            myDialog.setMessage(resources.getString(R.string.measurement_processlastsamples,
                    activity.measurementService.getAudioProcess().getRemainingNotProcessSamples()));
            myDialog.setCancelable(false);
            myDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
                    resources.getText(R.string.text_CANCEL_data_transfer),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                            activity.measurementService.cancel();
                        }
                    });
            myDialog.show();
        }

        // Launch processing end activity
        new Thread(new WaitEndOfProcessing(activity, myDialog)).start();
    }
    activity.initGuiState();
}