List of usage examples for android.app ProgressDialog show
public static ProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminate)
From source file:com.android.nobadgift.DashboardActivity.java
public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == 0) { if (resultCode == RESULT_OK) { final String scanResult = intent.getStringExtra("SCAN_RESULT"); progDialog = ProgressDialog.show(this, "", "Fetching information...", true); new Thread(new Runnable() { public void run() { runOnUiThread(new Runnable() { public void run() { retrieveProductInfo(scanResult); retrievedImage = doInBackground(imageURL); if (urlContent != null) { displayConfirmationDialog(); } else { trace("Item not found."); }/* w w w. jav a2 s.c om*/ } }); progDialog.dismiss(); } }).start(); } else if (resultCode == RESULT_CANCELED) { trace("Scanning aborted..."); } } }
From source file:com.example.snapcacheexample.SelectionFragment.java
private void handleAnnounce() { pendingAnnounce = false;/*from w w w . j a va2 s. c o m*/ Session session = Session.getActiveSession(); if (session == null || !session.isOpened()) { return; } List<String> permissions = session.getPermissions(); if (!permissions.containsAll(PERMISSIONS)) { pendingAnnounce = true; requestPublishPermissions(session); return; } // Show a progress dialog because sometimes the requests can take a while. progressDialog = ProgressDialog.show(getActivity(), "", getActivity().getResources().getString(R.string.progress_dialog_text), true); // Run this in a background thread since some of the populate methods may take // a non-trivial amount of time. AsyncTask<Void, Void, Response> task = new AsyncTask<Void, Void, Response>() { @Override protected Response doInBackground(Void... voids) { EatAction eatAction = GraphObject.Factory.create(EatAction.class); for (BaseListElement element : listElements) { element.populateOGAction(eatAction); } Request request = new Request(Session.getActiveSession(), POST_ACTION_PATH, null, HttpMethod.POST); request.setGraphObject(eatAction); return request.executeAndWait(); } @Override protected void onPostExecute(Response response) { onPostActionResponse(response); } }; task.execute(); }
From source file:com.jeremyhaberman.playgrounds.Playgrounds.java
/** * Display a "Loading nearby playgrounds..." dialog while the background * task is retrieving playground data//from ww w .java 2 s.c o m */ private void displayLoadingPlaygroundsProgressDialog() { progressDialog = ProgressDialog.show(Playgrounds.this, "", LOADING_NEARBY_PLAYGROUNDS, true); progressDialog.show(); }
From source file:net.reichholf.dreamdroid.activities.TimerListActivity.java
/** * Delete a timer by creating an <code>DeleteTimerTask</code> * /*from w w w.ja va 2s . c o m*/ * @param timer * The Timer to delete as <code>ExtendedHashMap</code> */ private void deleteTimer(ExtendedHashMap timer) { if (mProgress != null) { if (mProgress.isShowing()) { mProgress.dismiss(); } } ArrayList<NameValuePair> params = Timer.getDeleteParams(timer); mProgress = ProgressDialog.show(this, "", getText(R.string.cleaning_timerlist), true); execSimpleResultTask(new TimerDeleteRequestHandler(), params); }
From source file:com.example.polytech.orientatewatch.ForecastFragment.java
public void updateWeatherWatch() { FetchWeatherTask weatherTask = new FetchWeatherTask(); String range = MainActivity.getRayon(); String typePOI = MainActivity.getType(); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); String tspType = sharedPrefs.getString(getString(R.string.pref_trnspt_key), getString(R.string.pref_trnspt_pied)); String modeTsp;// w w w.j a va 2s .c om if (tspType.equals(getString(R.string.pref_trnspt_voiture))) { modeTsp = "driving"; } else { modeTsp = "walking"; } if (range != Utility.actualRange || modeTsp != Utility.actualTrspt || typePOI != Utility.actualType) { myProgressDialog = ProgressDialog.show(getActivity(), "", "Chargement", true); Utility.nextPageToken = null; Utility.actualRange = range; Utility.actualTrspt = modeTsp; Utility.actualType = typePOI; weatherTask.execute(range); sendMessage(WEAR_MESSAGE_PATH2, "Debut"); } }
From source file:com.sakisds.icymonitor.activities.ConnectionActivity.java
/** * Connect to URL// w ww. j a va2 s. co m * * @param url URL to connect. */ private void connect(final String url) { // Create client RequestParams params = new RequestParams("id", mSettings.getLong("device_id", -1)); // Create a dialog final ProgressDialog progress = ProgressDialog.show(this, "", getResources().getString(R.string.connecting), false); final Context context = this; // Send request mClient.get(url + "/auth", params, new JsonHttpResponseHandler() { @Override public void onSuccess(JSONObject response) { progress.dismiss(); try { String version = response.getString("Version"); if (version.equals(ACCEPTED_SERVER_VERSION)) { String auth = response.getString("Auth"); if (auth.equals("OK")) { Intent intent = new Intent(getBaseContext(), MainViewActivity.class); intent.putExtra(MainViewActivity.EXTRA_ADDRESS, url); startActivity(intent); } else { showErrorDialog(R.string.error_could_not_connect_title, R.string.error_authentication); } } else if (version.equals(UPDATE_SERVER_VERSION)) { showErrorDialog(R.string.error_could_not_connect_title, R.string.error_outdated_server_update); } else { showErrorDialog(R.string.error_outdated_server, R.string.error_outdated_server_long); } } catch (JSONException e) { showErrorDialog(R.string.error_could_not_connect_title, R.string.error_invalid_response); } } @Override public void onFailure(Throwable e, JSONObject response) { progress.dismiss(); showErrorDialog(R.string.error_could_not_connect_title, R.string.error_could_not_connect); } }); }
From source file:it.iziozi.iziozi.gui.IORemoteImageSearchActivity.java
private void searchImages(String queryString) { mRingProgressDialog = ProgressDialog.show(this, getString(R.string.please_wait), getString(R.string.search_in_progress), true); mPictograms = new ArrayList<IOPictogram>(); SharedPreferences prefs = getSharedPreferences(IOApplication.APPLICATION_NAME, Context.MODE_PRIVATE); prefs.getString(IOApplication.APPLICATION_LOCALE, Locale.getDefault().getLanguage()); RequestParams params = new RequestParams(); params.put("q", queryString); params.put("lang", Locale.getDefault().getLanguage()); IOApiClient.get("pictures", params, new JsonHttpResponseHandler() { @Override/*from w w w . j a va 2s .c o m*/ public void onStart() { super.onStart(); Log.d("http debug", getRequestURI().toString()); } @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { super.onSuccess(statusCode, headers, response); //something went wrong Toast.makeText(getApplicationContext(), getString(R.string.unexpected_response), Toast.LENGTH_SHORT) .show(); } @Override public void onFinish() { super.onFinish(); mRingProgressDialog.cancel(); } @Override public void onSuccess(int statusCode, Header[] headers, JSONArray response) { super.onSuccess(statusCode, headers, response); //Correct response int iter = response.length(); if (iter == 0) { mEmptyTextView.setVisibility(View.VISIBLE); } else { for (int i = 0; i < iter; i++) { try { JSONObject jsonObject = response.getJSONObject(i); IOPictogram pictogram = new IOPictogram(); pictogram.setId(jsonObject.getInt("id")); pictogram.setFilePath(jsonObject.getString("file")); pictogram.setUrl(jsonObject.getString("deepurl")); String text = jsonObject.getString("text"); pictogram.setDescription( text.substring(0, 1).toUpperCase() + text.substring(1).toLowerCase()); //TODO: add type or category mPictograms.add(pictogram); } catch (JSONException e) { e.printStackTrace(); } RemoteImagesGridAdapter gridAdapter = (RemoteImagesGridAdapter) mGridView.getAdapter(); gridAdapter.notifyDataSetChanged(); gridAdapter.notifyDataSetInvalidated(); } } } @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) { super.onFailure(statusCode, headers, throwable, errorResponse); //Timeout, 500, no connection Toast.makeText(getApplicationContext(), getString(R.string.request_error), Toast.LENGTH_SHORT) .show(); } }); }
From source file:net.reichholf.dreamdroid.activities.TimerListActivity.java
/** * CleanUp timer list by creating an <code>CleanupTimerListTask</code> *//*w w w . j av a2 s. c o m*/ private void cleanupTimerList() { if (mProgress != null) { if (mProgress.isShowing()) { mProgress.dismiss(); } } mProgress = ProgressDialog.show(this, "", getText(R.string.cleaning_timerlist), true); execSimpleResultTask(new TimerCleanupRequestHandler(), new ArrayList<NameValuePair>()); }
From source file:com.jakebasile.android.linkshrink.ShortenUrl.java
private void shortenWithGoogl(final String longUrl) { String display = String.format(getResources().getString(R.string.shortening_message), GOOGL); final ProgressDialog pd = ProgressDialog.show(ShortenUrl.this, getResources().getString(R.string.shortening_title), display, true); new Thread() { @Override/*from w w w . j a v a 2 s.co m*/ public void run() { try { JSONObject request = new JSONObject(); request.put("longUrl", longUrl); HttpClient httpClient = new DefaultHttpClient(); HttpPost post = new HttpPost(new URI(GOOGL_URL)); HttpEntity entity = new StringEntity(request.toString()); post.setEntity(entity); post.setHeader("Content-Type", "application/json"); HttpResponse response = httpClient.execute(post); if (response.getStatusLine().getStatusCode() == 200) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); response.getEntity().writeTo(stream); String jsonMessage = new String(stream.toByteArray()); Log.v("linkshrink", jsonMessage); JSONObject googlResponse = new JSONObject(jsonMessage); _shortUrl = googlResponse.getString("id"); } else { _shortUrl = null; } _handler.sendEmptyMessage(0); } catch (IOException ex) { _handler.sendEmptyMessage(1); Log.e("linkshrink", ex.getMessage()); } catch (URISyntaxException ex) { _handler.sendEmptyMessage(2); Log.e("linkshrink", ex.getMessage()); } catch (JSONException ex) { // nothing Log.e("linkshrink", ex.getMessage()); } finally { pd.dismiss(); } } }.start(); }
From source file:com.kii.world.MainActivity.java
private void loadObjects() { // default to an empty adapter mListAdapter.clear();/* ww w .j a v a 2 s . com*/ // show a progress dialog to the user mProgress = ProgressDialog.show(MainActivity.this, "", "Loading...", true); // create an empty KiiQuery (will retrieve all results, sorted by // creation date) KiiQuery query = new KiiQuery(null); query.sortByAsc("_created"); // define the bucket to query KiiBucket bucket = KiiUser.getCurrentUser().bucket(BUCKET_NAME); // perform the query bucket.query(new KiiQueryCallBack<KiiObject>() { // catch the callback's "done" request public void onQueryCompleted(int token, KiiQueryResult<KiiObject> result, Exception e) { // hide our progress UI element mProgress.dismiss(); // check for an exception (successful request if e==null) if (e == null) { // add the objects to the adapter (adding to the listview) List<KiiObject> objLists = result.getResult(); for (KiiObject obj : objLists) { mListAdapter.add(obj); } // tell the console and the user it was a success! Log.v(TAG, "Objects loaded: " + result.getResult().toString()); Toast.makeText(MainActivity.this, "Objects loaded", Toast.LENGTH_SHORT).show(); } // otherwise, something bad happened in the request else { // tell the console and the user there was a failure Log.v(TAG, "Error loading objects: " + e.getLocalizedMessage()); Toast.makeText(MainActivity.this, "Error loading objects: " + e.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); } } }, query); }