Java Code Examples for android.app.ProgressDialog#setCanceledOnTouchOutside()

The following examples show how to use android.app.ProgressDialog#setCanceledOnTouchOutside() . 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: ProgressFragmentDialog.java    From Bluefruit_LE_Connect_Android_V2 with MIT License 6 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    setRetainInstance(true);

    Bundle bundle = getArguments();
    if (bundle != null) {
        mMessage = bundle.getString(kParamMessage);
    }

    mDialog = new ProgressDialog(getActivity());
    mDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mDialog.setMax(100);
    mDialog.setCanceledOnTouchOutside(false);
    mDialog.setCancelable(true);

    updateUI();

    return mDialog;
}
 
Example 2
Source File: GetSeatsInfo.java    From kute with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.get_seats_info);
    back_nav=(ImageButton)findViewById(R.id.backNav);
    go_button=(Button)findViewById(R.id.goButton);
    back_nav.setOnClickListener(this);
    go_button.setOnClickListener(this);
    Bundle b=getIntent().getExtras();
    source_string=(String) b.get("source");
    destination_string=(String)b.get("destination");
    source_address=(String)b.get("sourceAdd");
    destination_address=(String)b.get("destinationAdd");
    dest_cords=(String)b.get("destinationCords");
    source_cords=(String)b.get("sourceCords");
    seats=(AppCompatEditText)findViewById(R.id.seatsAvailable);
    progress_dialog = new ProgressDialog(this);
    progress_dialog.setMessage("Registering Trip Request..");
    progress_dialog.setCanceledOnTouchOutside(false);
    request_queue= VolleySingleton.getInstance(getApplicationContext()).getRequestQueue();


    //Get the selected latlng for source and destination
}
 
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: UpdaterActivity.java    From Pix-Art-Messenger with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //set activity
    setContentView(R.layout.activity_updater);
    this.mTheme = findTheme();
    setTheme(this.mTheme);

    textView = findViewById(R.id.updater);

    mProgressDialog = new ProgressDialog(UpdaterActivity.this) {
        //show warning on back pressed
        @Override
        public void onBackPressed() {
            showCancelDialog();
        }
    };
    mProgressDialog.setMessage(getString(R.string.download_started));
    mProgressDialog.setProgressNumberFormat(null);
    mProgressDialog.setIndeterminate(true);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgressDialog.setCancelable(false);
    mProgressDialog.setCanceledOnTouchOutside(false);
}
 
Example 5
Source File: ApkDownloader.java    From android_gisapp with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onPreExecute() {
    super.onPreExecute();

    ControlHelper.lockScreenOrientation(mActivity);
    mProgress = new ProgressDialog(mActivity);
    mProgress.setMessage(mActivity.getString(R.string.message_loading));
    mProgress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    mProgress.setIndeterminate(true);
    mProgress.setCanceledOnTouchOutside(false);
    mProgress.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            cancel(true);
            Toast.makeText(mActivity, mActivity.getString(R.string.cancel_download), Toast.LENGTH_SHORT).show();
        }
    });
    mProgress.show();
}
 
Example 6
Source File: ResultActivity.java    From TextOcrExample with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(final View view) {
    mDialog = new ProgressDialog(view.getContext());
    mDialog.setMessage("识别中......");
    mDialog.setCanceledOnTouchOutside(false);
    mDialog.show();
    mRecTimeStart = System.currentTimeMillis();
    ThreadManager.getInstance().createLongPool().execute(new RecRunnable(mBitmaps[1], 1, mHandler));
    mRecogRunningCount++;
    ThreadManager.getInstance().createLongPool().execute(new RecRunnable(mBitmaps[2], 2, mHandler));
    mRecogRunningCount++;
    ThreadManager.getInstance().createLongPool().execute(new RecRunnable(mBitmaps[3], 3, mHandler));
    mRecogRunningCount++;
    ThreadManager.getInstance().createLongPool().execute(new RecRunnable(mBitmaps[4], 4, mHandler));
    mRecogRunningCount++;
    ThreadManager.getInstance().createLongPool().execute(new RecRunnable(mBitmaps[5], 5, mHandler));
    mRecogRunningCount++;
    ThreadManager.getInstance().createLongPool().execute(new RecRunnable(mBitmaps[6], 6, mHandler));
    mRecogRunningCount++;
}
 
Example 7
Source File: EaseContactListFragment.java    From Social with Apache License 2.0 5 votes vote down vote up
/**
 * 把user移入到黑名单
 */
protected void moveToBlacklist(final String username){
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st1 = getResources().getString(R.string.Is_moved_into_blacklist);
    final String st2 = getResources().getString(R.string.Move_into_blacklist_success);
    final String st3 = getResources().getString(R.string.Move_into_blacklist_failure);
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                //加入到黑名单
                EMClient.getInstance().contactManager().addUserToBlackList(username,false);
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2, 0).show();
                        refresh();
                    }
                });
            } catch (HyphenateException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st3, 0).show();
                    }
                });
            }
        }
    }).start();
    
}
 
Example 8
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 9
Source File: BrowserViewPagerActivity.java    From jmessage-android-uikit with MIT License 5 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        //点击返回时将选中的图片路径返回PickPictureActivity,更新选中的图片
        case R.id.return_btn:
            int pathArray[] = new int[mPathList.size()];
            for (int i = 0; i < pathArray.length; i++) {
                pathArray[i] = 0;
            }
            for (int j = 0; j < mSelectMap.size(); j++) {
                pathArray[mSelectMap.keyAt(j)] = 1;
            }
            Intent intent = new Intent();
            intent.putExtra("pathArray", pathArray);
            setResult(RESULT_CODE_SELECT_PICTURE, intent);
            finish();
            break;
        case R.id.pick_picture_send_btn:
            //TODO 发送图片
            mProgressDialog = new ProgressDialog(mContext);
            mProgressDialog.setMessage(mContext.getString(R.string.sending_hint));
            for (int i = 0; i < mSelectMap.size(); i++) {
                mPickedPath.add(mPathList.get(mSelectMap.keyAt(i)));
            }
            mProgressDialog.setCanceledOnTouchOutside(false);
            mProgressDialog.show();
            mPosition = mBrowserView.getCurrentItem();
            myHandler.sendEmptyMessageDelayed(SEND_PICTURE, 1000);
            break;
    }
}
 
Example 10
Source File: LoginActivity.java    From LLApp with Apache License 2.0 5 votes vote down vote up
@OnClick({R.id.rl_bg, R.id.loginButton})
void loginOnClick(View view) {
    switch (view.getId()){
        case R.id.rl_bg:
            hideSoftKeyboard();
            break;
        case R.id.loginButton:
            num = number.getText().toString().trim();
            pass = psw.getText().toString().trim();
            if (TextUtils.isEmpty(num)) {
                number.setError("请输入手机号");
                return;
            }
            if (TextUtils.isEmpty(pass)) {
                psw.setError("请输入密码");
                return;
            }
            if (!num.equals("18682176281") || !pass.equals("123")) {
                ToastUtil.showToast("用户名或密码错误");
                return;
            }
            final ProgressDialog dialog = new ProgressDialog(this);
            dialog.setMessage("登录中,请稍后...");
            dialog.setCanceledOnTouchOutside(false);
            dialog.show();
            hideSoftKeyboard();
            mHandler.postDelayed(() -> startAct(dialog), 2000);
            break;
    }
}
 
Example 11
Source File: RedPacketUtil.java    From LQRWeChat with MIT License 5 votes vote down vote up
/**
 * 拆红包方法
 *
 * @param activity      FragmentActivity(由于使用了DialogFragment,这个参数类型必须为FragmentActivity)
 * @param chatType      聊天类型
 * @param redPacketId   红包id
 * @param redPacketType 红包类型
 * @param receiverId    接收者id
 * @param messageDirect 消息的方向
 */
public static void openRedPacket(final FragmentActivity activity, final int chatType, String redPacketId, String redPacketType, String receiverId, String messageDirect) {
    final ProgressDialog progressDialog = new ProgressDialog(activity);
    progressDialog.setCanceledOnTouchOutside(false);
    RedPacketInfo redPacketInfo = new RedPacketInfo();
    redPacketInfo.redPacketId = redPacketId;
    redPacketInfo.messageDirect = messageDirect;
    redPacketInfo.chatType = chatType;
    RPRedPacketUtil.getInstance().openRedPacket(redPacketInfo, activity, new RPRedPacketUtil.RPOpenPacketCallback() {
        @Override
        public void onSuccess(String senderId, String senderNickname, String myAmount) {
            //领取红包成功 发送回执消息到聊天窗口
            Toast.makeText(activity, "拆红包成功,红包金额" + myAmount + "元", Toast.LENGTH_LONG).show();
        }

        @Override
        public void showLoading() {
            progressDialog.show();
        }

        @Override
        public void hideLoading() {
            progressDialog.dismiss();
        }

        @Override
        public void onError(String code, String message) {
            Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
        }
    });
}
 
Example 12
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 13
Source File: DailyFragment.java    From Cashew with Apache License 2.0 5 votes vote down vote up
@Override
public void initView(Bundle savedInstanceState) {
    mProgressDialog = new ProgressDialog(getActivity());
    mProgressDialog.setMessage("正在加载...");
    mProgressDialog.setCanceledOnTouchOutside(false);
    getBinding().setFrag(this);
    getHistoryDate();
}
 
Example 14
Source File: SearchChatPicVideoActivity.java    From imsdk-android with MIT License 5 votes vote down vote up
private void createProgressDialog(int max){
    dialog = new ProgressDialog(this);
    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);// 设置水平进度条
    dialog.setCancelable(true);// 设置是否可以通过点击Back键取消
    dialog.setCanceledOnTouchOutside(false);// 设置在点击Dialog外是否取消Dialog进度条
    dialog.setTitle("保存文件");
    dialog.setMax(max);
    dialog.show();
}
 
Example 15
Source File: LocalFileTask.java    From SoBitmap with Apache License 2.0 5 votes vote down vote up
public LocalFileTask(Activity activity, Spinner target) {
    this.activity = activity;
    this.target = target;
    progressDialog = new ProgressDialog(activity);
    progressDialog.setCancelable(false);
    progressDialog.setCanceledOnTouchOutside(false);
}
 
Example 16
Source File: ChatActivity.java    From school_shop with MIT License 5 votes vote down vote up
/**
 * 加入到黑名单
 * 
 * @param username
 */
private void addUserToBlacklist(final String username) {
    final ProgressDialog pd = new ProgressDialog(this);
       pd.setMessage(getString(R.string.Is_moved_into_blacklist));
       pd.setCanceledOnTouchOutside(false);
       pd.show();
    new Thread(new Runnable() {
           public void run() {
               try {
                   EMContactManager.getInstance().addUserToBlackList(username, false);
                   runOnUiThread(new Runnable() {
                       public void run() {
                           pd.dismiss();
                           Toast.makeText(getApplicationContext(), R.string.Move_into_blacklist_success, 0).show();
                       }
                   });
               } catch (EaseMobException e) {
                   e.printStackTrace();
                   runOnUiThread(new Runnable() {
                       public void run() {
                           pd.dismiss();
                           Toast.makeText(getApplicationContext(), R.string.Move_into_blacklist_failure, 0).show();
                       }
                   });
               }
           }
       }).start();
}
 
Example 17
Source File: GosBaseActivity.java    From Gizwits-SmartBuld_Android with MIT License 5 votes vote down vote up
/**
 * 设置ProgressDialog
 */
public void setProgressDialog() {
	progressDialog = new ProgressDialog(this);
	String loadingText = getString(R.string.loadingtext);
	progressDialog.setMessage(loadingText);
	progressDialog.setCanceledOnTouchOutside(false);
}
 
Example 18
Source File: ChanFragment.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
	ProgressDialog dialog = new ProgressDialog(getActivity());
	dialog.setCanceledOnTouchOutside(false);
	dialog.setMessage(getString(R.string.message_loading));
	return dialog;
}
 
Example 19
Source File: ShowBigImage.java    From school_shop with MIT License 4 votes vote down vote up
/**
 * 下载图片
 * 
 * @param remoteFilePath
 */
private void downloadImage(final String remoteFilePath, final Map<String, String> headers) {
	String str1 = getResources().getString(R.string.Download_the_pictures);
	pd = new ProgressDialog(this);
	pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
	pd.setCanceledOnTouchOutside(false);
	pd.setMessage(str1);
	pd.show();
	localFilePath = getLocalFilePath(remoteFilePath);
	final HttpFileManager httpFileMgr = new HttpFileManager(this, EMChatConfig.getInstance().getStorageUrl());
	final CloudOperationCallback callback = new CloudOperationCallback() {
		public void onSuccess(String resultMsg) {

			runOnUiThread(new Runnable() {
				@Override
				public void run() {
					DisplayMetrics metrics = new DisplayMetrics();
					getWindowManager().getDefaultDisplay().getMetrics(metrics);
					int screenWidth = metrics.widthPixels;
					int screenHeight = metrics.heightPixels;

					bitmap = ImageUtils.decodeScaleImage(localFilePath, screenWidth, screenHeight);
					if (bitmap == null) {
						image.setImageResource(default_res);
					} else {
						image.setImageBitmap(bitmap);
						ImageCache.getInstance().put(localFilePath, bitmap);
						isDownloaded = true;
					}
					if (pd != null) {
						pd.dismiss();
					}
				}
			});
		}

		public void onError(String msg) {
			Log.e("###", "offline file transfer error:" + msg);
			File file = new File(localFilePath);
			if (file.exists()&&file.isFile()) {
				file.delete();
			}
			runOnUiThread(new Runnable() {
				@Override
				public void run() {
					pd.dismiss();
					image.setImageResource(default_res);
				}
			});
		}

		public void onProgress(final int progress) {
			Log.d("ease", "Progress: " + progress);
			final String str2 = getResources().getString(R.string.Download_the_pictures_new);
			runOnUiThread(new Runnable() {
				@Override
				public void run() {
					
					pd.setMessage(str2 + progress + "%");
				}
			});
		}
	};

	new Thread(new Runnable() {
		@Override
		public void run() {
			httpFileMgr.downloadFile(remoteFilePath, localFilePath, headers, callback);
		}
	}).start();
}
 
Example 20
Source File: GosBaseActivity.java    From GOpenSource_AppKit_Android_AS with MIT License 3 votes vote down vote up
/**
 * 设置ProgressDialog
 * 
 * @param Message
 * @param Cancelable
 * @param CanceledOnTouchOutside
 */
public void setProgressDialog(String Message, boolean Cancelable, boolean CanceledOnTouchOutside) {
	progressDialog = new ProgressDialog(this);
	progressDialog.setMessage(Message);
	progressDialog.setCancelable(Cancelable);
	progressDialog.setCanceledOnTouchOutside(CanceledOnTouchOutside);
}