下面列出了android.app.ProgressDialog#setOnDismissListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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();
}
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();
}
@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);
}
@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();
}
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;
}
/**
* 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();
}
}