List of usage examples for android.app ProgressDialog ProgressDialog
public ProgressDialog(Context context)
From source file:edu.mit.mobile.android.locast.accounts.AbsLocastAuthenticatorActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_PROGRESS: final ProgressDialog dialog = new ProgressDialog(this); dialog.setMessage(getText(R.string.login_message_authenticating)); dialog.setIndeterminate(true);/* w ww.jav a 2 s. c om*/ dialog.setCancelable(true); dialog.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { if (BuildConfig.DEBUG) { Log.i(TAG, "dialog cancel has been invoked"); } if (mAuthenticationTask != null) { mAuthenticationTask.cancel(true); mAuthenticationTask = null; finish(); } } }); return dialog; default: return null; } }
From source file:com.piusvelte.sonet.core.SelectFriends.java
protected void loadFriends() { mFriends.clear();/*from w w w.j a v a2 s . co m*/ // SimpleAdapter sa = new SimpleAdapter(SelectFriends.this, mFriends, R.layout.friend, new String[]{Entities.PROFILE, Entities.FRIEND, Entities.ESID}, new int[]{R.id.profile, R.id.name, R.id.selected}); SimpleAdapter sa = new SimpleAdapter(SelectFriends.this, mFriends, R.layout.friend, new String[] { Entities.FRIEND, Entities.ESID }, new int[] { R.id.name, R.id.selected }); setListAdapter(sa); final ProgressDialog loadingDialog = new ProgressDialog(this); final AsyncTask<Long, String, Boolean> asyncTask = new AsyncTask<Long, String, Boolean>() { @Override protected Boolean doInBackground(Long... params) { boolean loadList = false; SonetCrypto sonetCrypto = SonetCrypto.getInstance(getApplicationContext()); // load the session Cursor account = getContentResolver().query(Accounts.getContentUri(SelectFriends.this), new String[] { Accounts.TOKEN, Accounts.SECRET, Accounts.SERVICE }, Accounts._ID + "=?", new String[] { Long.toString(params[0]) }, null); if (account.moveToFirst()) { mToken = sonetCrypto.Decrypt(account.getString(0)); mSecret = sonetCrypto.Decrypt(account.getString(1)); mService = account.getInt(2); } account.close(); String response; switch (mService) { case TWITTER: break; case FACEBOOK: if ((response = SonetHttpClient.httpResponse(mHttpClient, new HttpGet( String.format(FACEBOOK_FRIENDS, FACEBOOK_BASE_URL, Saccess_token, mToken)))) != null) { try { JSONArray friends = new JSONObject(response).getJSONArray(Sdata); for (int i = 0, l = friends.length(); i < l; i++) { JSONObject f = friends.getJSONObject(i); HashMap<String, String> newFriend = new HashMap<String, String>(); newFriend.put(Entities.ESID, f.getString(Sid)); newFriend.put(Entities.PROFILE, String.format(FACEBOOK_PICTURE, f.getString(Sid))); newFriend.put(Entities.FRIEND, f.getString(Sname)); // need to alphabetize if (mFriends.isEmpty()) mFriends.add(newFriend); else { String fullName = f.getString(Sname); int spaceIdx = fullName.lastIndexOf(" "); String newFirstName = null; String newLastName = null; if (spaceIdx == -1) newFirstName = fullName; else { newFirstName = fullName.substring(0, spaceIdx++); newLastName = fullName.substring(spaceIdx); } List<HashMap<String, String>> newFriends = new ArrayList<HashMap<String, String>>(); for (int i2 = 0, l2 = mFriends.size(); i2 < l2; i2++) { HashMap<String, String> oldFriend = mFriends.get(i2); if (newFriend == null) { newFriends.add(oldFriend); } else { fullName = oldFriend.get(Entities.FRIEND); spaceIdx = fullName.lastIndexOf(" "); String oldFirstName = null; String oldLastName = null; if (spaceIdx == -1) oldFirstName = fullName; else { oldFirstName = fullName.substring(0, spaceIdx++); oldLastName = fullName.substring(spaceIdx); } if (newFirstName == null) { newFriends.add(newFriend); newFriend = null; } else { int comparison = oldFirstName.compareToIgnoreCase(newFirstName); if (comparison == 0) { // compare firstnames if (newLastName == null) { newFriends.add(newFriend); newFriend = null; } else if (oldLastName != null) { comparison = oldLastName.compareToIgnoreCase(newLastName); if (comparison == 0) { newFriends.add(newFriend); newFriend = null; } else if (comparison > 0) { newFriends.add(newFriend); newFriend = null; } } } else if (comparison > 0) { newFriends.add(newFriend); newFriend = null; } } newFriends.add(oldFriend); } } if (newFriend != null) newFriends.add(newFriend); mFriends = newFriends; } } loadList = true; } catch (JSONException e) { Log.e(TAG, e.toString()); } } break; case MYSPACE: break; case LINKEDIN: break; case FOURSQUARE: break; case IDENTICA: break; case GOOGLEPLUS: break; case CHATTER: break; } return loadList; } @Override protected void onPostExecute(Boolean loadList) { if (loadList) { // SimpleAdapter sa = new SimpleAdapter(SelectFriends.this, mFriends, R.layout.friend, new String[]{Entities.PROFILE, Entities.FRIEND}, new int[]{R.id.profile, R.id.name}); SimpleAdapter sa = new SimpleAdapter(SelectFriends.this, mFriends, R.layout.friend, new String[] { Entities.FRIEND, Entities.ESID }, new int[] { R.id.name, R.id.selected }); sa.setViewBinder(mViewBinder); setListAdapter(sa); } if (loadingDialog.isShowing()) loadingDialog.dismiss(); } }; 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(mAccountId); }
From source file:fm.smart.r1.activity.CreateSoundActivity.java
public void onClick(View v) { String threegpfile_name = "test.3gp_amr"; String amrfile_name = "test.amr"; File dir = this.getDir("sounds", MODE_WORLD_READABLE); final File threegpfile = new File(dir, threegpfile_name); File amrfile = new File(dir, amrfile_name); String path = threegpfile.getAbsolutePath(); Log.d("CreateSoundActivity", path); Log.d("CreateSoundActivity", (String) button.getText()); if (button.getText().equals("Start")) { try {//from w ww .j a v a 2 s.co m recorder = new MediaRecorder(); // ContentValues values = new ContentValues(3); // // values.put(MediaStore.MediaColumns.TITLE, "test"); // values.put(MediaStore.MediaColumns.DATE_ADDED, // System.currentTimeMillis()); // values.put(MediaStore.MediaColumns.MIME_TYPE, // MediaRecorder.OutputFormat.THREE_GPP); // // ContentResolver contentResolver = new ContentResolver(this); // // Uri base = MediaStore.Audio.INTERNAL_CONTENT_URI; // Uri newUri = contentResolver.insert(base, values); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile(path); recorder.prepare(); button.setText("Stop"); recorder.start(); } catch (Exception e) { Log.w(TAG, e); } } else { FileOutputStream os = null; FileInputStream is = null; try { recorder.stop(); recorder.release(); // Now the object cannot be reused button.setEnabled(false); // ThreegpReader tr = new ThreegpReader(threegpfile); // os = new FileOutputStream(amrfile); // tr.extractAmr(os); is = new FileInputStream(threegpfile); playSound(is.getFD()); final String media_entity = "http://test.com/test.mp3"; final String author = "tansaku"; final String author_url = "http://smart.fm/users/tansaku"; if (Main.isNotLoggedIn(this)) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName(this, LoginActivity.class.getName()); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); LoginActivity.return_to = CreateSoundActivity.class.getName(); LoginActivity.params = new HashMap<String, String>(); LoginActivity.params.put("item_id", item_id); LoginActivity.params.put("list_id", list_id); LoginActivity.params.put("id", id); LoginActivity.params.put("to_record", to_record); LoginActivity.params.put("sound_type", sound_type); startActivity(intent); } else { final ProgressDialog myOtherProgressDialog = new ProgressDialog(this); myOtherProgressDialog.setTitle("Please Wait ..."); myOtherProgressDialog.setMessage("Creating Sound ..."); myOtherProgressDialog.setIndeterminate(true); myOtherProgressDialog.setCancelable(true); final Thread create_sound = new Thread() { public void run() { // TODO make this interruptable .../*if // (!this.isInterrupted())*/ CreateSoundActivity.create_sound_result = createSound(threegpfile, media_entity, author, author_url, "1", id); myOtherProgressDialog.dismiss(); } }; myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { create_sound.interrupt(); } }); OnCancelListener ocl = new OnCancelListener() { public void onCancel(DialogInterface arg0) { create_sound.interrupt(); } }; myOtherProgressDialog.setOnCancelListener(ocl); myOtherProgressDialog.show(); create_sound.start(); } } catch (Exception e) { Log.w(TAG, e); } finally { if (os != null) { try { os.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } if (is != null) { try { is.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } }
From source file:com.github.wakhub.monodict.activity.bean.ActivityHelper.java
/** * Show ProgressDialog// w w w .ja v a2 s.c o m */ @UiThread public void showProgressDialog(String message) { if (progressDialog != null) { return; } progressDialog = new ProgressDialog(activity); progressDialog.setIndeterminate(true); progressDialog.setCancelable(false); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setMessage(message); progressDialog.show(); }
From source file:net.networksaremadeofstring.rhybudd.DeviceList.java
public void Refresh() { if (dialog != null) { dialog.setTitle("Contacting Zenoss..."); dialog.setMessage("Please wait:\nLoading Infrastructure...."); dialog.setCancelable(false);// w ww . j ava 2s . c om if (!dialog.isShowing()) { dialog.show(); } } else { dialog = new ProgressDialog(this); dialog.setTitle("Contacting Zenoss..."); dialog.setMessage("Please wait:\nLoading Infrastructure...."); dialog.setCancelable(false); dialog.show(); } if (listOfZenossDevices != null) listOfZenossDevices.clear(); ((Thread) new Thread() { public void run() { String MessageExtra = ""; try { Message msg = new Message(); Bundle bundle = new Bundle(); ZenossAPI API = null; try { if (PreferenceManager.getDefaultSharedPreferences(DeviceList.this) .getBoolean(ZenossAPI.PREFERENCE_IS_ZAAS, false)) { API = new ZenossAPIZaas(); } else { API = new ZenossAPICore(); } ZenossCredentials credentials = new ZenossCredentials(DeviceList.this); API.Login(credentials); } catch (ConnectTimeoutException cte) { if (cte.getMessage() != null) { bundle.putString("exception", "The connection timed out;\r\n" + cte.getMessage().toString()); msg.setData(bundle); msg.what = 0; handler.sendMessage(msg); //Toast.makeText(DeviceList.this, "The connection timed out;\r\n" + cte.getMessage().toString(), Toast.LENGTH_LONG).show(); } else { bundle.putString("exception", "A time out error was encountered but the exception thrown contains no further information."); msg.setData(bundle); msg.what = 0; handler.sendMessage(msg); //Toast.makeText(DeviceList.this, "A time out error was encountered but the exception thrown contains no further information.", Toast.LENGTH_LONG).show(); } } catch (Exception e) { if (e.getMessage() != null) { bundle.putString("exception", "An error was encountered;\r\n" + e.getMessage().toString()); msg.setData(bundle); msg.what = 0; handler.sendMessage(msg); //Toast.makeText(DeviceList.this, "An error was encountered;\r\n" + e.getMessage().toString(), Toast.LENGTH_LONG).show(); } else { bundle.putString("exception", "An error was encountered but the exception thrown contains no further information."); msg.setData(bundle); msg.what = 0; handler.sendMessage(msg); //Toast.makeText(DeviceList.this, "An error was encountered but the exception thrown contains no further information.", Toast.LENGTH_LONG).show(); } } try { if (API != null) { listOfZenossDevices = API.GetRhybuddDevices(); } else { listOfZenossDevices = null; } } catch (Exception e) { if (e.getMessage() != null) MessageExtra = e.getMessage(); listOfZenossDevices = null; } if (listOfZenossDevices != null && listOfZenossDevices.size() > 0) { DeviceCount = listOfZenossDevices.size(); Message.obtain(); handler.sendEmptyMessage(1); RhybuddDataSource datasource = new RhybuddDataSource(DeviceList.this); datasource.open(); datasource.UpdateRhybuddDevices(listOfZenossDevices); datasource.close(); } else { //Message msg = new Message(); //Bundle bundle = new Bundle(); bundle.putString("exception", "A query to both the local DB and Zenoss API returned no devices. " + MessageExtra); msg.setData(bundle); msg.what = 0; handler.sendMessage(msg); } } catch (Exception e) { //BugSenseHandler.log("DeviceList", e); Message msg = new Message(); Bundle bundle = new Bundle(); bundle.putString("exception", e.getMessage()); msg.setData(bundle); msg.what = 0; handler.sendMessage(msg); } } }).start(); }
From source file:com.google.zxing.client.android.history.HistoryActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { progDialog = new ProgressDialog(this); switch (item.getItemId()) { case R.id.menu_history_upload_text: enviaTodosDados();// w ww .j av a 2 s . co m break; default: return super.onOptionsItemSelected(item); } return true; }
From source file:com.github.wakhub.monodict.activity.settings.DownloadsActivity.java
void startDownload(DownloadsItem downloadsItem) { progressDialog = new ProgressDialog(this); progressDialog.setTitle(R.string.message_in_processing); progressDialog.setIndeterminate(true); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setCancelable(false); dlTask.execute(downloadsItem.getUrl()); }
From source file:com.almarsoft.GroundhogReader.ComposeActivity.java
@Override protected Dialog onCreateDialog(int id) { if (id == ID_DIALOG_POSTING) { ProgressDialog loadingDialog = new ProgressDialog(this); loadingDialog.setMessage(getString(R.string.posting_message)); loadingDialog.setIndeterminate(true); loadingDialog.setCancelable(true); return loadingDialog; }//www . j a va 2 s. co m return super.onCreateDialog(id); }
From source file:org.uoyabause.android.YabauseHandler.java
public void showDialog() { mProgressDialog = new ProgressDialog(this); mProgressDialog.setMessage("Sending..."); mProgressDialog.show();//from w w w . ja va 2s . c o m waiting_reault = true; isShowProgress = true; }