List of usage examples for android.app ProgressDialog setMessage
@Override public void setMessage(CharSequence message)
From source file:com.grass.caishi.cc.activity.main.MainActivity.java
void logout() { final ProgressDialog pd = new ProgressDialog(MainActivity.this); String st = "..."; pd.setMessage(st); pd.setCanceledOnTouchOutside(false); pd.show();/*from w ww .j a v a 2s . c o m*/ DemoHXSDKHelper.getInstance().logout(true, new EMCallBack() { @Override public void onSuccess() { MainActivity.this.runOnUiThread(new Runnable() { public void run() { pd.dismiss(); // ?? MainActivity.this.finish(); startActivity(new Intent(MainActivity.this, LoginActivity.class)); } }); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, String message) { MainActivity.this.runOnUiThread(new Runnable() { @Override public void run() { // pd.dismiss(); Toast.makeText(MainActivity.this, "unbind devicetokens failed", Toast.LENGTH_SHORT).show(); } }); } }); }
From source file:com.juick.android.MainActivity.java
private void obtainSavedMessagesURL(final boolean reset) { final ProgressDialog pd = new ProgressDialog(MainActivity.this); pd.setIndeterminate(true);//from w w w . jav a 2 s. com pd.setTitle("Saved Messages"); pd.setMessage("Waiting for server key"); pd.setCancelable(true); pd.show(); new Thread("obtainSavedMessagesURL") { @Override public void run() { final RESTResponse restResponse = DatabaseService.obtainSharingURL(MainActivity.this, reset); if (restResponse.getErrorText() == null) try { new JSONObject(restResponse.getResult()); } catch (JSONException e) { restResponse.errorText = e.toString(); } runOnUiThread(new Runnable() { @Override public void run() { pd.cancel(); if (restResponse.getErrorText() != null) { Toast.makeText(MainActivity.this, restResponse.getErrorText(), Toast.LENGTH_LONG) .show(); } else { try { final String url = (String) new JSONObject(restResponse.getResult()).get("url"); if (url.length() == 0) { Toast.makeText(MainActivity.this, "You don't have key yet. Choose another option.", Toast.LENGTH_LONG) .show(); } else { new AlertDialog.Builder(MainActivity.this).setTitle("You got key!") .setMessage(url) .setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setNeutralButton("Share with..", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent share = new Intent( android.content.Intent.ACTION_SEND); share.setType("text/plain"); share.addFlags( Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); share.putExtra(Intent.EXTRA_SUBJECT, "My Saved messages on Juick Advanced"); share.putExtra(Intent.EXTRA_TEXT, url); startActivity( Intent.createChooser(share, "Share link")); } }) .setCancelable(true).show(); } } catch (JSONException e) { Toast.makeText(MainActivity.this, e.toString(), Toast.LENGTH_LONG).show(); } } } }); } }.start(); }
From source file:ac.robinson.mediaphone.MediaPhoneActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case R.id.dialog_importing_in_progress: ProgressDialog importDialog = new ProgressDialog(MediaPhoneActivity.this); importDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); importDialog.setMessage(getString(R.string.import_progress)); importDialog.setCancelable(false); mImportFramesProgressDialog = importDialog; mImportFramesDialogShown = true; return importDialog; case R.id.dialog_export_narrative_in_progress: ProgressDialog exportDialog = new ProgressDialog(MediaPhoneActivity.this); exportDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); exportDialog.setMessage(getString(R.string.background_task_progress)); exportDialog.setCancelable(false); exportDialog.setIndeterminate(true); mExportNarrativeDialogShown = true; return exportDialog; case R.id.dialog_mov_creator_in_progress: ProgressDialog movDialog = new ProgressDialog(MediaPhoneActivity.this); movDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); movDialog.setMessage(getString(R.string.mov_export_task_progress)); movDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.mov_export_run_in_background), new DialogInterface.OnClickListener() { @Override/*from w w w . j av a2s.c om*/ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); mExportVideoDialogShown = false; } }); movDialog.setCancelable(false); movDialog.setIndeterminate(true); mExportVideoDialogShown = true; return movDialog; case R.id.dialog_background_runner_in_progress: ProgressDialog runnerDialog = new ProgressDialog(MediaPhoneActivity.this); runnerDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); runnerDialog.setMessage(getString(R.string.background_task_progress)); runnerDialog.setCancelable(false); runnerDialog.setIndeterminate(true); mBackgroundRunnerDialogShown = true; return runnerDialog; default: return super.onCreateDialog(id); } }
From source file:com.piusvelte.sonet.core.SonetCreatePost.java
protected void getPhoto(Uri uri) { final ProgressDialog loadingDialog = new ProgressDialog(this); final AsyncTask<Uri, Void, String> asyncTask = new AsyncTask<Uri, Void, String>() { @Override/*from w ww .j ava2 s .com*/ protected String doInBackground(Uri... imgUri) { String[] projection = new String[] { MediaStore.Images.Media.DATA }; String path = null; Cursor c = getContentResolver().query(imgUri[0], projection, null, null, null); if ((c != null) && c.moveToFirst()) { path = c.getString(c.getColumnIndex(projection[0])); } else { // some file manages send the path through the uri path = imgUri[0].getPath(); } c.close(); return path; } @Override protected void onPostExecute(String path) { if (loadingDialog.isShowing()) loadingDialog.dismiss(); if (path != null) setPhoto(path); else (Toast.makeText(SonetCreatePost.this, "error retrieving the photo path", Toast.LENGTH_LONG)) .show(); } }; loadingDialog.setMessage(getString(R.string.loading)); loadingDialog.setCancelable(true); loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (!asyncTask.isCancelled()) asyncTask.cancel(true); } }); loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); loadingDialog.show(); asyncTask.execute(uri); }
From source file:com.mobicage.rogerthat.registration.RegistrationActivity2.java
private void tryConnect(final ProgressDialog pd, final int attempt, final String statusMessage, final RegistrationInfo info) { T.UI();/* w w w . j a v a 2 s . c o m*/ final Pausable pausable = this; if (attempt > XMPP_MAX_NUM_ATTEMPTS) { pd.dismiss(); new AlertDialog.Builder(RegistrationActivity2.this).setMessage(getString(R.string.registration_error)) .setCancelable(true).setPositiveButton(R.string.try_again, null).create().show(); mWiz.reInit(); mWiz.goBackToPrevious(); return; } pd.setMessage(statusMessage + attempt); if (!pd.isShowing()) pd.show(); L.d("Registration attempt #" + attempt); final String xmppServiceName = info.mCredentials.getXmppServiceName(); final String xmppAccount = info.mCredentials.getXmppAccount(); final String xmppPassword = info.mCredentials.getPassword(); final ConfigurationProvider cp = mService.getConfigurationProvider(); Configuration cfg = cp.getConfiguration(RegistrationWizard2.CONFIGKEY); final String invitorCode = (cfg == null) ? null : cfg.get(INVITOR_CODE_CONFIGKEY, null); final String invitorSecret = (cfg == null) ? null : cfg.get(INVITOR_SECRET_CONFIGKEY, null); Runnable runnable = new SafeRunnable() { @Override public void safeRun() { T.REGISTRATION(); try { if (CloudConstants.USE_XMPP_KICK_CHANNEL) { final ConnectionConfiguration xmppConfig = new XMPPConfigurationFactory(cp, mService.getNetworkConnectivityManager(), null) .getSafeXmppConnectionConfiguration(xmppServiceName); final XMPPConnection xmppCon = new XMPPConnection(xmppConfig); xmppCon.setLogger(new Logger() { @Override public void log(String message) { L.d(message); } }); xmppCon.connect(); xmppCon.login(xmppAccount, xmppPassword); final Thread t2 = new Thread(new SafeRunnable() { @Override protected void safeRun() throws Exception { L.d("REG Before disconnect (on separate thread) - xmpp-" + xmppCon.hashCode()); xmppCon.disconnect(); L.d("REG After disconnect (on separate thread) - xmpp-" + xmppCon.hashCode()); } }); t2.setDaemon(true); t2.start(); } postFinishRegistration(info.mCredentials.getUsername(), info.mCredentials.getPassword(), invitorCode, invitorSecret); mUIHandler.post(new SafeRunnable(pausable) { @Override protected void safeRun() throws Exception { T.UI(); mWiz.setCredentials(info.mCredentials); if (CloudConstants.USE_GCM_KICK_CHANNEL && !"".equals(mGCMRegistrationId)) { GoogleServicesUtils.saveGCMRegistrationId(mService, mGCMRegistrationId); } mService.setCredentials(mWiz.getCredentials()); mService.setRegisteredInConfig(true); final Intent launchServiceIntent = new Intent(RegistrationActivity2.this, MainService.class); launchServiceIntent.putExtra(MainService.START_INTENT_JUST_REGISTERED, true); launchServiceIntent.putExtra(MainService.START_INTENT_MY_EMAIL, mWiz.getEmail()); RegistrationActivity2.this.startService(launchServiceIntent); stopRegistrationService(); pd.dismiss(); mWiz.finish(); // finish } }); } catch (Exception e) { L.d("Exception while trying to end the registration process", e); mUIHandler.post(new SafeRunnable(pausable) { @Override protected void safeRun() throws Exception { T.UI(); tryConnect(pd, attempt + 1, statusMessage, info); } }); } } }; if (attempt == 1) { mWorkerHandler.post(runnable); } else { mWorkerHandler.postDelayed(runnable, XMPP_CHECK_DELAY_MILLIS); } }
From source file:com.shafiq.myfeedle.core.MyfeedleCreatePost.java
protected void getPhoto(Uri uri) { final ProgressDialog loadingDialog = new ProgressDialog(this); final AsyncTask<Uri, Void, String> asyncTask = new AsyncTask<Uri, Void, String>() { @Override//from w w w.ja v a 2 s .c o m protected String doInBackground(Uri... imgUri) { String[] projection = new String[] { MediaStore.Images.Media.DATA }; String path = null; Cursor c = getContentResolver().query(imgUri[0], projection, null, null, null); if ((c != null) && c.moveToFirst()) { path = c.getString(c.getColumnIndex(projection[0])); } else { // some file manages send the path through the uri path = imgUri[0].getPath(); } c.close(); return path; } @Override protected void onPostExecute(String path) { if (loadingDialog.isShowing()) loadingDialog.dismiss(); if (path != null) setPhoto(path); else (Toast.makeText(MyfeedleCreatePost.this, "error retrieving the photo path", Toast.LENGTH_LONG)) .show(); } }; loadingDialog.setMessage(getString(R.string.loading)); loadingDialog.setCancelable(true); loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (!asyncTask.isCancelled()) asyncTask.cancel(true); } }); loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); loadingDialog.show(); asyncTask.execute(uri); }
From source file:com.slownet5.pgprootexplorer.filemanager.ui.FileManagerActivity.java
private void setupRoot() { if (alreadySetup()) { afterInitSetup(true);//from ww w.j ava 2 s . c o m return; } final ProgressDialog dialog = new ProgressDialog(this); dialog.setIndeterminate(true); dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); dialog.setTitle("Setting up root"); dialog.setCancelable(false); ; dialog.setMax(100); final String os = SystemUtils.getSystemArchitecture(); Log.d(TAG, "setupRoot: architecture is: " + os); class Setup extends AsyncTask<Void, Integer, Boolean> { @Override protected Boolean doInBackground(Void... params) { new File(SharedData.CRYPTO_FM_PATH).mkdirs(); String filename = SharedData.CRYPTO_FM_PATH + "/toybox"; AssetManager asset = getAssets(); try { InputStream stream = asset.open("toybox"); OutputStream out = new FileOutputStream(filename); byte[] buffer = new byte[4096]; int read; int total = 0; while ((read = stream.read(buffer)) != -1) { total += read; out.write(buffer, 0, read); } Log.d(TAG, "doInBackground: total written bytes: " + total); stream.close(); out.flush(); out.close(); } catch (IOException ex) { ex.printStackTrace(); return false; } RootUtils.initRoot(filename); return true; } @Override protected void onPreExecute() { dialog.setMessage("Please wait...."); dialog.show(); } @Override protected void onPostExecute(Boolean aBoolean) { dialog.dismiss(); if (aBoolean) { SharedPreferences.Editor prefs = getSharedPreferences(CommonConstants.COMMON_SHARED_PEREFS_NAME, Context.MODE_PRIVATE).edit(); prefs.putBoolean(CommonConstants.ROOT_TOYBOX, true); prefs.apply(); prefs.commit(); afterInitSetup(true); } else { afterInitSetup(aBoolean); } } } new Setup().execute(); }
From source file:com.piusvelte.sonet.core.SonetNotifications.java
@Override public boolean onContextItemSelected(final MenuItem item) { if (item.getItemId() == CLEAR) { final ProgressDialog loadingDialog = new ProgressDialog(this); final AsyncTask<Void, Void, Void> asyncTask = new AsyncTask<Void, Void, Void>() { @Override//w w w . ja v a 2s . c om protected Void doInBackground(Void... arg0) { // clear all notifications ContentValues values = new ContentValues(); values.put(Notifications.CLEARED, 1); SonetNotifications.this.getContentResolver().update( Notifications.getContentUri(SonetNotifications.this), values, Notifications._ID + "=?", new String[] { Long.toString(((AdapterContextMenuInfo) item.getMenuInfo()).id) }); return null; } @Override protected void onPostExecute(Void result) { if (loadingDialog.isShowing()) { loadingDialog.dismiss(); } SonetNotifications.this.finish(); } }; loadingDialog.setMessage(getString(R.string.loading)); loadingDialog.setCancelable(true); loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (!asyncTask.isCancelled()) asyncTask.cancel(true); } }); loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); loadingDialog.show(); asyncTask.execute(); } return super.onContextItemSelected(item); // clear }
From source file:com.dwdesign.tweetings.activity.ComposeActivity.java
private void UploadProgressMethod(final ProgressDialog dialog) { //This method is called directly by the timer //and runs in the same thread as the timer. //We call the method that will work with the UI //through the runOnUiThread method. this.runOnUiThread(new Runnable() { public void run() { // use data here if (upload != null && upload.getRequestLength() > 0) { float progress = (float) upload.getRequestStatus() / (float) upload.getRequestLength(); float longPc = progress * 100; int percentage = Math.round(longPc); if (percentage >= 100) { dialog.setProgress(100); dialog.setIndeterminate(true); dialog.setMessage(getString(R.string.uploading_media_wait)); } else { dialog.setProgress(percentage); }/*from ww w . ja va2 s .co m*/ } } }); }
From source file:com.shafiq.myfeedle.core.MyfeedleNotifications.java
@Override public boolean onContextItemSelected(final MenuItem item) { if (item.getItemId() == CLEAR) { final ProgressDialog loadingDialog = new ProgressDialog(this); final AsyncTask<Void, Void, Void> asyncTask = new AsyncTask<Void, Void, Void>() { @Override/*from w ww. j av a 2 s .c o m*/ protected Void doInBackground(Void... arg0) { // clear all notifications ContentValues values = new ContentValues(); values.put(Notifications.CLEARED, 1); MyfeedleNotifications.this.getContentResolver().update( Notifications.getContentUri(MyfeedleNotifications.this), values, Notifications._ID + "=?", new String[] { Long.toString(((AdapterContextMenuInfo) item.getMenuInfo()).id) }); return null; } @Override protected void onPostExecute(Void result) { if (loadingDialog.isShowing()) { loadingDialog.dismiss(); } MyfeedleNotifications.this.finish(); } }; loadingDialog.setMessage(getString(R.string.loading)); loadingDialog.setCancelable(true); loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (!asyncTask.isCancelled()) asyncTask.cancel(true); } }); loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); loadingDialog.show(); asyncTask.execute(); } return super.onContextItemSelected(item); // clear }