List of usage examples for android.app ProgressDialog ProgressDialog
public ProgressDialog(Context context)
From source file:com.neighbor.ex.tong.network.UploadFileAndMessage.java
@Override protected void onPreExecute() { mProgressDialog = new ProgressDialog(context); mProgressDialog.setMessage(" ."); mProgressDialog.show();/*from w w w. j ava 2s . c om*/ super.onPreExecute(); }
From source file:com.chuger.bithdayapp.view.auth.AuthDialog.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); mSpinner = new ProgressDialog(getContext()); mSpinner.requestWindowFeature(Window.FEATURE_NO_TITLE); mSpinner.setMessage("Loading..."); requestWindowFeature(Window.FEATURE_NO_TITLE); mContent = new FrameLayout(getContext()); /* Create the 'x' image, but don't add to the mContent layout yet * at this point, we only need to know its drawable width and height * to place the webview/* www .j av a 2 s . c om*/ */ createCrossImage(); /* Now we know 'x' drawable width and height, * layout the webivew and add it the mContent layout */ final int crossWidth = mCrossImage.getDrawable().getIntrinsicWidth(); setUpWebView(crossWidth / 2); /* Finally add the 'x' image to the mContent layout and * add mContent to the Dialog view */ mContent.addView(mCrossImage, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); addContentView(mContent, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); }
From source file:net.kourlas.voipms_sms.gcm.Gcm.java
/** * Registers for Google Cloud Messaging. Sends the registration token to the application servers. * * @param activity The activity that initiated the registration. * @param showFeedback If true, shows a dialog at the end of the registration process indicating the success or * failure of the process. * @param force If true, retrieves a new registration token even if one is already stored. *//* w w w . j a v a 2 s . com*/ public void registerForGcm(final Activity activity, final boolean showFeedback, boolean force) { if (!preferences.getNotificationsEnabled()) { return; } if (preferences.getDid().equals("")) { // Do not show an error; this method should never be called unless a DID is set return; } if (!checkPlayServices(activity, showFeedback)) { return; } final ProgressDialog progressDialog = new ProgressDialog(activity); if (showFeedback) { progressDialog.setMessage(applicationContext.getString(R.string.notifications_gcm_progress)); progressDialog.setCancelable(false); progressDialog.show(); } final InstanceID instanceIdObj = InstanceID.getInstance(applicationContext); final String instanceId = instanceIdObj.getId(); if (preferences.getGcmToken().equals("") || !instanceId.equals(preferences.getGcmInstanceId()) || force) { new AsyncTask<Boolean, Void, Boolean>() { @Override protected Boolean doInBackground(Boolean... params) { try { String token = instanceIdObj.getToken( applicationContext.getString(R.string.notifications_gcm_sender_id), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); String registrationBackendUrl = "https://voipmssms-kourlas.rhcloud.com/register?" + "did=" + URLEncoder.encode(preferences.getDid(), "UTF-8") + "&" + "reg_id=" + URLEncoder.encode(token, "UTF-8"); JSONObject result = Utils.getJson(registrationBackendUrl); String status = result.optString("status"); if (status == null || !status.equals("success")) { return false; } preferences.setGcmInstanceId(instanceId); preferences.setGcmToken(token); return true; } catch (Exception ex) { return false; } } @Override protected void onPostExecute(Boolean success) { if (showFeedback) { progressDialog.hide(); if (!success) { Utils.showInfoDialog(activity, applicationContext.getResources().getString(R.string.notifications_gcm_fail)); } else { Utils.showInfoDialog(activity, applicationContext.getResources() .getString(R.string.notifications_gcm_success)); } } } }.execute(); } else if (showFeedback) { Utils.showInfoDialog(activity, applicationContext.getResources().getString(R.string.notifications_gcm_success)); } }
From source file:com.wenwen.chatuidemo.activity.RegisterActivity.java
/** * /*from w w w . j a v a 2s . co m*/ * * @param view */ public void register(View view) { final String username = userNameEditText.getText().toString().trim(); final String pwd = passwordEditText.getText().toString().trim(); String confirm_pwd = confirmPwdEditText.getText().toString().trim(); if (TextUtils.isEmpty(username)) { Toast.makeText(this, "????", Toast.LENGTH_SHORT).show(); userNameEditText.requestFocus(); return; } else if (TextUtils.isEmpty(pwd)) { Toast.makeText(this, "???", Toast.LENGTH_SHORT).show(); passwordEditText.requestFocus(); return; } else if (TextUtils.isEmpty(confirm_pwd)) { Toast.makeText(this, "???", Toast.LENGTH_SHORT).show(); confirmPwdEditText.requestFocus(); return; } else if (!pwd.equals(confirm_pwd)) { Toast.makeText(this, "????", Toast.LENGTH_SHORT).show(); return; } if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(pwd)) { final ProgressDialog pd = new ProgressDialog(this); pd.setMessage("..."); RequestParams params = new RequestParams(); params.put("username", userNameEditText.getText().toString().trim()); params.put("password", MD5.md5("ys_" + passwordEditText.getText().toString().trim()).toUpperCase()); params.put("type", "1"); HttpClientRequest.post(Urls.REG, 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("res", res); JSONObject result = new JSONObject(res); switch (Integer.valueOf(result.getString("ret"))) { case -1: Toast.makeText(RegisterActivity.this, "?", Toast.LENGTH_SHORT).show(); break; case 1: Toast.makeText(RegisterActivity.this, "?", Toast.LENGTH_SHORT).show(); DemoApplication.getInstance().setUserName(userNameEditText.getText().toString().trim()); DemoApplication.getInstance().setUserUid(result.getString("uid")); Intent intent = new Intent(RegisterActivity.this, PersonalData.class); startActivity(intent); finish(); break; case 0: case -2: case -9: Toast.makeText(RegisterActivity.this, "", Toast.LENGTH_SHORT).show(); break; default: 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) { } }); } }
From source file:net.networksaremadeofstring.cyllell.ViewCookbooks_Fragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { settings = this.getActivity().getSharedPreferences("Cyllell", 0); try {//from w w w . j a v a 2s . c om Cut = new Cuts(getActivity()); } catch (Exception e) { e.printStackTrace(); } dialog = new ProgressDialog(getActivity()); dialog.setTitle("Contacting Chef"); dialog.setMessage("Please wait: Prepping Authentication protocols"); dialog.setIndeterminate(true); if (listOfCookbooks.size() < 1) { dialog.show(); } updateListNotify = new Handler() { public void handleMessage(Message msg) { int tag = msg.getData().getInt("tag", 999999); if (msg.what == 0) { if (tag != 999999) { listOfCookbooks.get(tag).SetSpinnerVisible(); } } else if (msg.what == 1) { //Get rid of the lock CutInProgress = false; //the notifyDataSetChanged() will handle the rest } else if (msg.what == 99) { if (tag != 999999) { Toast.makeText(ViewCookbooks_Fragment.this.getActivity(), "An error occured during that operation.", Toast.LENGTH_LONG).show(); listOfCookbooks.get(tag).SetErrorState(); } } CookbookAdapter.notifyDataSetChanged(); } }; handler = new Handler() { public void handleMessage(Message msg) { //Once we've checked the data is good to use start processing it if (msg.what == 0) { OnClickListener listener = new OnClickListener() { public void onClick(View v) { GetMoreDetails((Integer) v.getTag()); } }; OnLongClickListener listenerLong = new OnLongClickListener() { public boolean onLongClick(View v) { //selectForCAB((Integer)v.getTag()); Toast.makeText(getActivity(), "This version doesn't support Cookbook editing yet", Toast.LENGTH_SHORT).show(); return true; } }; CookbookAdapter = new CookbookListAdaptor(getActivity(), listOfCookbooks, listener, listenerLong); try { list = (ListView) getView().findViewById(R.id.cookbooksListView); } catch (Exception e) { e.printStackTrace(); } if (list != null) { if (CookbookAdapter != null) { list.setAdapter(CookbookAdapter); } else { //Log.e("CookbookAdapter","CookbookAdapter is null"); } } else { //Log.e("List","List is null"); } dialog.dismiss(); } else if (msg.what == 200) { dialog.setMessage("Sending request to Chef..."); } else if (msg.what == 201) { dialog.setMessage("Parsing JSON....."); } else if (msg.what == 202) { dialog.setMessage("Populating UI!"); } else { //Close the Progress dialog dialog.dismiss(); //Alert the user that something went terribly wrong AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.setTitle("API Error"); alertDialog.setMessage("There was an error communicating with the API:\n" + msg.getData().getString("exception")); alertDialog.setButton2("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //getActivity().finish(); } }); alertDialog.setIcon(R.drawable.icon); alertDialog.show(); } } }; Thread dataPreload = new Thread() { public void run() { if (listOfCookbooks.size() > 0) { handler.sendEmptyMessage(0); } else { try { handler.sendEmptyMessage(200); Cookbooks = Cut.GetCookbooks(); handler.sendEmptyMessage(201); JSONArray Keys = Cookbooks.names(); String URI = ""; String Version = "0.0.0"; JSONObject cookbook; for (int i = 0; i < Cookbooks.length(); i++) { cookbook = new JSONObject(Cookbooks.getString(Keys.get(i).toString())); //URI = Cookbooks.getString(Keys.get(i).toString()).replaceFirst("^(https://|http://).*/cookbooks/", ""); //Version = Cookbooks.getString(Keys.get(i).toString()) //Log.i("Cookbook Name", Keys.get(i).toString()); URI = cookbook.getString("url").replaceFirst("^(https://|http://).*/cookbooks/", ""); //Log.i("Cookbook URL", URI); JSONArray versions = cookbook.getJSONArray("versions"); Version = versions.getJSONObject(versions.length() - 1).getString("version"); //Log.i("Cookbook version", Version); listOfCookbooks.add(new Cookbook(Keys.get(i).toString(), URI, Version)); } handler.sendEmptyMessage(202); handler.sendEmptyMessage(0); } catch (Exception e) { BugSenseHandler.log("ViewCookbooksFragment", e); e.printStackTrace(); Message msg = new Message(); Bundle data = new Bundle(); data.putString("exception", e.getMessage()); msg.setData(data); msg.what = 1; handler.sendMessage(msg); } } return; } }; dataPreload.start(); return inflater.inflate(R.layout.cookbooks_landing, container, false); }
From source file:org.que.async.AsyncJSONSender.java
/** * The ctor of the AsyncJSONSender with context to show a progess dialog * @param url the url of the web service * @param job the job which will be executed after sending the objects * @param context to create a progress dialog *//*w w w .ja va2 s .c o m*/ public AsyncJSONSender(String url, PostExecuteJob job, Context context) { this.url = url; this.job = job; this.progress = new ProgressDialog(context); }
From source file:com.dmsl.anyplace.tasks.FetchPoisByBuidTask.java
@Override protected void onPreExecute() { dialog = new ProgressDialog(mCtx); dialog.setIndeterminate(true);// ww w. j a v a 2s . co m dialog.setTitle("Fetching POIs"); dialog.setMessage("Please be patient..."); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(false); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { FetchPoisByBuidTask.this.cancel(true); } }); dialog.show(); }
From source file:li.klass.fhem.fragments.AbstractWebViewFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override//from www .ja v a2 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.wenwen.chatuidemo.activity.AddContactActivity.java
/** * contact//from ww w. ja v a 2 s .c o m * * @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:me.xingrz.finder.ZipFinderActivity.java
@Override protected void onCreateInternal(Bundle savedInstanceState) { super.onCreateInternal(savedInstanceState); current = new File(getIntent().getData().getPath()); try {//from ww w.ja va 2 s . c o m zipFile = new ZipFile(current); zipFile.setRunInThread(true); } catch (ZipException e) { Log.d(TAG, "failed to open zip file " + current.getAbsolutePath(), e); } if (getIntent().hasExtra(EXTRA_PREFIX)) { toolbar.setTitle(FilenameUtils.getName(getIntent().getStringExtra(EXTRA_PREFIX))); toolbar.setSubtitle(current.getName()); } passwordPrompt = new AlertDialog.Builder(this).setView(R.layout.dialog_password) .setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { confirmFilePassword(); } }).create(); progressMonitor = zipFile.getProgressMonitor(); progressDialog = new ProgressDialog(this); progressDialog.setMax(100); progressDialog.setCancelable(false); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); }