List of usage examples for android.app ProgressDialog setMessage
@Override public void setMessage(CharSequence message)
From source file:com.cellbots.logger.LoggerActivity.java
@Override public void onPrepareDialog(int id, Dialog dialog, Bundle bundle) { super.onPrepareDialog(id, dialog, bundle); if (id != PROGRESS_ID) { return;//from w w w .j av a2 s . c o m } final ProgressDialog progressDialog = (ProgressDialog) dialog; progressDialog.setMessage("Processing..."); final Handler handler = new Handler() { @Override public void handleMessage(android.os.Message msg) { int done = msg.getData().getInt("percentageDone"); String status = msg.getData().getString("status"); progressDialog.setProgress(done); progressDialog.setMessage(status); if (mRemoteControl != null) { mRemoteControl.broadcastMessage("Zipping Progress: " + done + "%\n"); } } }; zipperThread = new Thread() { @Override public void run() { if (useZip) { ZipItUpRequest request = new ZipItUpRequest(); String directoryName = application.getLoggerPathPrefix(); request.setInputFiles(new FileListFetcher().getFilesAndDirectoriesInDir(directoryName)); request.setOutputFile(directoryName + "/logged-data.zip"); request.setMaxOutputFileSize(MAX_OUTPUT_ZIP_CHUNK_SIZE); request.setDeleteInputfiles(true); request.setCompressionLevel(Deflater.NO_COMPRESSION); try { new ZipItUpProcessor(request).chunkIt(handler); } catch (IOException e) { Log.e("Oh Crap!", "IoEx", e); } } // closing dialog progressDialog.dismiss(); application.generateNewFilePathUniqueIdentifier(); // TODO: Need to deal with empty directories that are created if // another recording // session is never started. initSensorLogFiles(); if (mCamcorderView != null) { try { mCamcorderView.startPreview(); if (mRemoteControl != null) mRemoteControl.broadcastMessage("*** Packaging Finished: OK to start ***\n"); } catch (RuntimeException e) { e.printStackTrace(); runOnUiThread(new Runnable() { // @Override @Override public void run() { Toast.makeText(getApplicationContext(), "Camera hardware error. Please restart the application.", Toast.LENGTH_LONG) .show(); } }); finish(); return; } } } }; zipperThread.start(); }
From source file:org.runnerup.export.UploadManager.java
private void doUploadMulti(final Uploader uploader, final long id) { final ProgressDialog copySpinner = mSpinner; final SQLiteDatabase copyDB = mDBHelper.getWritableDatabase(); copySpinner.setMessage(Long.toString(1 + uploadActivities.size()) + " remaining"); new AsyncTask<Uploader, String, Uploader.Status>() { @Override/*from w ww .java 2 s. co m*/ protected Uploader.Status doInBackground(Uploader... params) { try { return uploader.upload(copyDB, id); } catch (Exception ex) { ex.printStackTrace(); return Uploader.Status.ERROR; } } @Override protected void onPostExecute(Uploader.Status result) { switch (result) { case CANCEL: case ERROR: case INCORRECT_USAGE: case SKIP: break; case OK: uploadOK(uploader, copySpinner, copyDB, id); break; case NEED_AUTH: handleAuth(new Callback() { @Override public void run(String uploaderName, org.runnerup.export.Uploader.Status status) { switch (status) { case CANCEL: case SKIP: case ERROR: case INCORRECT_USAGE: case NEED_AUTH: // should be handled inside // connect "loop" uploadActivities.clear(); uploadNextActivity(uploader); break; case OK: doUploadMulti(uploader, id); break; } } }, uploader, result.authMethod); break; } uploadNextActivity(uploader); } }.execute(uploader); }
From source file:org.runnerup.export.UploadManager.java
private void doUpload(final Uploader uploader) { final ProgressDialog copySpinner = mSpinner; final SQLiteDatabase copyDB = mDBHelper.getWritableDatabase(); copySpinner.setMessage("Uploading " + uploader.getName()); new AsyncTask<Uploader, String, Uploader.Status>() { @Override/*from w w w . j av a 2s. c o m*/ protected Uploader.Status doInBackground(Uploader... params) { try { return params[0].upload(copyDB, mID); } catch (Exception ex) { ex.printStackTrace(); return Uploader.Status.ERROR; } } @Override protected void onPostExecute(Uploader.Status result) { switch (result) { case CANCEL: disableUploader(disableUploaderCallback, uploader, false); return; case SKIP: case ERROR: case INCORRECT_USAGE: nextUploader(); return; case OK: uploadOK(uploader, copySpinner, copyDB, mID); nextUploader(); return; case NEED_AUTH: // should be handled inside connect "loop" handleAuth(new Callback() { @Override public void run(String uploaderName, org.runnerup.export.Uploader.Status status) { switch (status) { case CANCEL: disableUploader(disableUploaderCallback, uploader, false); return; case SKIP: case ERROR: case INCORRECT_USAGE: case NEED_AUTH: // should be handled inside // connect "loop" nextUploader(); return; case OK: doUpload(uploader); return; } } }, uploader, result.authMethod); return; } } }.execute(uploader); }
From source file:com.easemob.chatuidemo.activity.LoginFragment.java
public void login(final String currentUsername, final String currentPassword, final ProgressDialog pd) { if (!CommonUtils.isNetWorkConnected(getActivity())) { Toast.makeText(getActivity(), R.string.network_isnot_available, Toast.LENGTH_SHORT).show(); return;/*from w ww .j a va2s.c o m*/ } if (TextUtils.isEmpty(currentUsername)) { Toast.makeText(getActivity(), R.string.User_name_cannot_be_empty, Toast.LENGTH_SHORT).show(); return; } if (TextUtils.isEmpty(currentPassword)) { Toast.makeText(getActivity(), R.string.Password_cannot_be_empty, Toast.LENGTH_SHORT).show(); return; } progressShow = true; pd.setCanceledOnTouchOutside(false); pd.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { progressShow = false; } }); pd.setMessage(getString(R.string.Is_landing)); pd.show(); final long start = System.currentTimeMillis(); // sdk?? EMChatManager.getInstance().login(currentUsername, currentPassword, new EMCallBack() { @Override public void onSuccess() { if (!progressShow) { return; } // ????? HXApplication.getInstance().setUserName(currentUsername); HXApplication.getInstance().setPassword(currentPassword); try { // ** ?logout??? // ** manually load all local groups and EMGroupManager.getInstance().loadAllGroups(); EMChatManager.getInstance().loadAllConversations(); // ?? initializeContacts(); } catch (Exception e) { e.printStackTrace(); // ????? getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); HXApplication.getInstance().logout(null); Toast.makeText(getActivity().getApplicationContext(), R.string.login_failure_failed, 1) .show(); } }); return; } // ?nickname ios?nick boolean updatenick = EMChatManager.getInstance() .updateCurrentUserNick(HXApplication.currentUserNick.trim()); if (!updatenick) { Log.e("LoginActivity", "update current user nick fail"); } if (!getActivity().isFinishing() && pd.isShowing()) { pd.dismiss(); } // ? startMainActivity(); } @Override public void onProgress(int progress, String status) { } @Override public void onError(final int code, final String message) { if (!progressShow) { return; } getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity().getApplicationContext(), getString(R.string.Login_failed) + message, Toast.LENGTH_SHORT).show(); } }); } }); }
From source file:com.uraroji.garage.android.arrraycopybench.MainActivity.java
private void startBench() { mResultTextView.setText(""); final String arrayTypeStr = mArrayTypeSpinner.getSelectedItem().toString(); final int arrayLength = Integer.parseInt(mArrayLengthSpinner.getSelectedItem().toString()); final int benchTimes = Integer.parseInt(mBenchTimesSpinner.getSelectedItem().toString()); final ProgressDialog dialog = new ProgressDialog(this); dialog.setMessage(getString(R.string.benchmarking)); dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); dialog.setCancelable(false);/* w w w.j a va 2 s . c o m*/ dialog.show(); final Handler handler = new Handler(); if (arrayTypeStr.equals("byte")) { final byte[] src = new byte[arrayLength]; for (int i = 0; i < src.length; ++i) { src[i] = (byte) i; } new Thread(new Runnable() { @Override public void run() { BenchResult benchResult = null; benchResult = copyClone(src, benchTimes); showResult("clone", benchResult, handler); benchResult = copyArraycopy(src, benchTimes); showResult("System.arraycopy", benchResult, handler); benchResult = copyArraysCopyOf(src, benchTimes); showResult("Arrays.copyOf", benchResult, handler); benchResult = copyForLoop(src, benchTimes); showResult("for loop", benchResult, handler); benchResult = copyNative(src, benchTimes); showResult("native", benchResult, handler); dialog.dismiss(); } }).start(); } else if (arrayTypeStr.equals("short")) { final short[] src = new short[arrayLength]; for (int i = 0; i < src.length; ++i) { src[i] = (short) i; } new Thread(new Runnable() { @Override public void run() { BenchResult benchResult = null; benchResult = copyClone(src, benchTimes); showResult("clone", benchResult, handler); benchResult = copyArraycopy(src, benchTimes); showResult("System.arraycopy", benchResult, handler); benchResult = copyArraysCopyOf(src, benchTimes); showResult("Arrays.copyOf", benchResult, handler); benchResult = copyForLoop(src, benchTimes); showResult("for loop", benchResult, handler); benchResult = copyNative(src, benchTimes); showResult("native", benchResult, handler); dialog.dismiss(); } }).start(); } else if (arrayTypeStr.equals("int")) { final int[] src = new int[arrayLength]; for (int i = 0; i < src.length; ++i) { src[i] = (int) i; } new Thread(new Runnable() { @Override public void run() { BenchResult benchResult = null; benchResult = copyClone(src, benchTimes); showResult("clone", benchResult, handler); benchResult = copyArraycopy(src, benchTimes); showResult("System.arraycopy", benchResult, handler); benchResult = copyArraysCopyOf(src, benchTimes); showResult("Arrays.copyOf", benchResult, handler); benchResult = copyForLoop(src, benchTimes); showResult("for loop", benchResult, handler); benchResult = copyNative(src, benchTimes); showResult("native", benchResult, handler); dialog.dismiss(); } }).start(); } else if (arrayTypeStr.equals("long")) { final long[] src = new long[arrayLength]; for (int i = 0; i < src.length; ++i) { src[i] = (long) i; } new Thread(new Runnable() { @Override public void run() { BenchResult benchResult = null; benchResult = copyClone(src, benchTimes); showResult("clone", benchResult, handler); benchResult = copyArraycopy(src, benchTimes); showResult("System.arraycopy", benchResult, handler); benchResult = copyArraysCopyOf(src, benchTimes); showResult("Arrays.copyOf", benchResult, handler); benchResult = copyForLoop(src, benchTimes); showResult("for loop", benchResult, handler); benchResult = copyNative(src, benchTimes); showResult("native", benchResult, handler); dialog.dismiss(); } }).start(); } else if (arrayTypeStr.equals("double")) { final double[] src = new double[arrayLength]; for (int i = 0; i < src.length; ++i) { src[i] = (double) i; } new Thread(new Runnable() { @Override public void run() { BenchResult benchResult = null; benchResult = copyClone(src, benchTimes); showResult("clone", benchResult, handler); benchResult = copyArraycopy(src, benchTimes); showResult("System.arraycopy", benchResult, handler); benchResult = copyArraysCopyOf(src, benchTimes); showResult("Arrays.copyOf", benchResult, handler); benchResult = copyForLoop(src, benchTimes); showResult("for loop", benchResult, handler); benchResult = copyNative(src, benchTimes); showResult("native", benchResult, handler); dialog.dismiss(); } }).start(); } else if (arrayTypeStr.equals("Object")) { final Object[] src = new Object[arrayLength]; for (int i = 0; i < src.length; ++i) { src[i] = new Object(); } new Thread(new Runnable() { @Override public void run() { BenchResult benchResult = null; benchResult = copyClone(src, benchTimes); showResult("clone", benchResult, handler); benchResult = copyArraycopy(src, benchTimes); showResult("System.arraycopy", benchResult, handler); benchResult = copyArraysCopyOf(src, benchTimes); showResult("Arrays.copyOf", benchResult, handler); benchResult = copyForLoop(src, benchTimes); showResult("for loop", benchResult, handler); dialog.dismiss(); } }).start(); } else if (arrayTypeStr.equals("Byte")) { final Byte[] src = new Byte[arrayLength]; for (int i = 0; i < src.length; ++i) { src[i] = new Byte((byte) i); } new Thread(new Runnable() { @Override public void run() { BenchResult benchResult = null; benchResult = copyClone(src, benchTimes); showResult("clone", benchResult, handler); benchResult = copyArraycopy(src, benchTimes); showResult("System.arraycopy", benchResult, handler); benchResult = copyArraysCopyOf(src, benchTimes); showResult("Arrays.copyOf", benchResult, handler); benchResult = copyForLoop(src, benchTimes); showResult("for loop", benchResult, handler); dialog.dismiss(); } }).start(); } else if (arrayTypeStr.equals("Integer")) { final Integer[] src = new Integer[arrayLength]; for (int i = 0; i < src.length; ++i) { src[i] = new Integer((int) i); } new Thread(new Runnable() { @Override public void run() { BenchResult benchResult = null; benchResult = copyClone(src, benchTimes); showResult("clone", benchResult, handler); benchResult = copyArraycopy(src, benchTimes); showResult("System.arraycopy", benchResult, handler); benchResult = copyArraysCopyOf(src, benchTimes); showResult("Arrays.copyOf", benchResult, handler); benchResult = copyForLoop(src, benchTimes); showResult("for loop", benchResult, handler); dialog.dismiss(); } }).start(); } else if (arrayTypeStr.equals("Long")) { final Long[] src = new Long[arrayLength]; for (int i = 0; i < src.length; ++i) { src[i] = new Long((long) i); } new Thread(new Runnable() { @Override public void run() { BenchResult benchResult = null; benchResult = copyClone(src, benchTimes); showResult("clone", benchResult, handler); benchResult = copyArraycopy(src, benchTimes); showResult("System.arraycopy", benchResult, handler); benchResult = copyArraysCopyOf(src, benchTimes); showResult("Arrays.copyOf", benchResult, handler); benchResult = copyForLoop(src, benchTimes); showResult("for loop", benchResult, handler); dialog.dismiss(); } }).start(); } else if (arrayTypeStr.equals("Double")) { final Double[] src = new Double[arrayLength]; for (int i = 0; i < src.length; ++i) { src[i] = new Double((double) i); } new Thread(new Runnable() { @Override public void run() { BenchResult benchResult = null; benchResult = copyClone(src, benchTimes); showResult("clone", benchResult, handler); benchResult = copyArraycopy(src, benchTimes); showResult("System.arraycopy", benchResult, handler); benchResult = copyArraysCopyOf(src, benchTimes); showResult("Arrays.copyOf", benchResult, handler); benchResult = copyForLoop(src, benchTimes); showResult("for loop", benchResult, handler); dialog.dismiss(); } }).start(); } else { dialog.dismiss(); } }
From source file:org.runnerup.export.SyncManager.java
private void syncOK(Synchronizer synchronizer, ProgressDialog copySpinner, SQLiteDatabase copyDB, long id) { copySpinner.setMessage(getResources().getString(R.string.Saving)); ContentValues tmp = new ContentValues(); tmp.put(DB.EXPORT.ACCOUNT, synchronizer.getId()); tmp.put(DB.EXPORT.ACTIVITY, id);/*from w ww . jav a 2 s .c o m*/ tmp.put(DB.EXPORT.STATUS, 0); copyDB.insert(DB.EXPORT.TABLE, null, tmp); }
From source file:im.vector.activity.SettingsActivity.java
private void saveChanges(final MXSession session) { LinearLayout linearLayout = mLinearLayoutBySession.get(session); EditText displayNameEditText = (EditText) linearLayout.findViewById(R.id.editText_displayName); // Save things final String nameFromForm = displayNameEditText.getText().toString(); final ApiCallback<Void> changeCallback = UIUtils.buildOnChangeCallback(this); final MyUser myUser = session.getMyUser(); final Button saveButton = (Button) linearLayout.findViewById(R.id.button_save); if (UIUtils.hasFieldChanged(myUser.displayname, nameFromForm)) { myUser.updateDisplayName(nameFromForm, new SimpleApiCallback<Void>(changeCallback) { @Override/*from w w w .j a v a 2 s .c o m*/ public void onSuccess(Void info) { super.onSuccess(info); updateSaveButton(saveButton); } }); } Uri newAvatarUri = mTmpThumbnailUriBySession.get(session); 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 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 mTmpThumbnailUriBySession.remove(session); updateSaveButton(saveButton); } }); } progressDialog.dismiss(); } }); } }
From source file:org.runnerup.export.SyncManager.java
protected void doListWorkout(final Synchronizer synchronizer) { final ProgressDialog copySpinner = mSpinner; copySpinner.setMessage("Listing from " + synchronizer.getName()); final ArrayList<Pair<String, String>> list = new ArrayList<Pair<String, String>>(); new AsyncTask<Synchronizer, String, Synchronizer.Status>() { @Override/*from w w w .j a v a2 s. co m*/ protected Synchronizer.Status doInBackground(Synchronizer... params) { try { return params[0].listWorkouts(list); } 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: for (Pair<String, String> w : list) { workoutRef.add(new WorkoutRef(synchronizer.getName(), w.first, w.second)); } 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" nextListWorkout(); break; case OK: doListWorkout(synchronizer); break; } } }, synchronizer, result.authMethod); return; } nextListWorkout(); } }.execute(synchronizer); }
From source file:com.almarsoft.GroundhogReader.MessageListActivity.java
@Override protected Dialog onCreateDialog(int id) { ProgressDialog dialog = null; if (id == ID_DIALOG_CATCHUP) { dialog = new ProgressDialog(this); dialog.setMessage(getString(R.string.catchingup_server)); dialog.setIndeterminate(true);/*www. j a va 2 s . c om*/ dialog.setCancelable(false); return dialog; } return super.onCreateDialog(id); }