List of usage examples for android.app ProgressDialog ProgressDialog
public ProgressDialog(Context context)
From source file:com.code.android.vibevault.ShowDetailsScreen.java
/** Dialog creation method. * * Includes Thread bookkeeping to prevent not leaking Views on orientation changes. *//*from ww w. j a v a 2s. c o m*/ @Override protected Dialog onCreateDialog(int id) { switch (id) { case VibeVault.LOADING_DIALOG_ID: ProgressDialog dialog = new ProgressDialog(this); dialog.setMessage("Loading"); return dialog; default: return super.onCreateDialog(id); } }
From source file:nf.frex.android.FrexActivity.java
private void setWallpaper() { final WallpaperManager wallpaperManager = WallpaperManager.getInstance(FrexActivity.this); final int desiredWidth = wallpaperManager.getDesiredMinimumWidth(); final int desiredHeight = wallpaperManager.getDesiredMinimumHeight(); final Image image = view.getImage(); final int imageWidth = image.getWidth(); final int imageHeight = image.getHeight(); final boolean useDesiredSize = desiredWidth > imageWidth || desiredHeight > imageHeight; DialogInterface.OnClickListener noListener = new DialogInterface.OnClickListener() { @Override/* w w w . j a v a 2 s . c om*/ public void onClick(DialogInterface dialog, int which) { // ok } }; if (useDesiredSize) { showYesNoDialog(this, R.string.set_wallpaper, getString(R.string.wallpaper_compute_msg, desiredWidth, desiredHeight), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final Image wallpaperImage; try { wallpaperImage = new Image(desiredWidth, desiredHeight); } catch (OutOfMemoryError e) { alert(getString(R.string.out_of_memory)); return; } final ProgressDialog progressDialog = new ProgressDialog(FrexActivity.this); Generator.ProgressListener progressListener = new Generator.ProgressListener() { int numLines; @Override public void onStarted(int numTasks) { } @Override public void onSomeLinesComputed(int taskId, int line1, int line2) { numLines += 1 + line2 - line1; progressDialog.setProgress(numLines); } @Override public void onStopped(boolean cancelled) { progressDialog.dismiss(); if (!cancelled) { setWallpaper(wallpaperManager, wallpaperImage); } } }; final Generator wallpaperGenerator = new Generator(view.getGeneratorConfig(), SettingsActivity.NUM_CORES, progressListener); DialogInterface.OnCancelListener cancelListener = new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (progressDialog.isShowing()) { progressDialog.dismiss(); } wallpaperGenerator.cancel(); } }; progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setCancelable(true); progressDialog.setMax(desiredHeight); progressDialog.setOnCancelListener(cancelListener); progressDialog.show(); Arrays.fill(wallpaperImage.getValues(), FractalView.MISSING_VALUE); wallpaperGenerator.start(wallpaperImage, false); } }, noListener, null); } else { showYesNoDialog(this, R.string.set_wallpaper, getString(R.string.wallpaper_replace_msg), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { setWallpaper(wallpaperManager, image); } }, noListener, null); } }
From source file:com.odoo.addons.sale.models.SaleOrder.java
public void newCopyQuotation(final ODataRow quotation, final OnOperationSuccessListener listener) { new AsyncTask<Void, Void, Void>() { private ProgressDialog dialog; @Override/* w w w .ja v a 2s . co m*/ protected void onPreExecute() { super.onPreExecute(); dialog = new ProgressDialog(mContext); dialog.setTitle(R.string.title_please_wait); dialog.setMessage(OResource.string(mContext, R.string.title_working)); dialog.setCancelable(false); dialog.show(); } @Override protected Void doInBackground(Void... params) { try { OArguments args = new OArguments(); args.add(new JSONArray().put(quotation.getInt("id"))); args.add(new JSONObject()); getServerDataHelper().callMethod("copy_quotation", args); } catch (Exception e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); dialog.dismiss(); if (listener != null) { listener.OnSuccess(); } } @Override protected void onCancelled() { super.onCancelled(); dialog.dismiss(); if (listener != null) { listener.OnCancelled(); } } }.execute(); }
From source file:de.schaeuffelhut.android.openvpn.tun.ShareTunActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_UPLOAD_DEVICE_DETAILS: { ProgressDialog dialog = new ProgressDialog(this); dialog.setTitle("Uploading Device Details"); return dialog; }/* w w w .j av a 2 s . co m*/ case DIALOG_UPLOAD_SUCCESS: { return new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_info) .setTitle("Thank you for sharing!").setMessage("The upload was succesfull.") .setPositiveButton("Close", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { removeDialog(DIALOG_UPLOAD_SUCCESS); finish(); } }).create(); } case DIALOG_UPLOAD_FAILED: { return new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert) .setTitle("Upload failed!").setMessage("Please be so kind and try again later.") .setPositiveButton("Hmm...", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { removeDialog(DIALOG_UPLOAD_SUCCESS); } }).create(); } default: return super.onCreateDialog(id); } }
From source file:com.shafiq.myfeedle.core.MyfeedleComments.java
@Override public void onClick(View v) { if (v == mSend) { if ((mMessage.getText().toString() != null) && (mMessage.getText().toString().length() > 0) && (mSid != null) && (mEsid != null)) { mMessage.setEnabled(false);//from w w w. j av a 2 s .co m mSend.setEnabled(false); // post or comment! final ProgressDialog loadingDialog = new ProgressDialog(this); final AsyncTask<Void, String, String> asyncTask = new AsyncTask<Void, String, String>() { @Override protected String doInBackground(Void... arg0) { List<NameValuePair> params; String message; String response = null; HttpPost httpPost; MyfeedleOAuth myfeedleOAuth; String serviceName = Myfeedle.getServiceName(getResources(), mService); publishProgress(serviceName); switch (mService) { case TWITTER: // limit tweets to 140, breaking up the message if necessary myfeedleOAuth = new MyfeedleOAuth(TWITTER_KEY, TWITTER_SECRET, mToken, mSecret); message = mMessage.getText().toString(); while (message.length() > 0) { final String send; if (message.length() > 140) { // need to break on a word int end = 0; int nextSpace = 0; for (int i = 0, i2 = message.length(); i < i2; i++) { end = nextSpace; if (message.substring(i, i + 1).equals(" ")) { nextSpace = i; } } // in case there are no spaces, just break on 140 if (end == 0) { end = 140; } send = message.substring(0, end); message = message.substring(end + 1); } else { send = message; message = ""; } httpPost = new HttpPost(String.format(TWITTER_UPDATE, TWITTER_BASE_URL)); // resolve Error 417 Expectation by Twitter httpPost.getParams().setBooleanParameter("http.protocol.expect-continue", false); params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair(Sstatus, send)); params.add(new BasicNameValuePair(Sin_reply_to_status_id, mSid)); try { httpPost.setEntity(new UrlEncodedFormEntity(params)); response = MyfeedleHttpClient.httpResponse(mHttpClient, myfeedleOAuth.getSignedRequest(httpPost)); } catch (UnsupportedEncodingException e) { Log.e(TAG, e.toString()); } } break; case FACEBOOK: httpPost = new HttpPost(String.format(FACEBOOK_COMMENTS, FACEBOOK_BASE_URL, mSid, Saccess_token, mToken)); params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair(Smessage, mMessage.getText().toString())); try { httpPost.setEntity(new UrlEncodedFormEntity(params)); response = MyfeedleHttpClient.httpResponse(mHttpClient, httpPost); } catch (UnsupportedEncodingException e) { Log.e(TAG, e.toString()); } break; case MYSPACE: myfeedleOAuth = new MyfeedleOAuth(MYSPACE_KEY, MYSPACE_SECRET, mToken, mSecret); try { httpPost = new HttpPost(String.format(MYSPACE_URL_STATUSMOODCOMMENTS, MYSPACE_BASE_URL, mEsid, mSid)); httpPost.setEntity(new StringEntity(String.format(MYSPACE_STATUSMOODCOMMENTS_BODY, mMessage.getText().toString()))); response = MyfeedleHttpClient.httpResponse(mHttpClient, myfeedleOAuth.getSignedRequest(httpPost)); } catch (IOException e) { Log.e(TAG, e.toString()); } break; case FOURSQUARE: try { message = URLEncoder.encode(mMessage.getText().toString(), "UTF-8"); httpPost = new HttpPost(String.format(FOURSQUARE_ADDCOMMENT, FOURSQUARE_BASE_URL, mSid, message, mToken)); response = MyfeedleHttpClient.httpResponse(mHttpClient, httpPost); } catch (UnsupportedEncodingException e) { Log.e(TAG, e.toString()); } break; case LINKEDIN: myfeedleOAuth = new MyfeedleOAuth(LINKEDIN_KEY, LINKEDIN_SECRET, mToken, mSecret); try { httpPost = new HttpPost( String.format(LINKEDIN_UPDATE_COMMENTS, LINKEDIN_BASE_URL, mSid)); httpPost.setEntity(new StringEntity( String.format(LINKEDIN_COMMENT_BODY, mMessage.getText().toString()))); httpPost.addHeader(new BasicHeader("Content-Type", "application/xml")); response = MyfeedleHttpClient.httpResponse(mHttpClient, myfeedleOAuth.getSignedRequest(httpPost)); } catch (IOException e) { Log.e(TAG, e.toString()); } break; case IDENTICA: // limit tweets to 140, breaking up the message if necessary myfeedleOAuth = new MyfeedleOAuth(IDENTICA_KEY, IDENTICA_SECRET, mToken, mSecret); message = mMessage.getText().toString(); while (message.length() > 0) { final String send; if (message.length() > 140) { // need to break on a word int end = 0; int nextSpace = 0; for (int i = 0, i2 = message.length(); i < i2; i++) { end = nextSpace; if (message.substring(i, i + 1).equals(" ")) { nextSpace = i; } } // in case there are no spaces, just break on 140 if (end == 0) { end = 140; } send = message.substring(0, end); message = message.substring(end + 1); } else { send = message; message = ""; } httpPost = new HttpPost(String.format(IDENTICA_UPDATE, IDENTICA_BASE_URL)); // resolve Error 417 Expectation by Twitter httpPost.getParams().setBooleanParameter("http.protocol.expect-continue", false); params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair(Sstatus, send)); params.add(new BasicNameValuePair(Sin_reply_to_status_id, mSid)); try { httpPost.setEntity(new UrlEncodedFormEntity(params)); response = MyfeedleHttpClient.httpResponse(mHttpClient, myfeedleOAuth.getSignedRequest(httpPost)); } catch (UnsupportedEncodingException e) { Log.e(TAG, e.toString()); } } break; case GOOGLEPLUS: break; case CHATTER: httpPost = new HttpPost(String.format(CHATTER_URL_COMMENT, mChatterInstance, mSid, Uri.encode(mMessage.getText().toString()))); httpPost.setHeader("Authorization", "OAuth " + mChatterToken); response = MyfeedleHttpClient.httpResponse(mHttpClient, httpPost); break; } return ((response == null) && (mService == MYSPACE)) ? null : serviceName + " " + getString(response != null ? R.string.success : R.string.failure); } @Override protected void onProgressUpdate(String... params) { loadingDialog.setMessage(String.format(getString(R.string.sending), params[0])); } @Override protected void onPostExecute(String result) { if (result != null) { (Toast.makeText(MyfeedleComments.this, result, Toast.LENGTH_LONG)).show(); } else if (mService == MYSPACE) { // myspace permissions (Toast.makeText(MyfeedleComments.this, MyfeedleComments.this.getResources() .getStringArray(R.array.service_entries)[MYSPACE] + getString(R.string.failure) + " " + getString(R.string.myspace_permissions_message), Toast.LENGTH_LONG)).show(); } if (loadingDialog.isShowing()) loadingDialog.dismiss(); 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(); } else { (Toast.makeText(MyfeedleComments.this, "error parsing message body", Toast.LENGTH_LONG)).show(); mMessage.setEnabled(true); mSend.setEnabled(true); } } }
From source file:com.nuvolect.securesuite.data.SqlSyncTest.java
private void pingPongProgress(Activity act) { m_pingPongProgressDialog = new ProgressDialog(m_act); m_pingPongProgressDialog.setTitle("Ping Pong Test In Progress"); m_pingPongProgressDialog.setMessage("Starting test..."); m_pingPongProgressDialog.setMax(SqlSyncTest.MAX_PING_PONG_TESTS); m_pingPongProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); m_pingPongProgressDialog.setIndeterminate(false); m_pingPongProgressDialog.setCancelable(false); m_pingPongProgressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { SqlSyncTest.getInstance().stopTest(); m_pingPongProgressDialog.cancel(); return; }//www . j a va2s .c o m }); m_pingPongProgressDialog.setProgress(0); m_pingPongProgressDialog.show(); }
From source file:com.imalu.alyou.activity.FriendlistFragment.java
/** * user???//from w w w. j a v a 2 s . c o 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,false); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), "????", 0).show(); //refresh(); } }); //} // catch (EaseMobException e) { // e.printStackTrace(); // getActivity().runOnUiThread(new Runnable() { // public void run() { // pd.dismiss(); // Toast.makeText(getActivity(), "???", 0).show(); // } // }); // } } }).start(); }
From source file:com.cellobject.oikos.FormActivity.java
/** * For API level 8 or newer. //from w w w . j a v a2 s .c o m */ public Dialog onCreateDialog(final int id, final Bundle args) { if (id == SUBMITTING_DIALOG) { final ProgressDialog dlg = new ProgressDialog(this); dlg.setProgressStyle(ProgressDialog.STYLE_SPINNER); dlg.setMessage(getText(R.string.submitting)); dlg.setIndeterminate(true); return dlg; } return null; }
From source file:com.cellobject.oikos.FormActivity.java
/** * For API level lower than 8. /*from ww w. ja v a 2s . c o m*/ */ public Dialog onCreateDialog(final int id) { if (id == SUBMITTING_DIALOG) { final ProgressDialog dlg = new ProgressDialog(this); dlg.setProgressStyle(ProgressDialog.STYLE_SPINNER); dlg.setMessage(getText(R.string.submitting)); dlg.setIndeterminate(true); return dlg; } return null; }
From source file:net.networksaremadeofstring.rhybudd.ViewZenossEvent.java
/** Called when the activity is first created. */ @Override//w w w.j ava 2 s . co m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); BugSenseHandler.initAndStartSession(ViewZenossEvent.this, "44a76a8c"); settings = PreferenceManager.getDefaultSharedPreferences(this); setContentView(R.layout.view_zenoss_event); try { actionbar = getActionBar(); actionbar.setDisplayHomeAsUpEnabled(true); actionbar.setHomeButtonEnabled(true); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossEvent", "OnCreate", e); } try { ((TextView) findViewById(R.id.EventTitle)).setText(getIntent().getStringExtra("Device")); ((TextView) findViewById(R.id.Summary)).setText(Html.fromHtml(getIntent().getStringExtra("Summary"))); ((TextView) findViewById(R.id.LastTime)).setText(getIntent().getStringExtra("LastTime")); ((TextView) findViewById(R.id.EventCount)) .setText("Count: " + Integer.toString(getIntent().getIntExtra("Count", 0))); } catch (Exception e) { //We don't need to much more than report it because the direct API request will sort it out for us. BugSenseHandler.sendExceptionMessage("ViewZenossEvent", "OnCreate", e); } firstLoadHandler = new Handler() { public void handleMessage(Message msg) { dialog.dismiss(); try { if (EventObject.has("result") && EventObject.getJSONObject("result").getBoolean("success") == true) { //Log.i("Event",EventObject.toString(3)); TextView Title = (TextView) findViewById(R.id.EventTitle); TextView Component = (TextView) findViewById(R.id.Componant); TextView EventClass = (TextView) findViewById(R.id.EventClass); TextView Summary = (TextView) findViewById(R.id.Summary); TextView FirstTime = (TextView) findViewById(R.id.FirstTime); TextView LastTime = (TextView) findViewById(R.id.LastTime); LinearLayout logList; EventDetails = EventObject.getJSONObject("result").getJSONArray("event").getJSONObject(0); try { if (EventDetails.getString("eventState").equals("Acknowledged")) { ((ImageView) findViewById(R.id.ackIcon)) .setImageResource(R.drawable.ic_acknowledged); } } catch (Exception e) { e.printStackTrace(); } //Log.e("EventDetails",EventDetails.toString(3)); try { Title.setText(EventDetails.getString("device_title")); } catch (Exception e) { Title.setText("Unknown Device - Event Details"); } try { Component.setText(EventDetails.getString("component")); } catch (Exception e) { Component.setText("Unknown Component"); } try { EventClass.setText(EventDetails.getString("eventClassKey")); } catch (Exception e) { EventClass.setText("Unknown Event Class"); } try { ImageView img = (ImageView) findViewById(R.id.summaryImage); URLImageParser p = new URLImageParser(img, ViewZenossEvent.this, Summary); Spanned htmlSpan = Html.fromHtml(EventDetails.getString("message"), p, null); Summary.setText(htmlSpan); //Summary.setText(Html.fromHtml(EventDetails.getString("message"))); //((ImageView) findViewById(R.id.summaryImage)).setImageDrawable(p.drawable); //Log.i("Summary",EventDetails.getString("message")); //((TextView) findViewById(R.id.Summary)).setVisibility(View.GONE); //((WebView) findViewById(R.id.summaryWebView)).loadData(EventDetails.getString("message"), "text/html", null); //((WebView) findViewById(R.id.summaryWebView)).loadDataWithBaseURL(null, EventDetails.getString("message"), "text/html", "UTF-8", "about:blank"); try { Summary.setMovementMethod(LinkMovementMethod.getInstance()); } catch (Exception e) { //Worth a shot } } catch (Exception e) { Summary.setText("No Summary available"); } try { FirstTime.setText(EventDetails.getString("firstTime")); } catch (Exception e) { FirstTime.setText("No Start Date Provided"); } try { LastTime.setText(EventDetails.getString("stateChange")); } catch (Exception e) { LastTime.setText("No Recent Date Provided"); } try { ((TextView) findViewById(R.id.EventCount)) .setText("Count: " + EventDetails.getString("count")); } catch (Exception e) { ((TextView) findViewById(R.id.EventCount)).setText("Count: ??"); } try { ((TextView) findViewById(R.id.Agent)).setText(EventDetails.getString("agent")); } catch (Exception e) { ((TextView) findViewById(R.id.Agent)).setText("unknown"); } try { JSONArray Log = EventDetails.getJSONArray("log"); int LogEntryCount = Log.length(); logList = (LinearLayout) findViewById(R.id.LogList); if (LogEntryCount == 0) { /*String[] LogEntries = {"No log entries could be found"}; ((ListView) findViewById(R.id.LogList)).setAdapter(new ArrayAdapter<String>(ViewZenossEvent.this, R.layout.search_simple,LogEntries));*/ TextView newLog = new TextView(ViewZenossEvent.this); newLog.setText("No log entries could be found"); logList.addView(newLog); } else { LogEntries = new String[LogEntryCount]; for (int i = 0; i < LogEntryCount; i++) { //LogEntries[i] = Log.getJSONArray(i).getString(0) + " set " + Log.getJSONArray(i).getString(2) +"\nAt: " + Log.getJSONArray(i).getString(1); TextView newLog = new TextView(ViewZenossEvent.this); newLog.setText(Html.fromHtml("<strong>" + Log.getJSONArray(i).getString(0) + "</strong> wrote " + Log.getJSONArray(i).getString(2) + "\n<br/><strong>At:</strong> " + Log.getJSONArray(i).getString(1))); newLog.setPadding(0, 6, 0, 6); logList.addView(newLog); } /*try { ((ListView) findViewById(R.id.LogList)).setAdapter(new ArrayAdapter<String>(ViewZenossEvent.this, R.layout.search_simple,LogEntries)); } catch(Exception e) { Toast.makeText(getApplicationContext(), "There was an error trying process the log entries for this event.", Toast.LENGTH_SHORT).show(); }*/ } } catch (Exception e) { TextView newLog = new TextView(ViewZenossEvent.this); newLog.setText("No log entries could be found"); newLog.setPadding(0, 6, 0, 6); ((LinearLayout) findViewById(R.id.LogList)).addView(newLog); /*String[] LogEntries = {"No log entries could be found"}; try { ((ListView) findViewById(R.id.LogList)).setAdapter(new ArrayAdapter<String>(ViewZenossEvent.this, R.layout.search_simple,LogEntries)); } catch(Exception e1) { //BugSenseHandler.log("ViewZenossEvent-LogEntries", e1); }*/ } } else { //Log.e("ViewEvent",EventObject.toString(3)); Toast.makeText(ViewZenossEvent.this, "There was an error loading the Event details", Toast.LENGTH_LONG).show(); //finish(); } } catch (Exception e) { Toast.makeText(ViewZenossEvent.this, "An error was encountered parsing the JSON. An error report has been sent.", Toast.LENGTH_LONG).show(); //BugSenseHandler.log("ViewZenossEvent", e); } } }; dialog = new ProgressDialog(this); dialog.setTitle("Contacting Zenoss"); dialog.setMessage("Please wait:\nLoading Event details...."); dialog.show(); dataPreload = new Thread() { public void run() { try { /*if(API == null) { if(settings.getBoolean("httpBasicAuth", false)) { API = new ZenossAPIv2(settings.getString("userName", ""), settings.getString("passWord", ""), settings.getString("URL", ""),settings.getString("BAUser", ""), settings.getString("BAPassword", "")); } else { API = new ZenossAPIv2(settings.getString("userName", ""), settings.getString("passWord", ""), settings.getString("URL", "")); } } EventObject = API.GetEvent(getIntent().getStringExtra("EventID"));*/ if (settings.getBoolean(ZenossAPI.PREFERENCE_IS_ZAAS, false)) { API = new ZenossAPIZaas(); } else { API = new ZenossAPICore(); } ZenossCredentials credentials = new ZenossCredentials(ViewZenossEvent.this); API.Login(credentials); EventObject = API.GetEvent(getIntent().getStringExtra("EventID")); } catch (Exception e) { firstLoadHandler.sendEmptyMessage(0); BugSenseHandler.sendExceptionMessage("ViewZenossEvent", "DataPreloadThread", e); } finally { firstLoadHandler.sendEmptyMessage(1); } } }; dataPreload.start(); }