List of usage examples for android.app ProgressDialog show
public static ProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate, boolean cancelable, OnCancelListener cancelListener)
From source file:com.facebook.android.Places.java
private void fetchPlaces() { if (!isFinishing()) { dialog = ProgressDialog.show(Places.this, "", getString(R.string.nearby_places), true, true, new DialogInterface.OnCancelListener() { @Override/*w w w .j a v a 2s. c om*/ public void onCancel(DialogInterface dialog) { showToast("No places fetched."); } }); } /* * Source tag: fetch_places_tag */ Bundle params = new Bundle(); params.putString("type", "place"); try { params.putString("center", location.getString("latitude") + "," + location.getString("longitude")); } catch (JSONException e) { showToast("No places fetched."); return; } params.putString("distance", "1000"); Utility.mAsyncRunner.request("search", params, new placesRequestListener()); }
From source file:org.liberty.android.fantastischmemopro.downloader.DownloaderSS.java
protected void openCategory(final DownloadItem di) { mProgressDialog = ProgressDialog.show(this, getString(R.string.loading_please_wait), getString(R.string.loading_connect_net), true, true, new DialogInterface.OnCancelListener() { @Override//from ww w . jav a 2s .co m public void onCancel(DialogInterface dialog) { finish(); } }); new Thread() { public void run() { try { final List<DownloadItem> databaseList = retrieveDatabaseList(di); dlStack.push(dlAdapter.getList()); categoryIdStack.push(di.getExtras("id")); mHandler.post(new Runnable() { public void run() { dlAdapter.clear(); for (DownloadItem i : categoryList) { if (i.getExtras("pid").equals(di.getExtras("id"))) { dlAdapter.add(i); } } dlAdapter.addList(databaseList); listView.setSelection(0); mProgressDialog.dismiss(); } }); } catch (final Exception e) { mHandler.post(new Runnable() { public void run() { Log.e(TAG, "Error obtaining databases", e); new AlertDialog.Builder(DownloaderSS.this) .setTitle(getString(R.string.downloader_connection_error)) .setMessage( getString(R.string.downloader_connection_error_message) + e.toString()) .setNeutralButton(getString(R.string.back_menu_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { finish(); } }) .create().show(); } }); } } }.start(); }
From source file:net.exclaimindustries.geohashdroid.wiki.WikiPictureEditor.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); // Get some display metrics. We need to scale the gallery thumbnails // accordingly, else they look too small on big screens and too big on // small screens. We do this here to save calculations later, else // we'd be doing floating-point multiplication on EVERY SINGLE // THUMBNAIL, and we can't guarantee that won't be painful on every // Android phone. DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); THUMB_DIMEN = (int) (getResources().getDimensionPixelSize(R.dimen.nominal_icon_size) * metrics.density); Log.d(DEBUG_TAG, "Thumbnail dimensions: " + THUMB_DIMEN); mInfo = (Info) getIntent().getParcelableExtra(GeohashDroid.INFO); setContentView(R.layout.pictureselect); Button submitButton = (Button) findViewById(R.id.wikieditbutton); ImageButton galleryButton = (ImageButton) findViewById(R.id.GalleryButton); galleryButton.setOnClickListener(new View.OnClickListener() { @Override//from w w w . j a v a 2 s. c o m public void onClick(View v) { // Fire off the Gallery! startActivityForResult(new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI), REQUEST_PICTURE); } }); submitButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // We don't want to let the Activity handle the dialog. That WILL // cause it to show up properly and all, but after a configuration // change (i.e. orientation shift), it won't show or update any text // (as far as I know), as we can't reassign the handler properly. // So, we'll handle it ourselves. mProgress = ProgressDialog.show(WikiPictureEditor.this, "", "", true, true, WikiPictureEditor.this); mConnectionHandler = new PictureConnectionRunner(mProgressHandler, WikiPictureEditor.this); mWikiConnectionThread = new Thread(mConnectionHandler, "WikiConnectionThread"); mWikiConnectionThread.start(); } }); // We can set the background on the thumbnail view right away, even if // it's not actually visible. ImageView thumbView = (ImageView) findViewById(R.id.ThumbnailImage); thumbView.setBackgroundResource(R.drawable.gallery_selected_default); thumbView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); // Now, let's see if we have anything retained... try { RetainedThings retain = (RetainedThings) getLastNonConfigurationInstance(); if (retain != null) { // We have something retained! Thus, we need to construct the // popup and update it with the right status, assuming the // thread's still going. if (retain.thread != null && retain.thread.isAlive()) { mProgress = ProgressDialog.show(WikiPictureEditor.this, "", "", true, true, WikiPictureEditor.this); mConnectionHandler = retain.handler; mConnectionHandler.resetHandler(mProgressHandler); mWikiConnectionThread = retain.thread; } // And in any event, put the image info back up. mCurrentFile = retain.currentFile; mCurrentThumbnail = retain.thumbnail; mPictureLocation = retain.picLocation; setThumbnail(); } else { // If there was nothing to retain, maybe we've got a bundle. if (icicle != null) { if (icicle.containsKey(STORED_FILE)) mCurrentFile = icicle.getString(STORED_FILE); if (icicle.containsKey(STORED_LOCATION)) mPictureLocation = icicle.getParcelable(STORED_LOCATION); } // Rebuild it all in any event. buildThumbnail(); setThumbnail(); } } catch (Exception ex) { // If we got an exception, reset the thumbnail info with whatever // we have handy. buildThumbnail(); setThumbnail(); } // Rebuild the thumbnail and display it as need be. }
From source file:com.foundstone.certinstaller.CertInstallerActivity.java
/** * Tests the certificate chain by making a connection with or without the * proxy to the specified URL//from ww w . j av a 2s. com * * @param urlString * @param proxyIP * @param proxyPort */ private void testCertChain(final String urlString, final String proxyIP, final String proxyPort) { mCaCertInstalled = false; mSiteCertInstalled = false; if (TextUtils.isEmpty(urlString)) { Toast.makeText(getApplicationContext(), "URL is not set", Toast.LENGTH_SHORT).show(); Log.d(TAG, "URL is not set"); return; } pd = ProgressDialog.show(CertInstallerActivity.this, "Testing the cert chain", "", true, false, null); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { Log.d(TAG, "[+] Starting HTTPS request..."); HttpsURLConnection urlConnection = null; try { Log.d(TAG, "[+] Set URL..."); URL url = new URL("https://" + urlString); Log.d(TAG, "[+] Open Connection..."); // The user could have ProxyDroid running if (!TextUtils.isEmpty(proxyIP) && !TextUtils.isEmpty(proxyPort)) { Log.d(TAG, "[+] Using proxy " + proxyIP + ":" + proxyPort); Proxy proxy = new Proxy(Type.HTTP, new InetSocketAddress(proxyIP, Integer.parseInt(proxyPort))); urlConnection = (HttpsURLConnection) url.openConnection(proxy); } else { urlConnection = (HttpsURLConnection) url.openConnection(); } urlConnection.setReadTimeout(15000); Log.d(TAG, "[+] Get the input stream..."); InputStream in = urlConnection.getInputStream(); Log.d(TAG, "[+] Create a buffered reader to read the response..."); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); final StringBuilder builder = new StringBuilder(); String line = null; Log.d(TAG, "[+] Read all of the return...."); while ((line = reader.readLine()) != null) { builder.append(line); } mResult = builder.toString(); Log.d(TAG, mResult); // If everything passed we set these both to true mCaCertInstalled = true; mSiteCertInstalled = true; // Catch when the CA doesn't exist // Error: javax.net.ssl.SSLHandshakeException: // java.security.cert.CertPathValidatorException: Trust // anchor for certification path not found } catch (SSLHandshakeException e) { e.printStackTrace(); // Catch when the hostname does not verify // Line 224ish // http://source-android.frandroid.com/libcore/luni/src/main/java/libcore/net/http/HttpConnection.java // http://docs.oracle.com/javase/1.4.2/docs/api/javax/net/ssl/HostnameVerifier.html#method_detail } catch (IOException e) { // Found the CA cert installed but not the site cert mCaCertInstalled = true; e.printStackTrace(); } catch (Exception e) { Log.d(TAG, "[-] Some other exception: " + e.getMessage()); e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void result) { pd.dismiss(); if (mCaCertInstalled && !mSiteCertInstalled) { Log.d(TAG, Boolean.toString(mCaCertInstalled)); Toast.makeText(getApplicationContext(), "Found the CA cert installed", Toast.LENGTH_SHORT) .show(); setCaTextInstalled(); setSiteTextNotInstalled(); setFullTextNotInstalled(); } else if (mCaCertInstalled && mSiteCertInstalled) { Toast.makeText(getApplicationContext(), "Found the CA and Site certs installed", Toast.LENGTH_SHORT).show(); setCaTextInstalled(); setSiteTextInstalled(); setFullTextInstalled(); } else { Toast.makeText(getApplicationContext(), "No Certificates were found installed", Toast.LENGTH_SHORT).show(); setCaTextNotInstalled(); setSiteTextNotInstalled(); setFullTextNotInstalled(); } super.onPostExecute(result); } }.execute(); }
From source file:com.mobicage.rogerthat.registration.ContentBrandingRegistrationActivity.java
private void startQRScan() { T.UI();/*from w w w.j a v a2s . co m*/ if (!mService.isPermitted(Manifest.permission.CAMERA)) { ActivityCompat.requestPermissions(ContentBrandingRegistrationActivity.this, new String[] { Manifest.permission.CAMERA }, MY_PERMISSIONS_REQUEST_CAMERA); return; } if (mProgressDialog == null) { mProgressDialog = ProgressDialog.show(ContentBrandingRegistrationActivity.this, null, getString(R.string.opening_camera), true, true, null); } SafeRunnable runnable = new SafeRunnable() { @Override protected void safeRun() throws Exception { SystemUtils.showZXingActivity(ContentBrandingRegistrationActivity.this, MARKET_INSTALL_RESULT, ZXING_SCAN_QR_CODE_RESULT); } }; if (mServiceIsBound) { mService.postDelayedOnUIHandler(runnable, 250); } else { runnable.run(); } }
From source file:com.wishlist.Wishlist.java
public void uploadPhoto() { uploadCancelled = false;/* w w w .ja v a 2 s . c o m*/ dialog = ProgressDialog.show(Wishlist.this, "", getString(R.string.uploading_photo), true, true, new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { uploadCancelled = true; } }); /* * Upload photo to the server in a new thread */ new Thread() { public void run() { try { String postURL = HOST_SERVER_URL + HOST_PHOTO_UPLOAD_URI; HttpClient httpClient = new DefaultHttpClient(); HttpPost postRequest = new HttpPost(postURL); ByteArrayBody bab = new ByteArrayBody(imageBytes, "file_name_ignored"); MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); reqEntity.addPart("source", bab); postRequest.setEntity(reqEntity); HttpResponse response = httpClient.execute(postRequest); BufferedReader reader = new BufferedReader( new InputStreamReader(response.getEntity().getContent(), "UTF-8")); String sResponse; StringBuilder s = new StringBuilder(); while ((sResponse = reader.readLine()) != null) { s = s.append(sResponse); } /* * JSONObject is returned with image_name and image_url */ JSONObject jsonResponse = new JSONObject(s.toString()); mProductImageName = jsonResponse.getString("image_name"); mProductImageURL = jsonResponse.getString("image_url"); dismissDialog(); if (mProductImageName == null) { showToast(getString(R.string.error_uploading_photo)); return; } /* * photo upload finish, now publish to the timeline */ if (!uploadCancelled) { mHandler.post(new Runnable() { public void run() { addToTimeline(); } }); } } catch (Exception e) { Log.e(e.getClass().getName(), e.getMessage()); } } }.start(); }
From source file:com.android.browser.GoogleAccountLogin.java
private void startLogin() { saveLoginTime();// w w w . j a v a2 s .c o m mProgressDialog = ProgressDialog.show(mActivity, mActivity.getString(R.string.pref_autologin_title), mActivity.getString(R.string.pref_autologin_progress, mAccount.name), true /* indeterminate */, true /* cancelable */, this); mState = 1; // SID AccountManager.get(mActivity).getAuthToken(mAccount, "SID", null, mActivity, this, null); }
From source file:com.phonegap.Notification.java
/** * Show the spinner./*from w ww . j a v a 2s. c om*/ * * @param title Title of the dialog * @param message The message of the dialog */ public synchronized void activityStart(final String title, final String message) { if (this.spinnerDialog != null) { this.spinnerDialog.dismiss(); this.spinnerDialog = null; } final Notification notification = this; final PhonegapActivity ctx = this.ctx; Runnable runnable = new Runnable() { public void run() { notification.spinnerDialog = ProgressDialog.show(ctx, title, message, true, true, new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { notification.spinnerDialog = null; } }); } }; this.ctx.runOnUiThread(runnable); }
From source file:com.getkickbak.plugin.NotificationPlugin.java
/** * Show the spinner./*from w w w .ja v a 2s . co m*/ * * @param title * Title of the dialog * @param message * The message of the dialog */ public synchronized void activityStart(final String title, final String message) { if (this.spinnerDialog != null) { this.spinnerDialog.dismiss(); this.spinnerDialog = null; } final CordovaInterface cordova = this.cordova; Runnable runnable = new Runnable() { public void run() { NotificationPlugin.this.spinnerDialog = ProgressDialog.show(cordova.getActivity(), title, message, true, true, new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { NotificationPlugin.this.spinnerDialog = null; } }); } }; this.cordova.getActivity().runOnUiThread(runnable); }
From source file:com.foundstone.certinstaller.CertInstallerActivity.java
/** * Install the CA certificate. First check if we have the certificate, if * not open a connection and grab the certificates. Once the certificates * are found launch intent with an X509Cert to be installed to the KeyChain. * //from ww w . ja v a 2 s . c o m * @param urlString * @param proxyIP * @param proxyPort */ private void installCACert(String urlString, String proxyIP, String proxyPort) { if (TextUtils.isEmpty(urlString)) { Toast.makeText(getApplicationContext(), "URL is not set", Toast.LENGTH_SHORT).show(); Log.d(TAG, "URL is not set"); return; } else if (TextUtils.isEmpty(proxyIP)) { Toast.makeText(getApplicationContext(), "Port is not set", Toast.LENGTH_SHORT).show(); Log.d(TAG, "Port is not set"); return; } if (caCert == null) { pd = ProgressDialog.show(CertInstallerActivity.this, "Getting the CA certificate", "", true, false, null); grabCerts(urlString, proxyIP, proxyPort); try { while (caCert == null) { Thread.sleep(10); } } catch (InterruptedException e1) { e1.printStackTrace(); } pd.dismiss(); } try { installCert(caCert, CertUtils.INSTALL_CA_CODE); } catch (Exception e) { setCaTextNotInstalled(); e.printStackTrace(); } }