List of usage examples for android.app ProgressDialog setMessage
@Override public void setMessage(CharSequence message)
From source file:li.klass.fhem.fragments.AbstractWebViewFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override//from w ww . j ava2 s. c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); if (view != null) return view; view = inflater.inflate(R.layout.webview, container, false); assert view != null; final WebView webView = (WebView) view.findViewById(R.id.webView); WebSettings settings = webView.getSettings(); settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); settings.setJavaScriptEnabled(true); settings.setBuiltInZoomControls(true); final ProgressDialog progressDialog = new ProgressDialog(getActivity()); progressDialog.setMessage(getResources().getString(R.string.loading)); webView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { super.onProgressChanged(view, newProgress); if (newProgress < 100) { progressDialog.setProgress(newProgress); progressDialog.show(); } else { progressDialog.hide(); } } }); webView.setWebViewClient(new WebViewClient() { @Override public void onReceivedSslError(WebView view, @NotNull SslErrorHandler handler, SslError error) { handler.proceed(); } @SuppressWarnings("ConstantConditions") @Override public void onReceivedHttpAuthRequest(WebView view, @NotNull HttpAuthHandler handler, String host, String realm) { FHEMServerSpec currentServer = connectionService.getCurrentServer(getActivity()); String url = currentServer.getUrl(); String alternativeUrl = trimToNull(currentServer.getAlternateUrl()); try { String fhemUrlHost = new URL(url).getHost(); String alternativeUrlHost = alternativeUrl == null ? null : new URL(alternativeUrl).getHost(); String username = currentServer.getUsername(); String password = currentServer.getPassword(); if (host.startsWith(fhemUrlHost) || (alternativeUrlHost != null && host.startsWith(alternativeUrlHost))) { handler.proceed(username, password); } else { handler.cancel(); Intent intent = new Intent(Actions.SHOW_TOAST); intent.putExtra(BundleExtraKeys.STRING_ID, R.string.error_authentication); getActivity().sendBroadcast(intent); } } catch (MalformedURLException e) { Intent intent = new Intent(Actions.SHOW_TOAST); intent.putExtra(BundleExtraKeys.STRING_ID, R.string.error_host_connection); getActivity().sendBroadcast(intent); LOG.error("malformed URL: " + url, e); handler.cancel(); } } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if ("about:blank".equalsIgnoreCase(url)) { Optional<String> alternativeUrl = getAlternateLoadUrl(); if (alternativeUrl.isPresent()) { webView.loadUrl(alternativeUrl.get()); } } else { onPageLoadFinishedCallback(view, url); } } }); return view; }
From source file:com.givon.anhao.activity.ContactlistFragment.java
/** * ?/*from w w w . j ava2 s . c o m*/ * * @param toDeleteUser */ public void deleteContact(final UserBean tobeDeleteUser) { final ProgressDialog pd = new ProgressDialog(getActivity()); pd.setMessage("..."); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { public void run() { try { EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername()); // db? UserDao dao = new UserDao(getActivity()); dao.deleteContact(tobeDeleteUser.getUsername()); AnhaoApplication.getInstance().getContactList().remove(tobeDeleteUser.getUsername()); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); adapter.remove(tobeDeleteUser); adapter.notifyDataSetChanged(); } }); } catch (final Exception e) { getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), ": " + e.getMessage(), 1).show(); } }); } } }).start(); }
From source file:de.gebatzens.sia.SetupActivity.java
public void startDownloadingSchool() { final ProgressDialog d = new ProgressDialog(this); d.setTitle(SIAApp.SIA_APP.school.name); d.setMessage(getString(R.string.downloading_image)); d.setCancelable(false);//from www .ja va2s . co m d.setProgressStyle(ProgressDialog.STYLE_SPINNER); d.show(); new Thread() { @Override public void run() { if (!School.downloadImage(SIAApp.SIA_APP.school.image)) { runOnUiThread(new Runnable() { @Override public void run() { Snackbar.make(getWindow().getDecorView().findViewById(R.id.coordinator_layout), getString(R.string.download_error), Snackbar.LENGTH_LONG).show(); } }); } //workaround for a bug that causes an endless loading screen Subst.GGPlans subst = SIAApp.SIA_APP.api.getPlans(false); subst.save(); SIAApp.SIA_APP.school.fragments.getByType(FragmentData.FragmentType.PLAN).get(0).setData(subst); if (d.isShowing()) d.dismiss(); Intent i = new Intent(SetupActivity.this, MainActivity.class); //i.putExtra("reload", true); startActivity(i); finish(); } }.start(); }
From source file:com.wenwen.chatuidemo.activity.AddContactActivity.java
/** * contact//ww w.j a v a2 s. c om * * @param view */ public void addContact(View view) { if (DemoApplication.getInstance().getUserName().equals(nameText.getText().toString())) { startActivity(new Intent(this, AlertDialog.class).putExtra("msg", "?")); return; } final ProgressDialog pd = new ProgressDialog(AddContactActivity.this); pd.setMessage("..."); RequestParams params = new RequestParams(); DebugLog.i(TAG, "uid" + DemoApplication.getInstance().getUserUid()); params.put("fromuid", DemoApplication.getInstance().getUserUid()); params.put("touid", myUser.getAccount_id()); params.put("flag", "1"); HttpClientRequest.post(Urls.FRIENDSSET, params, 3000, new AsyncHttpResponseHandler() { @Override public void onStart() { // TODO Auto-generated method stub super.onStart(); pd.show(); } @Override public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { // TODO Auto-generated method stub try { String res = new String(arg2); DebugLog.i(TAG, "" + res); JSONObject result = new JSONObject(res); switch (Integer.valueOf(result.getString("ret"))) { case 0: Toast.makeText(AddContactActivity.this, "", Toast.LENGTH_SHORT).show(); break; case 1: Toast.makeText(AddContactActivity.this, "?", Toast.LENGTH_SHORT).show(); Bundle bundle = new Bundle(); bundle.putSerializable("myuser", myUser); Intent data = new Intent(); data.putExtras(bundle); setResult(Activity.RESULT_OK, data); // ??? finish(); break; case -2: Toast.makeText(AddContactActivity.this, "??", Toast.LENGTH_SHORT).show(); break; default: break; } } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public void onFinish() { // TODO Auto-generated method stub super.onFinish(); pd.dismiss(); } @Override public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { // TODO Auto-generated method stub } }); }
From source file:com.fortysevendeg.labs.bbc.rest.android.activities.BeerActivity.java
/** * Delete beer on server// w w w. j a va 2s . co m */ private void deleteBeer() { final ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setMessage(getString(R.string.connecting)); progressDialog.setIndeterminate(true); progressDialog.setCancelable(false); progressDialog.show(); APIService.get().deleteBeer(beerResponseEdit.getId(), new ContextAwareAPIDelegate<BeerResponse>(this, BeerResponse.class) { @Override public void onResults(BeerResponse beerResponse) { progressDialog.dismiss(); Toast.makeText(BeerActivity.this, R.string.beerDeleted, Toast.LENGTH_SHORT).show(); setResult(RESULT_OK); finish(); } @Override public void onError(Throwable e) { progressDialog.dismiss(); Toast.makeText(BeerActivity.this, R.string.error, Toast.LENGTH_SHORT).show(); } }); }
From source file:com.wenwen.chatuidemo.activity.AddContactActivity.java
/** * contact/*from w w w . j a v a2 s . c om*/ * * @param v */ public void searchContact(View v) { final String name = editText.getText().toString(); String saveText = searchBtn.getText().toString(); if (getString(R.string.button_search).equals(saveText)) { toAddUsername = name; if (TextUtils.isEmpty(name)) { startActivity(new Intent(this, AlertDialog.class).putExtra("msg", "??")); return; } final ProgressDialog pd = new ProgressDialog(AddContactActivity.this); pd.setMessage("..."); RequestParams params = new RequestParams(); params.put("data", editText.getText().toString().trim()); params.put("flag", "1"); HttpClientRequest.post(Urls.FINDUSER, params, 3000, new AsyncHttpResponseHandler() { @Override public void onStart() { // TODO Auto-generated method stub super.onStart(); pd.show(); } @Override public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { // TODO Auto-generated method stub try { String res = new String(arg2); DebugLog.i(TAG, "" + res); JSONObject result = new JSONObject(res); switch (Integer.valueOf(result.getString("ret"))) { case -1: Toast.makeText(AddContactActivity.this, "?", Toast.LENGTH_SHORT).show(); break; case 1: searchedUserLayout.setVisibility(View.VISIBLE); nameText.setText(toAddUsername); nameText.setText(result.getString("account_name")); myUser = new MyUser(); myUser.setAccount_id(result.getString("account_id")); myUser.setAccount_image(result.getString("account_image")); myUser.setAccount_name(result.getString("account_name")); myUser.setAccount_username(result.getString("account_username")); break; case 0: Toast.makeText(AddContactActivity.this, "", Toast.LENGTH_SHORT).show(); break; } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public void onFinish() { // TODO Auto-generated method stub super.onFinish(); pd.dismiss(); } @Override public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { // TODO Auto-generated method stub } }); } }
From source file:com.haseebelahi.usman.UserProfile.java
public void getUserDetails() { String url = "http://asfand.danglingpixels.com/taxi/app/get_user.php?user_id=" + logged_in; //showing dialog box final ProgressDialog progressDialog = new ProgressDialog(this.getActivity(), R.style.AppTheme_Dark_Dialog); progressDialog.setIndeterminate(true); progressDialog.setMessage("Updating..."); progressDialog.show();/*from ww w. ja v a 2 s . c o m*/ // Request a string response StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() { @Override public void onResponse(String response) { // Result handling System.out.println(response); progressDialog.dismiss(); try { JSONArray jsonArray = new JSONArray(response); JSONObject jsonObject = jsonArray.getJSONObject(0); name.setText("Name: " + jsonObject.getString("name")); username.setText("Username: " + jsonObject.getString("username")); email.setText("Email: " + jsonObject.getString("email")); cnic.setText("CNIC: " + jsonObject.getString("cnic")); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { // Error handling System.out.println("Something went wrong!"); error.printStackTrace(); progressDialog.dismiss(); Toast.makeText(getContext(), "FAILED TO CONNECT", Toast.LENGTH_LONG).show(); } }); // Add the request to the queue int socketTimeout = 30000;//30 seconds - change to what you want RetryPolicy policy = new DefaultRetryPolicy(socketTimeout, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT); stringRequest.setRetryPolicy(policy); Volley.newRequestQueue(this.getContext()).add(stringRequest); }
From source file:com.haseebelahi.usman.UserProfile.java
public void getDriverDetails() { String url = "http://asfand.danglingpixels.com/taxi/app/get_driver.php?user_id=" + logged_in; //showing dialog box final ProgressDialog progressDialog = new ProgressDialog(this.getActivity(), R.style.AppTheme_Dark_Dialog); progressDialog.setIndeterminate(true); progressDialog.setMessage("Updating..."); progressDialog.show();//from w w w . jav a 2s .c om // Request a string response StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() { @Override public void onResponse(String response) { // Result handling System.out.println(response); progressDialog.dismiss(); try { JSONArray jsonArray = new JSONArray(response); JSONObject jsonObject = jsonArray.getJSONObject(0); name.setText("Name: " + jsonObject.getString("name")); username.setText("License: " + jsonObject.getString("license")); email.setText("Mobile: " + jsonObject.getString("mobile")); cnic.setText(""); } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { // Error handling System.out.println("Something went wrong!"); error.printStackTrace(); progressDialog.dismiss(); Toast.makeText(getContext(), "FAILED TO CONNECT", Toast.LENGTH_LONG).show(); } }); // Add the request to the queue int socketTimeout = 30000;//30 seconds - change to what you want RetryPolicy policy = new DefaultRetryPolicy(socketTimeout, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT); stringRequest.setRetryPolicy(policy); Volley.newRequestQueue(this.getContext()).add(stringRequest); }
From source file:app.view.chat.ContactListFragment.java
/** * user???/* w w w . j av a 2s . co m*/ */ private void moveToBlacklist(final String username) { final ProgressDialog pd = new ProgressDialog(getActivity()); pd.setMessage("???..."); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { public void run() { try { //??? EMContactManager.getInstance().addUserToBlackList(username, true); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), "????", Toast.LENGTH_SHORT).show(); } }); } catch (EaseMobException e) { e.printStackTrace(); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), "???", Toast.LENGTH_SHORT).show(); } }); } } }).start(); }
From source file:net.kourlas.voipms_sms.Notifications.java
/** * Enable SMS notifications by configuring the VoIP.ms URL callback, registering for GCM and making the appropriate * changes to the application preferences. * * @param activity The source activity./*from w w w.j av a 2 s.co m*/ */ public void enableNotifications(final Activity activity) { if (preferences.getEmail().equals("") || preferences.getPassword().equals("") || preferences.getDid().equals("")) { Utils.showInfoDialog(activity, applicationContext.getString(R.string.notifications_callback_username_password_did)); return; } final ProgressDialog progressDialog = new ProgressDialog(activity); progressDialog.setMessage(activity.getString(R.string.notifications_callback_progress)); progressDialog.setCancelable(false); progressDialog.show(); new AsyncTask<Boolean, Void, Boolean>() { @Override protected Boolean doInBackground(Boolean... params) { try { String url = "https://www.voip.ms/api/v1/rest.php?" + "api_username=" + URLEncoder.encode(preferences.getEmail(), "UTF-8") + "&" + "api_password=" + URLEncoder.encode(preferences.getPassword(), "UTF-8") + "&" + "method=setSMS" + "&" + "did=" + URLEncoder.encode(preferences.getDid(), "UTF-8") + "&" + "enable=1" + "&" + "url_callback_enable=1" + "&" + "url_callback=" + URLEncoder .encode("http://voipmssms-kourlas.rhcloud.com/sms_callback?did={TO}", "UTF-8") + "&" + "url_callback_retry=0"; JSONObject result = Utils.getJson(url); String status = result.optString("status"); return !(status == null || !status.equals("success")); } catch (Exception ex) { return false; } } @Override protected void onPostExecute(Boolean success) { progressDialog.hide(); DialogInterface.OnClickListener gcmOnClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { gcm.registerForGcm(activity, true, true); } }; if (!success) { Utils.showAlertDialog(activity, null, applicationContext.getString(R.string.notifications_callback_fail), applicationContext.getString(R.string.ok), gcmOnClickListener, null, null); } else { Utils.showAlertDialog(activity, null, applicationContext.getString(R.string.notifications_callback_success), applicationContext.getString(R.string.ok), gcmOnClickListener, null, null); } } }.execute(); }