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

The following examples show how to use android.app.progressdialog#setOnDismissListener() . 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: ImportExportTask.java    From budget-watch with GNU General Public License v3.0 6 votes vote down vote up
protected void onPreExecute()
{
    progress = new ProgressDialog(activity);
    progress.setTitle(doImport ? R.string.importing : R.string.exporting);

    progress.setOnDismissListener(new DialogInterface.OnDismissListener()
    {
        @Override
        public void onDismiss(DialogInterface dialog)
        {
            ImportExportTask.this.cancel(true);
        }
    });

    progress.show();
}
 
Example 2
Source File: DatabaseCleanupTask.java    From budget-watch with GNU General Public License v3.0 6 votes vote down vote up
protected void onPreExecute()
{
    progress = new ProgressDialog(activity);
    progress.setTitle(R.string.cleaning);

    progress.setOnDismissListener(new DialogInterface.OnDismissListener()
    {
        @Override
        public void onDismiss(DialogInterface dialog)
        {
            DatabaseCleanupTask.this.cancel(true);
        }
    });

    progress.show();
}
 
Example 3
Source File: ExportGeoJSONTask.java    From android_maplibui with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void onPreExecute() {
    super.onPreExecute();
    if (mResultOnly)
        return;

    mProgress = new ProgressDialog(mActivity);
    mProgress.setTitle(R.string.export);
    mProgress.setMessage(mActivity.getString(R.string.preparing));
    mProgress.setCanceledOnTouchOutside(false);
    mProgress.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialogInterface) {
            mIsCanceled = true;
        }
    });
    mProgress.show();
    ControlHelper.lockScreenOrientation(mActivity);
}
 
Example 4
Source File: ExportGPXTask.java    From android_maplibui with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void onProgressUpdate(Void... values) {
    super.onProgressUpdate(values);

    mProgress = new ProgressDialog(mActivity);
    mProgress.setTitle(R.string.export);
    mProgress.setMessage(mActivity.getString(R.string.preparing));
    mProgress.setCanceledOnTouchOutside(false);
    mProgress.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialogInterface) {
            mIsCanceled = true;
        }
    });
    mProgress.show();
}
 
Example 5
Source File: ProgressDialogUtil.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
public static Dialog createProgressDialog(Context context, String title, String des,  DialogInterface.OnDismissListener dismissListener,boolean cancelable) {
    ProgressDialog builder = dialogBuilder(context, title, des);
    builder.setCancelable(cancelable);
    builder.setCanceledOnTouchOutside(true);
    builder.setOnDismissListener(dismissListener);
    return builder;
}
 
Example 6
Source File: SampleCacheDownloaderCustomUI.java    From osmdroid with Apache License 2.0 4 votes vote down vote up
/**
 * if true, start the job
 * if false, just update the dialog box
 */
private void updateEstimate(boolean startJob) {
    try {
        if (cache_east != null &&
                cache_west != null &&
                cache_north != null &&
                cache_south != null &&
                zoom_max != null &&
                zoom_min != null) {
            double n = Double.parseDouble(cache_north.getText().toString());
            double s = Double.parseDouble(cache_south.getText().toString());
            double e = Double.parseDouble(cache_east.getText().toString());
            double w = Double.parseDouble(cache_west.getText().toString());

            int zoommin = zoom_min.getProgress();
            int zoommax = zoom_max.getProgress();
            //nesw
            BoundingBox bb = new BoundingBox(n, e, s, w);
            int tilecount = mgr.possibleTilesInArea(bb, zoommin, zoommax);
            cache_estimate.setText(tilecount + " tiles");
            if (startJob) {
                if (downloadPrompt != null) {
                    downloadPrompt.dismiss();
                    downloadPrompt = null;
                }


                // prepare for a progress bar dialog ( do this first! )
                progressBar = new ProgressDialog(SampleCacheDownloaderCustomUI.this.getActivity());
                progressBar.setCancelable(true);
                progressBar.setMessage("Downloading ...");
                progressBar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
                progressBar.setProgress(0);
                progressBar.setCancelable(true);
                progressBar.setOnDismissListener(new DialogInterface.OnDismissListener() {
                    @Override
                    public void onDismiss(DialogInterface dialog) {
                        //cancel the job wit the dialog is closed
                        downloadingTask.cancel(true);
                        System.out.println("Pending jobs " + mgr.getPendingJobs());
                    }
                });
                //this triggers the download
                downloadingTask = mgr.downloadAreaAsyncNoUI(getActivity(), bb, zoommin, zoommax, SampleCacheDownloaderCustomUI.this);


            }

        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}