android.app.ProgressDialog#setOnCancelListener ( )源码实例Demo

下面列出了android.app.ProgressDialog#setOnCancelListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: WhereYouGo   文件: DownloadCartridgeActivity.java
public DownloadTask(final Context context, String username, String password) {
    super(context, username, password);
    progressDialog = new ProgressDialog(context);
    progressDialog.setMessage("");
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setMax(1);
    progressDialog.setIndeterminate(true);
    progressDialog.setCanceledOnTouchOutside(false);

    progressDialog.setCancelable(true);
    progressDialog.setOnCancelListener(arg0 -> {
        if (downloadTask != null && downloadTask.getStatus() != Status.FINISHED) {
            downloadTask.cancel(false);
            downloadTask = null;
            Log.i("down", "cancel");
            ManagerNotify.toastShortMessage(context, getString(R.string.cancelled));
        }
    });
}
 
源代码2 项目: mytracks   文件: DialogUtils.java
/**
 * Creates a progress dialog.
 *
 * @param spinner true to use the spinner style
 * @param context the context
 * @param messageId the progress message id
 * @param onCancelListener the cancel listener
 * @param formatArgs the format arguments for the message id
 */
private static ProgressDialog createProgressDialog(boolean spinner, final Context context,
    int messageId, DialogInterface.OnCancelListener onCancelListener, Object... formatArgs) {
  final ProgressDialog progressDialog = new ProgressDialog(context);
  progressDialog.setCancelable(true);
  progressDialog.setCanceledOnTouchOutside(false);
  progressDialog.setIcon(android.R.drawable.ic_dialog_info);
  progressDialog.setIndeterminate(true);
  progressDialog.setMessage(context.getString(messageId, formatArgs));
  progressDialog.setOnCancelListener(onCancelListener);
  progressDialog.setProgressStyle(spinner ? ProgressDialog.STYLE_SPINNER
      : ProgressDialog.STYLE_HORIZONTAL);
  progressDialog.setTitle(R.string.generic_progress_title);
  progressDialog.setOnShowListener(new DialogInterface.OnShowListener() {

      @Override
    public void onShow(DialogInterface dialog) {
      setDialogTitleDivider(context, progressDialog);
    }
  });
  return progressDialog;
}
 
源代码3 项目: PowerFileExplorer   文件: Search.java
@Override
protected void onPreExecute() {
    mCancelled=false;
    mProgressDialog = new ProgressDialog(mParent);
    mProgressDialog.setTitle(R.string.spinner_message);
    mProgressDialog.setMessage(mQuery);
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    mProgressDialog.setCancelable(true);
    mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

        public void onCancel(DialogInterface dialog)
        {
            mCancelled=true;
            cancel(false);
        }
    });
    mProgressDialog.show();
    mParent = null;
}
 
源代码4 项目: GravityBox   文件: WebServiceClient.java
public WebServiceClient(Context context, WebServiceTaskListener<T> listener) {
    mContext = context;
    mListener = listener;
    if (mContext == null || mListener == null) { 
        throw new IllegalArgumentException();
    }

    mProgressDialog = new ProgressDialog(mContext);
    mProgressDialog.setMessage(mContext.getString(R.string.wsc_please_wait));
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setCancelable(true);
    mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dlgInterface) {
            abortTaskIfRunning();
        }
    });

    mHash = getAppSignatureHash(mContext);
}
 
源代码5 项目: PowerFileExplorer   文件: TextFrag.java
@Override
protected void onPreExecute() {
    mProgressDialog = new ProgressDialog(mParent);
    mProgressDialog.setTitle(R.string.spinner_message);
    // mProgressDialog.setMessage(R.string.spinner_message);
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    mProgressDialog.setCancelable(false);
    mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        public void onCancel(DialogInterface dialog) {
        }
    });
    mProgressDialog.show();
    mChangeCancel = true;
    mParent = null;
}
 
源代码6 项目: android-lockpattern   文件: LoadingDialog.java
/**
 * Creates new instance.
 * 
 * @param context
 *            the context.
 * @param cancelable
 *            whether the user can cancel the dialog by tapping outside of
 *            it, or by pressing Back button.
 * @param msg
 *            the message to display.
 */
public LoadingDialog(Context context, boolean cancelable, CharSequence msg) {
    mDialog = new ProgressDialog(context);
    mDialog.setCancelable(cancelable);
    mDialog.setMessage(msg);
    mDialog.setIndeterminate(true);

    if (cancelable) {
        mDialog.setCanceledOnTouchOutside(true);
        mDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                cancel(true);
            }// onCancel()

        });
    }
}
 
源代码7 项目: Dainty   文件: DecompressionActivity.java
private void initData() {
    mDialog=new ProgressDialog(this);
    mDialog.setCanceledOnTouchOutside(false);
    mDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            finish();
        }
    });
    mDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    mDialog.setTitle("正在解析压缩包");
    mDialog.setMessage("请稍等...");
    mDialog.show();
    adapter = new CompressionListAdapter(this, data);
    switch (FileUtil.getExtensionName(handleFilePath)) {
        case "zip":
            type = "zip";
            presenter.resolveZip(handleFilePath);
            break;
        case "rar":
            type = "rar";
            presenter.resolveRar(handleFilePath);
            break;
    }
}
 
源代码8 项目: JotaTextEditor   文件: Search.java
@Override
protected void onPreExecute() {
    mCancelled=false;
    mProgressDialog = new ProgressDialog(mParent);
    mProgressDialog.setTitle(R.string.spinner_message);
    mProgressDialog.setMessage(mQuery);
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    mProgressDialog.setCancelable(true);
    mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

        public void onCancel(DialogInterface dialog)
        {
            mCancelled=true;
            cancel(false);
        }
    });
    mProgressDialog.show();
    mParent = null;
}
 
源代码9 项目: physical-web   文件: BluetoothSite.java
/**
 * Connects to the Gatt service of the device to download a web page and displays a progress bar
 * for the title.
 * @param deviceAddress The mac address of the bar
 * @param title The title of the web page being downloaded
 */
public void connect(String deviceAddress, String title) {
  running = true;
  String progressTitle = activity.getString(R.string.page_loading_title) + " " + title;
  progress = new ProgressDialog(activity);
  progress.setCancelable(true);
  progress.setOnCancelListener(new OnCancelListener() {
    @Override
    public void onCancel(DialogInterface dialogInterface) {
      Log.i(TAG, "Dialog box canceled");
      close();
    }
  });
  progress.setTitle(progressTitle);
  progress.setMessage(activity.getString(R.string.page_loading_message));
  progress.show();
  activity.runOnUiThread(new Runnable() {
    @Override
    public void run() {
      mBluetoothGatt = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(deviceAddress)
          .connectGatt(activity, false, BluetoothSite.this);
    }
  });
}
 
源代码10 项目: JotaTextEditor   文件: Main.java
@Override
protected void onPreExecute() {
    mProgressDialog = new ProgressDialog(mParent);
    mProgressDialog.setTitle(R.string.spinner_message);
    // mProgressDialog.setMessage(R.string.spinner_message);
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    mProgressDialog.setCancelable(false);
    mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        public void onCancel(DialogInterface dialog) {
        }
    });
    mProgressDialog.show();
    mChangeCancel = true;
    mParent = null;
}
 
源代码11 项目: android-common-utils   文件: WeixinUtil.java
private static ProgressDialog show(Context context, CharSequence title,
                                  CharSequence message, boolean indeterminate,
                                  boolean cancelable, DialogInterface.OnCancelListener cancelListener) {
    ProgressDialog dialog = new ProgressDialog(context,ProgressDialog.THEME_HOLO_LIGHT);
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.setIndeterminate(indeterminate);
    dialog.setCancelable(cancelable);
    dialog.setOnCancelListener(cancelListener);
    dialog.show();
    return dialog;
}
 
源代码12 项目: Overchan-Android   文件: CustomThemeListActivity.java
private ProgressDialog showProgressDialog(final CancellableTask task) {
    ProgressDialog progressDialog = new ProgressDialog(this);
    progressDialog.setMessage(getString(R.string.custom_themes_loading));
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            task.cancel();
        }
    });
    progressDialog.show();
    return progressDialog;
}
 
源代码13 项目: Dashchan   文件: DialogUnit.java
public PerformSendCallback(int localArchiveMax) {
	Context context = uiManager.getContext();
	dialog = new ProgressDialog(context);
	if (localArchiveMax >= 0) {
		dialog.setMessage(context.getString(R.string.message_processing_data));
		dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
		dialog.setMax(localArchiveMax);
	} else {
		dialog.setMessage(context.getString(R.string.message_sending));
	}
	dialog.setCanceledOnTouchOutside(false);
	dialog.setOnCancelListener(this);
	dialog.show();
}
 
源代码14 项目: NekoSMS   文件: DialogAsyncTask.java
@Override
protected void onPreExecute() {
    ProgressDialog dialog = new ProgressDialog(mContext);
    dialog.setMessage(mContext.getString(mProgressMessageId));
    dialog.setIndeterminate(true);
    dialog.setCancelable(mCancelable);
    if (mCancelable) {
        dialog.setOnCancelListener(this);
    }
    dialog.show();
    mDialog = dialog;
}
 
源代码15 项目: awesomesauce-rfduino   文件: BluetoothLEStack.java
/** Connect to a chosen Bluetooth Device using whatever BLE Stack is available. **/
public static BluetoothLEStack connectToBluetoothLEStack(BluetoothDevice device, Activity hostActivity, String uuidStringRepresentation, OnCancelListener onCancelConnectionAttempt){
	bluetoothConnectionWaitWindow = new ProgressDialog(hostActivity);
	bluetoothConnectionWaitWindow.setTitle("Connecting to Bluetooth Radio " + device.getAddress());
	bluetoothConnectionWaitWindow.setMessage("Please wait...");
	bluetoothConnectionWaitWindow.setCancelable(false);
	
	if (onCancelConnectionAttempt != null){
		bluetoothConnectionWaitWindow.setCancelable(true);
		bluetoothConnectionWaitWindow.setOnCancelListener(onCancelConnectionAttempt);
	}
	bluetoothConnectionWaitWindow.setIndeterminate(true);
	bluetoothConnectionWaitWindow.show();
	
	
	if (singleton != null){
		singleton.disconnect();
		singleton.connect(device, hostActivity);
		
	} else {
	
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2){
		singleton =  new AndroidBleStack(device, null, hostActivity);
		
	} else {
		//See if Samsung (Broadcom-based) Bluetooth Low Energy stack will work- works on Android 4.1 and 4.2
		singleton = new SamsungBleStack(device, hostActivity);
	}
	}
	return singleton;
}
 
private void getNC() {
	List<NameValuePair> targVar = new ArrayList<NameValuePair>();
	targVar.add(Wenku8Interface.getNovelContent(currentAid, currentCid,
			GlobalConfig.getFetchLanguage()));

	final asyncNovelContentTask ast = new asyncNovelContentTask();
	ast.execute(targVar);

	pDialog = new ProgressDialog(parentActivity);
	pDialog.setTitle(getResources().getString(R.string.load_status));
	pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
	pDialog.setCancelable(true);
	pDialog.setOnCancelListener(new OnCancelListener() {
		@Override
		public void onCancel(DialogInterface dialog) {
			// TODO Auto-generated method stub
			ast.cancel(true);
			pDialog.dismiss();
			pDialog = null;
		}

	});
	pDialog.setMessage(getResources().getString(R.string.load_loading));
	pDialog.setProgress(0);
	pDialog.setMax(1);
	pDialog.show();

	return;
}
 
源代码17 项目: DanDanPlayForAndroid   文件: CommJsonObserver.java
public CommJsonObserver(LifecycleOwner lifecycleOwner, ProgressDialog progressDialog) {
    this.lifecycleOwner = lifecycleOwner;
    this.progressDialog = progressDialog;
    progressDialog.setOnCancelListener(dialog -> mDisposable.dispose());
}
 
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_qiscus_photo_viewer);

    presenter = new QiscusPhotoViewerPresenter(this);

    toolbar = findViewById(R.id.toolbar);
    tvTitle = findViewById(R.id.tv_title);
    viewPager = findViewById(R.id.view_pager);
    progressBar = findViewById(R.id.progress_bar);
    senderName = findViewById(R.id.sender_name);
    date = findViewById(R.id.date);
    ImageButton shareButton = findViewById(R.id.action_share);
    infoPanel = findViewById(R.id.info_panel);
    fadein = AnimationUtils.loadAnimation(this, R.anim.qiscus_fadein);
    fadeout = AnimationUtils.loadAnimation(this, R.anim.qiscus_fadeout);

    progressDialog = new ProgressDialog(this);
    progressDialog.setMessage(getString(R.string.qiscus_downloading));
    progressDialog.setMax(100);
    progressDialog.setIndeterminate(false);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setOnCancelListener(dialog -> {
        presenter.cancelDownloading();
        showError(getString(R.string.qiscus_redownload_canceled));
        if (ongoingDownload != null) {
            ongoingDownload.setDownloadingListener(null);
            ongoingDownload.setProgressListener(null);
        }
    });

    findViewById(R.id.back).setOnClickListener(v -> onBackPressed());
    setSupportActionBar(toolbar);
    viewPager.addOnPageChangeListener(this);

    resolveData(savedInstanceState);

    presenter.loadQiscusPhotos(qiscusComment.getRoomId());

    if (!Qiscus.getChatConfig().isEnableShareMedia()) {
        shareButton.setVisibility(View.GONE);
    }

    shareButton.setOnClickListener(v -> {
        Pair<QiscusComment, File> qiscusPhoto = qiscusPhotos.get(position);
        shareImage(qiscusPhoto.second);
    });
}
 
public CommOtherDataObserver(LifecycleOwner lifecycleOwner, ProgressDialog progressDialog) {
    this.lifecycleOwner = lifecycleOwner;
    this.progressDialog = progressDialog;
    progressDialog.setOnCancelListener(dialog -> mDisposable.dispose());
}
 
源代码20 项目: kognitivo   文件: WebDialog.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    spinner = new ProgressDialog(getContext());
    spinner.requestWindowFeature(Window.FEATURE_NO_TITLE);
    spinner.setMessage(getContext().getString(R.string.com_facebook_loading));
    spinner.setOnCancelListener(new OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialogInterface) {
            cancel();
        }
    });

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    contentFrameLayout = new FrameLayout(getContext());

    // First calculate how big the frame layout should be
    resize();
    getWindow().setGravity(Gravity.CENTER);

    // resize the dialog if the soft keyboard comes up
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

    /* Create the 'x' image, but don't add to the contentFrameLayout layout yet
     * at this point, we only need to know its drawable width and height
     * to place the webview
     */
    createCrossImage();

    /* Now we know 'x' drawable width and height,
     * layout the webview and add it the contentFrameLayout layout
     */
    int crossWidth = crossImageView.getDrawable().getIntrinsicWidth();

    setUpWebView(crossWidth / 2 + 1);

    /* Finally add the 'x' image to the contentFrameLayout layout and
    * add contentFrameLayout to the Dialog view
    */
    contentFrameLayout.addView(crossImageView, new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

    setContentView(contentFrameLayout);
}