List of usage examples for android.app ProgressDialog setCancelable
public void setCancelable(boolean flag)
From source file:org.xwiki.android.authenticator.auth.AuthenticatorActivity.java
public void showProgress(CharSequence message, final AsyncTask asyncTask) { // To avoid repeatedly create if (mProgressDialog != null && mProgressDialog.isShowing()) { return;//from ww w .j a v a 2 s .c o m } final ProgressDialog dialog = new ProgressDialog(this); dialog.setMessage(message); dialog.setIndeterminate(true); dialog.setCancelable(true); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { Log.i(TAG, "user cancelling authentication"); if (asyncTask != null) { asyncTask.cancel(true); } } }); // We save off the progress dialog in a field so that we can dismiss // it later. mProgressDialog = dialog; mProgressDialog.show(); }
From source file:com.anandbibek.notifyme.MainActivity.java
@Override protected void onResume() { super.onResume(); if (!access) { ProgressDialog pDialog = new ProgressDialog(this); pDialog.setMessage(getResources().getString(R.string.main_check_checking)); pDialog.setMax(3000);/*from w ww . j a v a2s. co m*/ pDialog.setCancelable(false); pDialog.show(); stuff = new CheckAccessibilityTask(); stuff.execute(pDialog); return; } ListView mainFilterList = (ListView) this.findViewById(R.id.main_filter_list); String[] filterApps = new String[prefs.getNumberOfFilters() + 1]; for (int i = 0; i < filterApps.length; i++) { if (i == prefs.getNumberOfFilters()) { filterApps[i] = "JOKER"; } else { filterApps[i] = prefs.getFilterApp(i); } } ArrayAdapter<String> adapter = new MainFilterAdapter(this, filterApps); mainFilterList.setAdapter(adapter); mainFilterList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent editFilterIntent = new Intent(parent.getContext(), EditFilterActivity.class); if (position == prefs.getNumberOfFilters()) { editFilterIntent.setAction("new"); } else { editFilterIntent.setAction("edit"); editFilterIntent.putExtra("filter", position); } startActivity(editFilterIntent); } }); mainFilterList.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { final int filter = position; if (filter == prefs.getNumberOfFilters()) return true; final View finalView = view; AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext()); try { builder.setTitle(getResources().getString(R.string.main_remove_title1) + " " + ((TextView) ((RelativeLayout) view).getChildAt(1)).getText() + " " + getResources().getString(R.string.main_remove_title2)); builder.setIcon(((ImageView) ((RelativeLayout) view).getChildAt(0)).getDrawable()); } catch (Exception e) { } builder.setPositiveButton(R.string.main_remove_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { prefs.removeFilter(filter); startActivity(new Intent(finalView.getContext(), MainActivity.class).setAction("redraw")); } }); builder.setNegativeButton(R.string.main_remove_cancel, null); builder.show(); return true; } }); }
From source file:org.klnusbaum.udj.auth.AuthActivity.java
@Override protected Dialog onCreateDialog(int id) { final ProgressDialog dialog = new ProgressDialog(this); dialog.setMessage(getText(R.string.authenticating)); dialog.setIndeterminate(true);/* ww w .j a va 2 s .c o m*/ dialog.setCancelable(true); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { Log.i(TAG, "user cancelling authentication"); if (mAuthTask != null) { mAuthTask.cancel(true); } } }); // We save off the progress dialog in a field so that we can dismiss // it later. We can't just call dismissDialog(0) because the system // can lose track of our dialog if there's an orientation change. mProgressDialog = dialog; return dialog; }
From source file:com.ame.armymax.SearchActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); context = this; DataUser.context = context;/*from w w w .j a v a2 s. com*/ aq = new AQuery(this); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setTitle(""); query = getIntent().getStringExtra("query"); searchBox = (BootstrapEditText) findViewById(R.id.room_name); searchBox.setText(query); searchButton = (Button) findViewById(R.id.search_button); searchButton.setVisibility(View.GONE); intent = new Intent(this, ProfileActivity.class); searchButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query = searchBox.getEditableText().toString(); if (!query.equals("")) { String resultUrl = "http://www.armymax.com/api/?action=search&txt=" + query + "&startPoint=0&sizePage=50"; ProgressDialog dialog = new ProgressDialog(context); dialog.setIndeterminate(true); dialog.setCancelable(true); dialog.setInverseBackgroundForced(false); dialog.setCanceledOnTouchOutside(true); dialog.setTitle("Finding ..."); Log.e("searchurl", resultUrl); newSearch = true; aq.progress(dialog).ajax(resultUrl, JSONObject.class, context, "newSearchResultCb"); } } }); searchBox.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { query = searchBox.getEditableText().toString(); if (!query.equals("")) { String resultUrl = "http://www.armymax.com/api/?action=search&txt=" + query + "&startPoint=0&sizePage=20"; ProgressDialog dialog = new ProgressDialog(context); dialog.setIndeterminate(true); dialog.setCancelable(true); dialog.setInverseBackgroundForced(false); dialog.setCanceledOnTouchOutside(true); dialog.setTitle("Finding ..."); newSearch = true; Log.e("q", query); aq.ajax(resultUrl, JSONObject.class, context, "newSearchResultCb"); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }); String resultUrl = "http://www.armymax.com/api/?action=search&txt=" + query + "&startPoint=0&sizePage=50"; aq.ajax(resultUrl, JSONObject.class, this, "searchResultCb"); }
From source file:com.oonusave.coupon.MyMapStore.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog = null;//from w ww . j av a 2 s.c o m switch (id) { case PRO_DIALOG: ProgressDialog dialog1 = new ProgressDialog(this); dialog1.setMessage(AlertMsgUtil.getLoadingMessageText()); dialog1.setIndeterminate(true); dialog1.setCancelable(true); dialog = dialog1; } return dialog; }
From source file:ack.me.truconnectandroiddemo.DeviceInfoActivity.java
private void showDisconnectDialog() { final ProgressDialog dialog = new ProgressDialog(DeviceInfoActivity.this); String title = getString(R.string.disconnect_dialog_title); String msg = getString(R.string.disconnect_dialog_message); dialog.setIndeterminate(true);//Dont know how long disconnect could take..... dialog.setCancelable(false); mDisconnectDialog = dialog.show(DeviceInfoActivity.this, title, msg); mDisconnectDialog.setCancelable(false); }
From source file:com.github.guwenk.smuradio.SignInDialog.java
private void uploadFile() { if (filepath != null) { Log.d(AuthTag, "UPLOAD FILE " + filepath); final ProgressDialog progressDialog = new ProgressDialog(getActivity()); progressDialog.setTitle(getString(R.string.uploading)); progressDialog.setCancelable(false); progressDialog.show();/*ww w . j av a 2 s . com*/ int currentOrientation = getResources().getConfiguration().orientation; if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) { getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } else { getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } Log.d(AuthTag, "UPLOAD FILE progress dialog showing"); StorageReference musicRef = mStorageRef.child("audio/" + songTitle); Log.d(AuthTag, "UPLOAD FILE storage referense: " + musicRef); try { user = mAuth.getCurrentUser(); } catch (Exception ignored) { } StorageMetadata metadata = new StorageMetadata.Builder().setCustomMetadata("By", user.getUid()).build(); musicRef.putFile(filepath, metadata) .addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { // if upload success progressDialog.dismiss(); Toast.makeText(getActivity(), R.string.file_uploaded, Toast.LENGTH_SHORT).show(); alert.dismiss(); Log.d(AuthTag, "UPLOAD FILE success"); getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception exception) { // if upload failed progressDialog.dismiss(); Toast.makeText(getActivity(), getString(R.string.uploading_error) + exception.getMessage(), Toast.LENGTH_SHORT).show(); alert.dismiss(); Log.d(AuthTag, "UPLOAD FILE FAILED"); getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } }).addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() { @Override public void onProgress(UploadTask.TaskSnapshot taskSnapshot) { double progress = (100.0 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount(); try { progressDialog.setMessage((int) progress + getString(R.string.uploaded_procents)); Log.d(AuthTag, "UPLOAD FILE progress update: " + progress); } catch (Exception e) { e.printStackTrace(); } } }); } else { Toast.makeText(getActivity(), R.string.wrong_file, Toast.LENGTH_SHORT).show(); } }
From source file:com.clearcenter.mobile_demo.mdAuthenticatorActivity.java
protected Dialog onCreateDialog(int id) { final ProgressDialog dialog = new ProgressDialog(this); dialog.setMessage(getText(R.string.login_activity_authenticating)); dialog.setIndeterminate(true);/* w w w . ja va2 s. c om*/ dialog.setCancelable(true); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { Log.i(TAG, "user cancelling authentication"); if (auth_task != null) { auth_task.cancel(true); } } }); // We save off the progress dialog in a field so that we can dismiss // it later. We can't just call dismissDialog(0) because the system // can lose track of our dialog if there's an orientation change. progress_dialog = dialog; return dialog; }
From source file:com.owncloud.android.ui.activity.FileDetailActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog = null;/*from w ww. j av a 2 s . c om*/ switch (id) { case DIALOG_SHORT_WAIT: { ProgressDialog working_dialog = new ProgressDialog(this); working_dialog.setMessage(getResources().getString(R.string.wait_a_moment)); working_dialog.setIndeterminate(true); working_dialog.setCancelable(false); dialog = working_dialog; break; } default: dialog = null; } return dialog; }
From source file:com.artur.softwareproject.BluetoothConnectionListAdapter.java
@Override @NonNull/* w w w . j av a2s. c o m*/ public View getView(final int position, View convertView, @NonNull ViewGroup parent) { ViewHolder mViewHolder; if (convertView == null) { mViewHolder = new ViewHolder(); LayoutInflater ListInflater = LayoutInflater.from(getContext()); convertView = ListInflater.inflate(R.layout.bluetooth_list_pattern, parent, false); mViewHolder.bluetoothConnectionName = (TextView) convertView .findViewById(R.id.bluetooth_connection_name); mViewHolder.bluetoothConnectionStatus = (TextView) convertView .findViewById(R.id.bluetooth_connection_status); convertView.setTag(mViewHolder); convertView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //What happens if you press on the list items at the bluetooth activity. Animation animation = new AlphaAnimation(0.3f, 1.0f); animation.setDuration(1000); v.startAnimation(animation); intent = new Intent(contextActivity, BluetoothService.class); intent.putExtra("device", bDevices.get(position)); intent.putExtra("deviceList", bDevices); contextActivity.startService(intent); final ProgressDialog connectingDialog = new ProgressDialog(contextActivity); connectDialog = connectingDialog; connectingDialog.setMessage("Connecting..."); connectingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); connectingDialog.setCancelable(false); connectingDialog.show(); final ConnectionHandlerClass connectHandler = new ConnectionHandlerClass(bclaReference); connectThread = new Thread(new Runnable() { @Override public void run() { int stop = 0; int counter = 0; //Timeout after 10 seconds. while (stop == 0 && counter < 5) { stop = getConnected(); counter++; sleep(2000); } //Timeout occurred after 10s of waiting and stop is still 0. if (stop == 0 && counter == 4) { timeout = true; } connectHandler.sendEmptyMessage(0); } }); connectThread.start(); } }); } else { mViewHolder = (ViewHolder) convertView.getTag(); } mViewHolder.bluetoothConnectionName.setText(bluetoothAddress.get(position)); mViewHolder.bluetoothConnectionStatus.setText(bluetoothName.get(position)); return convertView; }