List of usage examples for android.app ProgressDialog setMessage
@Override public void setMessage(CharSequence message)
From source file:com.eleybourn.bookcatalogue.utils.SimpleTaskQueueProgressFragment.java
/** * Method, run in the UI thread, that updates the various dialog fields. *///w w w. j a v a2s .co m private void updateProgress() { ProgressDialog d = (ProgressDialog) getDialog(); if (d != null) { synchronized (this) { if (mMaxChanged) { d.setMax(mMax); mMaxChanged = false; } if (mNumberFormatChanged) { if (Build.VERSION.SDK_INT >= 11) { // Called in a separate function so we can set API attributes setDialogNumberFormat(d); } mNumberFormatChanged = false; } if (mMessageChanged) { d.setMessage(mMessage); mMessageChanged = false; } if (mProgressChanged) { d.setProgress(mProgress); mProgressChanged = false; } } } }
From source file:com.yi4all.rupics.ImageDetailActivity.java
private void initBtn() { topBarPanel = findViewById(R.id.image_top_bar); topBarPanel.setVisibility(View.GONE); popMenuPanel = findViewById(R.id.image_pop_menu); TextView tv = (TextView) findViewById(R.id.image_title_txt); tv.setText(issue.getCategory().getName() + "-" + issue.getName()); ImageView back = (ImageView) findViewById(R.id.image_back_btn); back.setOnClickListener(new OnClickListener() { @Override//from w w w.j a v a 2 s . co m public void onClick(View v) { finish(); } }); ImageView pop = (ImageView) findViewById(R.id.image_pop_btn); pop.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (popMenuPanel.getVisibility() == View.VISIBLE) { popMenuPanel.setVisibility(View.GONE); } else { popMenuPanel.setVisibility(View.VISIBLE); } } }); // final TextView wallpaperBtn = (TextView) findViewById(R.id.wallpaperBtn); final TextView slideshowBtn = (TextView) findViewById(R.id.slideshowBtn); final TextView shareBtn = (TextView) findViewById(R.id.shareBtn); final TextView downloadBtn = (TextView) findViewById(R.id.downloadBtn); // wallpaperBtn.setOnClickListener(new OnClickListener() { // public void onClick(View v) { // String img = imgList.get(imageSequence).getUrl(); // String path = Utils.convertUrl2Path(ImageDetailActivity.this, img); // if (path != null && new File(path).exists()) { // try { // ImageDetailActivity.this.setWallpaper(BitmapFactory.decodeFile(path)); // } catch (IOException e) { // e.printStackTrace(); // } // } else { // // give a tip to user // Utils.toastMsg(ImageDetailActivity.this, R.string.noImageWallpaper); // } // Utils.toastMsg(ImageDetailActivity.this, R.string.setWallpaperSuccess); // } // }); slideshowBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { isSlideshow = !isSlideshow; if (isSlideshow) { startSlideShow(); topBarPanel.setVisibility(View.GONE); popMenuPanel.setVisibility(View.GONE); slideshowBtn.setText(R.string.slideshow_pause); } else { topBarPanel.setVisibility(View.VISIBLE); slideshowBtn.setText(R.string.slideshow); } } }); shareBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // Intent intent = createShareIntent(); byte[] bytes = getCurrentImage(); if (bytes == null) { Utils.toastMsg(ImageDetailActivity.this, R.string.noImageShare); } else { // ImageDetailActivity.this.startActivity(intent); popMenuPanel.setVisibility(View.GONE); UMServiceFactory.shareTo(ImageDetailActivity.this, getString(R.string.shareImageMmsBody), bytes); } } }); downloadBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (getService().sureLimitation()) { popMenuPanel.setVisibility(View.GONE); final ProgressDialog pd = ProgressDialog.show(ImageDetailActivity.this, getString(R.string.waitTitle), getString(R.string.downloadAllImage), false, false); final Handler handler = new Handler() { int current = 0; int total = imgList.size(); int size = 0; @Override public void handleMessage(Message msg) { current++; pd.setMessage(getString(R.string.downloadAllImage) + current + "/" + total); if (msg.arg2 > 0) { size += msg.arg2; } if (current >= total) { if (size > 0) { getService().addUserConsumedKbytes(size); } pd.dismiss(); } } }; new Thread(new Runnable() { @Override public void run() { for (ImageModel im : imgList) { String imgUrl = im.getUrl(); String path = Utils.convertUrl2Path(ImageDetailActivity.this, imgUrl); util.runSaveUrl(path, imgUrl, handler); } } }).start(); } } }); }
From source file:com.example.android.camera2basic.fragments.Camera2BasicFragment.java
public void upload() { //Crea y muestra barra de progreso final ProgressDialog mProgressDialog = new ProgressDialog(getActivity()); mProgressDialog.setIndeterminate(false); mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); mProgressDialog.setMessage("Subiendo foto..."); mProgressDialog.show();/*from ww w. j a v a 2s .c o m*/ //Retrofit Retrofit retrofit = new Retrofit.Builder().baseUrl(FileUploadService.ENDPOINT) .addConverterFactory(GsonConverterFactory.create()).build(); // create upload service client FileUploadService service = retrofit.create(FileUploadService.class); // create RequestBody instance from file RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), mFile); // MultipartBody.Part is used to send also the actual file name MultipartBody.Part body = MultipartBody.Part.createFormData("fichero", mFile.getName(), requestFile); // finally, execute the request Call<ResponseBody> call = service.upload(body); call.enqueue(new Callback<ResponseBody>() { @Override public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { if (response.isSuccessful()) { mProgressDialog.hide();//Oculta progressDialog showToast("Upload picture success"); Log.v(TAG, "success"); } else { mProgressDialog.hide();//Oculta progressDialog showToast("Upload error:" + response.code()); Log.e(TAG, "Code: " + response.code()); } } @Override public void onFailure(Call<ResponseBody> call, Throwable t) { mProgressDialog.hide();//Oculta progressDialog showToast("Upload error:" + t.getMessage()); Log.e(TAG, "onfailure: " + t.getMessage()); } }); }
From source file:com.andrewshu.android.reddit.submit.SubmitLinkActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog = null;/*from w w w . ja v a 2 s. c o m*/ ProgressDialog pdialog; switch (id) { case Constants.DIALOG_LOGIN: dialog = new LoginDialog(this, mSettings, true) { @Override public void onLoginChosen(String user, String password) { removeDialog(Constants.DIALOG_LOGIN); new MyLoginTask(user, password).execute(); } }; break; // "Please wait" case Constants.DIALOG_LOGGING_IN: pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme())); pdialog.setMessage("Logging in..."); pdialog.setIndeterminate(true); pdialog.setCancelable(true); dialog = pdialog; break; case Constants.DIALOG_SUBMITTING: pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme())); pdialog.setMessage("Submitting..."); pdialog.setIndeterminate(true); pdialog.setCancelable(true); dialog = pdialog; break; default: break; } return dialog; }
From source file:com.juick.android.MessageMenu.java
public void translateToRussian(final String body, final Utils.Function<Void, String[]> callback) { final ProgressDialog mDialog = new ProgressDialog(activity); mDialog.setMessage("Google Translate..."); mDialog.setCancelable(true);/*www. ja v a 2s. c om*/ mDialog.setCanceledOnTouchOutside(true); final ArrayList<HttpGet> actions = new ArrayList<HttpGet>(); final String[] split = body.split("\\."); final String[] results = new String[split.length]; final int[] pieces = new int[] { 0 }; for (int i = 0; i < split.length; i++) { final String s = split[i]; if (s.trim().length() == 0) { results[i] = split[i]; synchronized (pieces) { pieces[0]++; if (pieces[0] == results.length) { mDialog.hide(); callback.apply(results); } } } else { Uri.Builder builder = new Uri.Builder().scheme("http").authority("translate.google.com") .path("translate_a/t"); builder = builder.appendQueryParameter("client", "at"); builder = builder.appendQueryParameter("v", "2.0"); builder = builder.appendQueryParameter("sl", "auto"); builder = builder.appendQueryParameter("tl", "ru"); builder = builder.appendQueryParameter("hl", "en_US"); builder = builder.appendQueryParameter("ie", "UTF-8"); builder = builder.appendQueryParameter("oe", "UTF-8"); builder = builder.appendQueryParameter("inputm", "2"); builder = builder.appendQueryParameter("source", "edit"); builder = builder.appendQueryParameter("text", s); final HttpClient client = new DefaultHttpClient(); // AndroidHttpClient.newInstance("AndroidTranslate/2.4.2 2.3.6 (gzip)", activity); final HttpGet verb = new HttpGet(builder.build().toString()); actions.add(verb); verb.setHeader("Accept-Charset", "UTF-8"); final int finalI = i; final Thread thread = new Thread("google translate") { @Override public void run() { final StringBuilder out = new StringBuilder(""); try { final String retval = client.execute(verb, new BasicResponseHandler()); out.setLength(0); out.append(retval); } catch (IOException e) { if (s.length() > 0) out.append("[error: " + e.toString() + "]"); Log.e("com.juickadvanced", "Error calling google translate", e); } finally { client.getConnectionManager().shutdown(); synchronized (pieces) { pieces[0]++; results[finalI] = out.toString(); if (pieces[0] == results.length) { activity.runOnUiThread(new Runnable() { @Override public void run() { mDialog.hide(); callback.apply(results); } }); } } } } }; thread.start(); } } mDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { for (HttpGet action : actions) { action.abort(); } synchronized (pieces) { pieces[0] = -10000; } mDialog.hide(); } }); mDialog.show(); }
From source file:info.staticfree.android.units.Units.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ABOUT: { final Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.dialog_about_title); builder.setIcon(R.drawable.icon); try {/*from w w w . ja va2 s .c o m*/ final WebView wv = new WebView(this); final InputStream is = getAssets().open("README.xhtml"); wv.loadDataWithBaseURL("file:///android_asset/", inputStreamToString(is), "application/xhtml+xml", "utf-8", null); wv.setBackgroundColor(0); builder.setView(wv); } catch (final IOException e) { builder.setMessage(R.string.err_no_load_about); e.printStackTrace(); } builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { setResult(RESULT_OK); } }); return builder.create(); } case DIALOG_ALL_UNITS: { final Builder b = new Builder(Units.this); b.setTitle(R.string.dialog_all_units_title); final ExpandableListView unitExpandList = new ExpandableListView(Units.this); unitExpandList.setId(android.R.id.list); final String[] groupProjection = { UsageEntry._ID, UsageEntry._UNIT, UsageEntry._FACTOR_FPRINT }; // any selection below will select from the grouping description final Cursor cursor = managedQuery(UsageEntry.CONTENT_URI_CONFORM_TOP, groupProjection, null, null, UnitUsageDBHelper.USAGE_SORT); unitExpandList.setAdapter(new UnitsExpandableListAdapter(cursor, this, android.R.layout.simple_expandable_list_item_1, android.R.layout.simple_expandable_list_item_1, new String[] { UsageEntry._UNIT }, new int[] { android.R.id.text1 }, new String[] { UsageEntry._UNIT }, new int[] { android.R.id.text1 })); unitExpandList.setCacheColorHint(0); unitExpandList.setOnChildClickListener(allUnitChildClickListener); b.setView(unitExpandList); return b.create(); } case DIALOG_UNIT_CATEGORY: { final Builder b = new Builder(new ContextThemeWrapper(this, android.R.style.Theme_Black)); final String[] from = { UsageEntry._UNIT }; final int[] to = { android.R.id.text1 }; b.setTitle("all units"); final String[] projection = { UsageEntry._ID, UsageEntry._UNIT, UsageEntry._FACTOR_FPRINT }; final Cursor c = managedQuery(UsageEntry.CONTENT_URI, projection, null, null, UnitUsageDBHelper.USAGE_SORT); dialogUnitCategoryList = new SimpleCursorAdapter(this, android.R.layout.select_dialog_item, c, from, to); b.setAdapter(dialogUnitCategoryList, dialogUnitCategoryOnClickListener); return b.create(); } case DIALOG_LOADING_UNITS: { final ProgressDialog pd = new ProgressDialog(this); pd.setIndeterminate(true); pd.setTitle(R.string.app_name); pd.setMessage(getText(R.string.dialog_loading_units)); return pd; } default: throw new IllegalArgumentException("Unknown dialog ID:" + id); } }
From source file:org.runnerup.export.SyncManager.java
private void doUpload(final Synchronizer synchronizer) { final ProgressDialog copySpinner = mSpinner; final SQLiteDatabase copyDB = DBHelper.getWritableDatabase(mContext); copySpinner.setMessage(getResources().getString(SyncMode.UPLOAD.getTextId(), synchronizer.getName())); new AsyncTask<Synchronizer, String, Synchronizer.Status>() { @Override// w w w. j a v a 2s. c o m protected Synchronizer.Status doInBackground(Synchronizer... params) { try { return params[0].upload(copyDB, mID); } catch (Exception ex) { ex.printStackTrace(); return Synchronizer.Status.ERROR; } } @Override protected void onPostExecute(Synchronizer.Status result) { switch (result) { case CANCEL: disableSynchronizer(disableSynchronizerCallback, synchronizer, false); return; case SKIP: case ERROR: case INCORRECT_USAGE: nextSynchronizer(); return; case OK: syncOK(synchronizer, copySpinner, copyDB, mID); nextSynchronizer(); return; case NEED_AUTH: // should be handled inside connect "loop" handleAuth(new Callback() { @Override public void run(String synchronizerName, Synchronizer.Status status) { switch (status) { case CANCEL: disableSynchronizer(disableSynchronizerCallback, synchronizer, false); return; case SKIP: case ERROR: case INCORRECT_USAGE: case NEED_AUTH: // should be handled inside // connect "loop" nextSynchronizer(); return; case OK: doUpload(synchronizer); return; } } }, synchronizer, result.authMethod); return; } } }.execute(synchronizer); }
From source file:org.runnerup.export.SyncManager.java
private void doSyncMulti(final Synchronizer synchronizer, final SyncMode mode, final SyncActivityItem activityItem) { final ProgressDialog copySpinner = mSpinner; final SQLiteDatabase copyDB = DBHelper.getWritableDatabase(mContext); copySpinner.setMessage(Long.toString(1 + syncActivitiesList.size()) + " remaining"); new AsyncTask<Synchronizer, String, Status>() { @Override/* w w w . j a v a 2 s .c o m*/ protected Synchronizer.Status doInBackground(Synchronizer... params) { try { switch (mode) { case UPLOAD: return synchronizer.upload(copyDB, activityItem.getId()); case DOWNLOAD: return synchronizer.download(copyDB, activityItem); } return Synchronizer.Status.ERROR; } catch (Exception ex) { ex.printStackTrace(); return Synchronizer.Status.ERROR; } } @Override protected void onPostExecute(Synchronizer.Status result) { switch (result) { case CANCEL: case ERROR: case INCORRECT_USAGE: case SKIP: break; case OK: syncOK(synchronizer, copySpinner, copyDB, result.activityId); break; case NEED_AUTH: handleAuth(new Callback() { @Override public void run(String synchronizerName, Synchronizer.Status status) { switch (status) { case CANCEL: case SKIP: case ERROR: case INCORRECT_USAGE: case NEED_AUTH: // should be handled inside // connect "loop" syncActivitiesList.clear(); syncNextActivity(synchronizer, mode); break; case OK: doSyncMulti(synchronizer, mode, activityItem); break; } } }, synchronizer, result.authMethod); break; } syncNextActivity(synchronizer, mode); } }.execute(synchronizer); }
From source file:org.matrix.console.activity.SettingsActivity.java
private void saveChanges(final MXSession session) { LinearLayout linearLayout = mLinearLayoutByMatrixId.get(session.getCredentials().userId); final String nameFromForm = getEditedUserName(session); final ApiCallback<Void> changeCallback = UIUtils.buildOnChangeCallback(this); final MyUser myUser = session.getMyUser(); final Button saveButton = (Button) linearLayout.findViewById(R.id.button_save); // disable the save button to avoid unexpected behaviour saveButton.setEnabled(false);/* w ww .jav a2 s. c o m*/ if (UIUtils.hasFieldChanged(myUser.displayname, nameFromForm)) { myUser.updateDisplayName(nameFromForm, new SimpleApiCallback<Void>(changeCallback) { @Override public void onSuccess(Void info) { super.onSuccess(info); updateSaveButton(saveButton); } }); } Uri newAvatarUri = mTmpThumbnailUriByMatrixId.get(session.getCredentials().userId); if (newAvatarUri != null) { Log.d(LOG_TAG, "Selected image to upload: " + newAvatarUri); ResourceUtils.Resource resource = ResourceUtils.openResource(this, newAvatarUri); if (resource == null) { Toast.makeText(SettingsActivity.this, getString(R.string.settings_failed_to_upload_avatar), Toast.LENGTH_LONG).show(); return; } final ProgressDialog progressDialog = ProgressDialog.show(this, null, getString(R.string.message_uploading), true); session.getContentManager().uploadContent(resource.contentStream, null, resource.mimeType, null, new ContentManager.UploadCallback() { @Override public void onUploadStart(String uploadId) { } @Override public void onUploadProgress(String anUploadId, int percentageProgress) { progressDialog.setMessage( getString(R.string.message_uploading) + " (" + percentageProgress + "%)"); } @Override public void onUploadComplete(String anUploadId, ContentResponse uploadResponse, final int serverResponseCode, String serverErrorMessage) { if (uploadResponse == null) { Toast.makeText(SettingsActivity.this, (null != serverErrorMessage) ? serverErrorMessage : getString(R.string.settings_failed_to_upload_avatar), Toast.LENGTH_LONG).show(); } else { Log.d(LOG_TAG, "Uploaded to " + uploadResponse.contentUri); myUser.updateAvatarUrl(uploadResponse.contentUri, new SimpleApiCallback<Void>(changeCallback) { @Override public void onSuccess(Void info) { super.onSuccess(info); // Reset this because its being set is how we know there's been a change mTmpThumbnailUriByMatrixId.remove(session.getCredentials().userId); updateSaveButton(saveButton); } }); } progressDialog.dismiss(); } }); } }