List of usage examples for android.app ProgressDialog show
public void show()
From source file:com.entertailion.android.dial.ServerFinder.java
private void showProgressDialog(ProgressDialog newDialog) { try {//from www . ja v a2 s . c om try { if ((progressDialog != null) && progressDialog.isShowing()) { progressDialog.dismiss(); } } catch (Throwable e) { Log.e(LOG_TAG, "showProgressDialog", e); } progressDialog = newDialog; newDialog.show(); } catch (Exception e) { Log.e(LOG_TAG, "showProgressDialog", e); } }
From source file:bikebadger.RideFragment.java
public void SaveGPXFileOnNewThreadWithDialog(final String path) { final ProgressDialog pd = new ProgressDialog(getActivity()); pd.setProgressStyle(ProgressDialog.STYLE_SPINNER); final File gpxFile = new File(path); pd.setMessage("Saving \"" + gpxFile.getName() + "\""); pd.setIndeterminate(true);/*www.ja va 2s . c om*/ pd.setCancelable(false); pd.show(); Thread mThread = new Thread() { @Override public void run() { mRideManager.ExportWaypointsTrack(); pd.dismiss(); if (mRideManager.mWaypoints != null) { getActivity().runOnUiThread(new Runnable() { public void run() { //Toast.makeText(getActivity(), "Hello", Toast.LENGTH_SHORT).show(); MyToast.Show(getActivity(), "\"" + gpxFile.getName() + "\" saved", Color.BLACK); } }); } } }; mThread.start(); }
From source file:bikebadger.RideFragment.java
public void OpenGPXFileOnNewThreadWithDialog(final String path) { final ProgressDialog pd = new ProgressDialog(getActivity()); pd.setProgressStyle(ProgressDialog.STYLE_SPINNER); final File gpxFile = new File(path); pd.setMessage("Loading \"" + gpxFile.getName() + "\""); pd.setIndeterminate(true);/*from w w w . j av a2s .c o m*/ pd.setCancelable(false); pd.show(); Thread mThread = new Thread() { @Override public void run() { mRideManager.OpenGPXFile(path); pd.dismiss(); if (mRideManager.mWaypoints != null) { getActivity().runOnUiThread(new Runnable() { public void run() { //Toast.makeText(getActivity(), "Hello", Toast.LENGTH_SHORT).show(); MyToast.Show(getActivity(), "\"" + gpxFile.getName() + "\" loaded (" + mRideManager.mWaypoints.size() + ")", Color.BLACK); } }); } } }; mThread.start(); }
From source file:com.microsoft.live.sample.skydrive.SkyDriveActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == FilePicker.PICK_FILE_REQUEST) { if (resultCode == RESULT_OK) { String filePath = data.getStringExtra(FilePicker.EXTRA_FILE_PATH); if (TextUtils.isEmpty(filePath)) { showToast("No file was choosen."); return; }/* w ww .j ava 2 s.co m*/ File file = new File(filePath); final ProgressDialog uploadProgressDialog = new ProgressDialog(SkyDriveActivity.this); uploadProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); uploadProgressDialog.setMessage("Uploading..."); uploadProgressDialog.setCancelable(true); uploadProgressDialog.show(); final LiveOperation operation = mClient.uploadAsync(mCurrentFolderId, file.getName(), file, new LiveUploadOperationListener() { @Override public void onUploadProgress(int totalBytes, int bytesRemaining, LiveOperation operation) { int percentCompleted = computePrecentCompleted(totalBytes, bytesRemaining); uploadProgressDialog.setProgress(percentCompleted); } @Override public void onUploadFailed(LiveOperationException exception, LiveOperation operation) { uploadProgressDialog.dismiss(); showToast(exception.getMessage()); } @Override public void onUploadCompleted(LiveOperation operation) { uploadProgressDialog.dismiss(); JSONObject result = operation.getResult(); if (result.has(JsonKeys.ERROR)) { JSONObject error = result.optJSONObject(JsonKeys.ERROR); String message = error.optString(JsonKeys.MESSAGE); String code = error.optString(JsonKeys.CODE); showToast(code + ": " + message); return; } loadFolder(mCurrentFolderId); } }); uploadProgressDialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { operation.cancel(); } }); } } }
From source file:com.ccxt.whl.activity.LoginActivity.java
/** * /*from ww w . j a v a 2 s.c om*/ * * @param view */ public void login(View view) { if (!CommonUtils.isNetWorkConnected(this)) { Toast.makeText(this, R.string.network_isnot_available, Toast.LENGTH_SHORT).show(); return; } final String email = usernameEditText.getText().toString(); final String password = passwordEditText.getText().toString(); if (!TextUtils.isEmpty(email) && !TextUtils.isEmpty(password)) { progressShow = true; final ProgressDialog pd = new ProgressDialog(LoginActivity.this); pd.setCanceledOnTouchOutside(false); pd.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { progressShow = false; } }); pd.setMessage("..."); pd.show(); // sdk?? RequestParams params = new RequestParams(); params.add("tel_email", email); params.add("pwd", MD5.MD5Hash(password)); params.add("uid", uid); HttpRestClient.get(Constant.LOGIN_URL, params, new BaseJsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, String rawJsonResponse, Object response) { Log.d("login_res_json" + rawJsonResponse); pd.dismiss(); if (CommonUtils.isNullOrEmpty(rawJsonResponse)) { Toast.makeText(getApplicationContext(), "?,?", 0) .show(); return; } Map<String, Object> lm = JsonToMapList.getMap(rawJsonResponse); if (lm.get("status").toString() != null && lm.get("status").toString().equals("yes")) { Map<String, Object> result = JsonToMapList.getMap(lm.get("result").toString()); String resultStr = "status:" + lm.get("status") + "\n" + "message:" + lm.get("message") + "\n" + "result:" + lm.get("result") + "\n" + "uid:" + result.get("uid") + "\n" + "umd5:" + result.get("umd5") + "\n" + "is_res:" + result.get("is_res") + "\n" + "headurl:" + result.get("headurl") + "\n" + "name:" + result.get("name") + "\n" + "sex:" + result.get("sex") + "\n" + "age:" + result.get("age") + "\n" + "province:" + result.get("province") + "\n" + "city:" + result.get("city") + "\n" + "pwd:" + result.get("pwd") + "\n"; Log.d("login_res_obj" + resultStr); //???id nullsaveinfo Preference //DemoApplication.getInstance().setUser(result.get("umd5").toString()); //System.out.println("========================"+result.get("umd5").toString()); /********/ PreferenceUtils.getInstance(getBaseContext()) .setSettingUserPic(result.get("headurl").toString()); PreferenceUtils.getInstance(getBaseContext()) .setSettingUserNickName(result.get("name").toString()); PreferenceUtils.getInstance(getBaseContext()) .setSettingUserSex(result.get("sex").toString()); PreferenceUtils.getInstance(getBaseContext()) .setSettingUserAge(result.get("age").toString()); PreferenceUtils.getInstance(getBaseContext()).setSettingUserArea( result.get("province").toString() + " " + result.get("city").toString()); PreferenceUtils.getInstance(getBaseContext()) .setSettingUserZhiye(result.get("zhiye").toString()); PreferenceUtils.getInstance(getBaseContext()) .setSettingUserQianming(result.get("qianming").toString()); String huanxin_username = result.get("umd5").toString(); String huanxin_pwd = result.get("pwd").toString(); Log.d("log huanxin_username:" + huanxin_username + "|huanxin_pwd:" + huanxin_pwd); //?? login(huanxin_username, huanxin_pwd); /*??? progressShow = false; pd.dismiss();*/ } else { Toast.makeText(getApplicationContext(), lm.get("message").toString(), 0).show(); } } @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, String rawJsonData, Object errorResponse) { // TODO Auto-generated method stub Toast.makeText(getApplicationContext(), "?,?", 0).show(); } @Override protected Object parseResponse(String rawJsonData, boolean isFailure) throws Throwable { // TODO Auto-generated method stub return null; } }); } }
From source file:com.ccxt.whl.activity.LoginActivity.java
/** * ?/*from w w w . j a v a2s . com*/ * * @param view */ public void login(final String username, final String password) { if (!CommonUtils.isNetWorkConnected(this)) { Toast.makeText(this, R.string.network_isnot_available, Toast.LENGTH_SHORT).show(); return; } //final String username = usernameEditText.getText().toString(); //final String password = passwordEditText.getText().toString(); if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(password)) { progressShow = true; final ProgressDialog pd = new ProgressDialog(LoginActivity.this); pd.setCanceledOnTouchOutside(false); pd.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { progressShow = false; } }); pd.setMessage("..."); pd.show(); // sdk?? EMChatManager.getInstance().login(username, password, new EMCallBack() { @Override public void onSuccess() { /***************** * ? *****************/ if (!progressShow) { return; } // ????? // DemoApplication.getInstance().setUserName(username); DemoApplication.getInstance().setUser(username); DemoApplication.getInstance().setPassword(password); DemoApplication.getInstance().setUserNickName(name); runOnUiThread(new Runnable() { public void run() { pd.setMessage("???..."); } }); try { // demo??????username?? List<String> usernames = EMChatManager.getInstance().getContactUserNames(); Map<String, User> userlist = new HashMap<String, User>(); for (String username : usernames) { User user = new User(); user.setUsername(username); setUserHearder(username, user); userlist.put(username, user); } // user"" User newFriends = new User(); newFriends.setUsername(Constant.NEW_FRIENDS_USERNAME); newFriends.setNick(""); newFriends.setHeader(""); userlist.put(Constant.NEW_FRIENDS_USERNAME, newFriends); // "?" User groupUser = new User(); groupUser.setUsername(Constant.GROUP_USERNAME); groupUser.setNick("?"); groupUser.setHeader(""); userlist.put(Constant.GROUP_USERNAME, groupUser); // DemoApplication.getInstance().setContactList(userlist); /***?MainActivity?db* / // db UserDao dao = new UserDao(LoginActivity.this); List<User> users = new ArrayList<User>(userlist.values()); dao.saveContactList(users);/**/ // ??,sdkEMGroupManagerdb EMGroupManager.getInstance().getGroupsFromServer(); // after login, we join groups in separate threads; EMGroupManager.getInstance().joinGroupsAfterLogin(); } catch (Exception e) { e.printStackTrace(); } if (!LoginActivity.this.isFinishing()) pd.dismiss(); // ? startActivity(new Intent(LoginActivity.this, MainActivity.class)); finish(); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, final String message) { if (!progressShow) { return; } //Log.d("log","code"+code); runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getApplicationContext(), ": " + message, 0).show(); } }); } }); } }
From source file:com.microsoft.live.sample.skydrive.SkyDriveActivity.java
@Override protected Dialog onCreateDialog(final int id, final Bundle bundle) { Dialog dialog = null;/*from w ww .j a va 2 s .c om*/ switch (id) { case DIALOG_DOWNLOAD_ID: { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Download").setMessage("This file will be downloaded to the sdcard.") .setPositiveButton("OK", new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final ProgressDialog progressDialog = new ProgressDialog(SkyDriveActivity.this); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setMessage("Downloading..."); progressDialog.setCancelable(true); progressDialog.show(); String fileId = bundle.getString(JsonKeys.ID); String name = bundle.getString(JsonKeys.NAME); File file = new File(Environment.getExternalStorageDirectory(), name); final LiveDownloadOperation operation = mClient.downloadAsync(fileId + "/content", file, new LiveDownloadOperationListener() { @Override public void onDownloadProgress(int totalBytes, int bytesRemaining, LiveDownloadOperation operation) { int percentCompleted = computePrecentCompleted(totalBytes, bytesRemaining); progressDialog.setProgress(percentCompleted); } @Override public void onDownloadFailed(LiveOperationException exception, LiveDownloadOperation operation) { progressDialog.dismiss(); showToast(exception.getMessage()); } @Override public void onDownloadCompleted(LiveDownloadOperation operation) { progressDialog.dismiss(); showToast("File downloaded."); } }); progressDialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { operation.cancel(); } }); } }).setNegativeButton("Cancel", new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); dialog = builder.create(); break; } } if (dialog != null) { dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { removeDialog(id); } }); } return dialog; }
From source file:com.mobicage.rogerthat.registration.AbstractRegistrationActivity.java
public void tryConnect(final ProgressDialog pd, final int attempt, final String statusMessage, final RegistrationInfo info) { T.UI();//ww w . j a v a2s . co m final Pausable pausable = this; if (attempt > XMPP_MAX_NUM_ATTEMPTS) { pd.dismiss(); String message = getString(R.string.registration_error); UIUtils.showDialog(mActivity, null, message, getString(R.string.try_again), null, null, null); mWizard.reInit(); mWizard.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); runOnUI(new SafeRunnable(pausable) { @Override protected void safeRun() throws Exception { T.UI(); mWizard.setCredentials(info.mCredentials); if (CloudConstants.USE_GCM_KICK_CHANNEL && !"".equals(mGCMRegistrationId)) { GoogleServicesUtils.saveGCMRegistrationId(mService, mGCMRegistrationId); } mService.setCredentials(mWizard.getCredentials()); mService.setRegisteredInConfig(true); final Intent launchServiceIntent = new Intent(mActivity, MainService.class); launchServiceIntent.putExtra(MainService.START_INTENT_JUST_REGISTERED, true); launchServiceIntent.putExtra(MainService.START_INTENT_MY_EMAIL, mWizard.getEmail()); mActivity.startService(launchServiceIntent); stopRegistrationService(); pd.dismiss(); mWizard.finish(); // finish } }); } catch (Exception e) { L.d("Exception while trying to end the registration process", e); runOnUI(new SafeRunnable(pausable) { @Override protected void safeRun() throws Exception { T.UI(); tryConnect(pd, attempt + 1, statusMessage, info); } }); } } }; if (attempt == 1) { runOnWorker(runnable); } else { runDelayedOnWorker(runnable, XMPP_CHECK_DELAY_MILLIS); } }
From source file:com.nttec.everychan.chans.ponyach.PonyachModule.java
@Override public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) { final Context context = preferenceGroup.getContext(); ListPreference captchaLevel = new LazyPreferences.ListPreference(context); captchaLevel.setTitle(R.string.ponyach_prefs_captcha); captchaLevel.setDialogTitle(R.string.ponyach_prefs_captcha); captchaLevel.setKey(getSharedKey(PREF_KEY_CAPTCHA_LEVEL)); captchaLevel.setEntryValues(new String[] { "3", "2", "1" }); captchaLevel.setEntries(new String[] { "Easy", "Easy++", "Medium" }); captchaLevel.setDefaultValue("1"); preferenceGroup.addPreference(captchaLevel); EditTextPreference passcodePref = new EditTextPreference(context); passcodePref.setTitle(R.string.ponyach_prefs_passcode); passcodePref.setDialogTitle(R.string.ponyach_prefs_passcode); passcodePref.getEditText().setFilters(new InputFilter[] { new InputFilter.LengthFilter(6) }); passcodePref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override/*www . java 2s .c om*/ public boolean onPreferenceChange(Preference preference, Object newValue) { final String newPasscode = (String) newValue; final CancellableTask passAuthTask = new CancellableTask.BaseCancellableTask(); final ProgressDialog passAuthProgressDialog = new ProgressDialog(context); passAuthProgressDialog.setMessage("Logging in"); passAuthProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { passAuthTask.cancel(); } }); passAuthProgressDialog.setCanceledOnTouchOutside(false); passAuthProgressDialog.show(); Async.runAsync(new Runnable() { @Override public void run() { try { if (passAuthTask.isCancelled()) return; String url = getUsingUrl() + "passcode.php"; List<BasicNameValuePair> pairs = Collections .singletonList(new BasicNameValuePair("passcode_just_set", newPasscode)); HttpRequestModel request = HttpRequestModel.builder() .setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).build(); HttpStreamer.getInstance().getStringFromUrl(url, request, httpClient, null, passAuthTask, false); savePhpCookies(); } catch (final Exception e) { if (context instanceof Activity) { ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { String message = e.getMessage() == null ? resources.getString(R.string.error_unknown) : e.getMessage(); Toast.makeText(context, message, Toast.LENGTH_LONG).show(); } }); } } finally { passAuthProgressDialog.dismiss(); } } }); return false; } }); preferenceGroup.addPreference(passcodePref); ListPreference domainPref = new LazyPreferences.ListPreference(context); domainPref.setTitle(R.string.pref_domain); domainPref.setDialogTitle(R.string.pref_domain); domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN)); domainPref.setEntryValues(DOMAINS); domainPref.setEntries(DOMAINS); domainPref.setDefaultValue(DEFAULT_DOMAIN); domainPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { loadPhpCookies((String) newValue); return true; } }); preferenceGroup.addPreference(domainPref); addHttpsPreference(preferenceGroup, useHttpsDefaultValue()); addProxyPreferences(preferenceGroup); captchaLevel.setSummary(captchaLevel.getEntry()); domainPref.setSummary(domainPref.getEntry()); }
From source file:org.openremote.android.console.AppSettingsActivity.java
/** * Submits a Certification Request to the controller */// www. j a v a2s .c o m private void requestAccess() { final String hostname = AppSettingsActivity.currentServer; if (!TextUtils.isEmpty(hostname)) { final ProgressDialog progress = new ProgressDialog(this); final Handler handler = new Handler() { public void handleMessage(Message msg) { if (progress.isShowing()) { progress.dismiss(); } } }; if (isActivityResumed()) { progress.show(); } new Thread() { public void run() { handler.sendEmptyMessage(ORPKCS10CertificationRequest.getInstance(getApplicationContext()) .submitCertificationRequest(hostname)); } }.start(); } }