List of usage examples for android.app ProgressDialog dismiss
@Override public void dismiss()
From source file:com.wenwen.chatuidemo.activity.AddContactActivity.java
/** * contact//from w w w . j ava 2 s . com * * @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.wenwen.chatuidemo.activity.RegisterActivity.java
/** * // w w w .j a v a 2 s . 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:com.mobicage.rogerthat.util.ui.SendMessageView.java
private void copyVideoFile(final Uri selectedVideo) { final ContentResolver cr = mActivity.getContentResolver(); final ProgressDialog progressDialog = showProcessing(); new SafeAsyncTask<Object, Object, Boolean>() { @Override/*from w w w. java2 s.co m*/ protected Boolean safeDoInBackground(Object... params) { L.d("Processing video: " + selectedVideo.toString()); try { if (mTmpUploadFile.getAbsolutePath().equals(selectedVideo.getPath())) { return true; } else { InputStream is = cr.openInputStream(selectedVideo); if (is != null) { try { OutputStream out = new FileOutputStream(mTmpUploadFile); try { IOUtils.copy(is, out, 1024); } finally { out.close(); } } finally { is.close(); } return true; } } } catch (FileNotFoundException e) { L.d(e); } catch (Exception e) { L.bug("Unknown exception occured while processing video: " + selectedVideo.toString(), e); } return false; }; @Override protected void safeOnPostExecute(Boolean result) { progressDialog.dismiss(); if (result) { setVideoSelected(); } else { UIUtils.showLongToast(mActivity, mActivity.getString(R.string.error_please_try_again)); } } @Override protected void safeOnCancelled(Boolean result) { } @Override protected void safeOnProgressUpdate(Object... values) { } @Override protected void safeOnPreExecute() { }; }.execute(); }
From source file:com.sxt.superqq.activity.LoginActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { if (requestCode == REQUEST_CODE_SETNICK) { SuperQQApplication.currentUserNick = data.getStringExtra("edittext"); progressShow = true;/*from w ww . j a v a 2 s .c o m*/ final ProgressDialog pd = new ProgressDialog(LoginActivity.this); pd.setCanceledOnTouchOutside(false); pd.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { progressShow = false; } }); pd.setMessage(getString(R.string.Is_landing)); pd.show(); final long start = System.currentTimeMillis(); // sdk?? EMChatManager.getInstance().login(currentUsername, currentPassword, new EMCallBack() { @Override public void onSuccess() { if (!progressShow) { return; } // ????? SuperQQApplication.getInstance().setUserName(currentUsername); SuperQQApplication.getInstance().setPassword(currentPassword); runOnUiThread(new Runnable() { public void run() { pd.setMessage(getString(R.string.list_is_for)); } }); try { // ** ?logout??? // ** manually load all local groups and // conversations in case we are auto login EMGroupManager.getInstance().loadAllGroups(); EMChatManager.getInstance().loadAllConversations(); //?? processContactsAndGroups(); } catch (Exception e) { e.printStackTrace(); //????? runOnUiThread(new Runnable() { public void run() { pd.dismiss(); SuperQQApplication.getInstance().logout(null); Toast.makeText(getApplicationContext(), R.string.login_failure_failed, 1) .show(); } }); return; } //?nickname ios?nick boolean updatenick = EMChatManager.getInstance() .updateCurrentUserNick(SuperQQApplication.currentUserNick.trim()); if (!updatenick) { Log.e("LoginActivity", "update current user nick fail"); } 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(final int code, final String message) { if (!progressShow) { return; } runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getApplicationContext(), getString(R.string.Login_failed) + message, Toast.LENGTH_SHORT).show(); } }); } }); } } }
From source file:com.example.sujit.myapplication.Get_Taxi.java
private void getDrivers() { final ProgressDialog loading = ProgressDialog.show(this, "Fetching Drivers", "Please wait...", false, false);/*from ww w . j av a 2s.c o m*/ final String SERVICE_URL = "http://192.168.0.101/retrieve.php"; RequestQueue requestQueue = Volley.newRequestQueue(Get_Taxi.this); JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, SERVICE_URL, null, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { mMap.clear(); LatLng latLng1 = new LatLng(currentLatitude, currentLongitude); mMap.addMarker(new MarkerOptions().position(latLng1).title("Your Location")); Log.d("Response Error", response.toString()); try { JSONArray jsonArray = response.getJSONArray("markers"); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObj = jsonArray.getJSONObject(i); double lang = jsonObj.getDouble("longitude"); double lat = jsonObj.getDouble("latitude"); LatLng latLng = new LatLng(lat, lang); //move CameraPosition on first result if (i == 0) { CameraPosition cameraPosition = new CameraPosition.Builder().target(latLng) .zoom(15).build(); mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); } // Create a marker for each city in the JSON data. mMap.addMarker(new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_directions_car)) .title(jsonObj.getString("username")) // .snippet(Integer.toString(jsonObj.getInt("id"))) .position(latLng)); } loading.dismiss(); } catch (JSONException e) { e.printStackTrace(); Log.e("Error Json Exception", e.toString()); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { loading.dismiss(); Toast.makeText(Get_Taxi.this, error.toString(), Toast.LENGTH_LONG).show(); Log.d("abd", "Error: " + error + ">>" + error.networkResponse.statusCode + ">>" + error.getCause() + ">>" + error.getMessage()); } }); requestQueue.add(jsonObjectRequest); }
From source file:com.microsoft.onedrive.apiexplorer.ItemFragment.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { final BaseApplication application = (BaseApplication) getActivity().getApplication(); final IOneDriveClient oneDriveClient = application.getOneDriveClient(); if (requestCode == REQUEST_CODE_SIMPLE_UPLOAD && data != null && data.getData() != null && data.getData().getScheme().equalsIgnoreCase(SCHEME_CONTENT)) { final ProgressDialog dialog = new ProgressDialog(getActivity()); dialog.setTitle(R.string.upload_in_progress_title); dialog.setMessage(getString(R.string.upload_in_progress_message)); dialog.setIndeterminate(false);/* w ww . j a v a 2s. c o m*/ dialog.setCancelable(false); dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setProgressNumberFormat(getString(R.string.upload_in_progress_number_format)); dialog.show(); final AsyncTask<Void, Void, Void> uploadFile = new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(final Void... params) { try { final ContentResolver contentResolver = getActivity().getContentResolver(); final ContentProviderClient contentProvider = contentResolver .acquireContentProviderClient(data.getData()); final byte[] fileInMemory = FileContent.getFileBytes(contentProvider, data.getData()); contentProvider.release(); // Fix up the file name (needed for camera roll photos, etc) final String filename = FileContent.getValidFileName(contentResolver, data.getData()); final Option option = new QueryOption("@name.conflictBehavior", "fail"); oneDriveClient.getDrive().getItems(mItemId).getChildren().byId(filename).getContent() .buildRequest(Collections.singletonList(option)) .put(fileInMemory, new IProgressCallback<Item>() { @Override public void success(final Item item) { dialog.dismiss(); Toast.makeText(getActivity(), application.getString(R.string.upload_complete, item.name), Toast.LENGTH_LONG).show(); refresh(); } @Override public void failure(final ClientException error) { dialog.dismiss(); if (error.isError(OneDriveErrorCodes.NameAlreadyExists)) { Toast.makeText(getActivity(), R.string.upload_failed_name_conflict, Toast.LENGTH_LONG).show(); } else { Toast.makeText(getActivity(), application.getString(R.string.upload_failed, filename), Toast.LENGTH_LONG).show(); } } @Override public void progress(final long current, final long max) { dialog.setProgress((int) current); dialog.setMax((int) max); } }); } catch (final Exception e) { Log.e(getClass().getSimpleName(), e.getMessage()); Log.e(getClass().getSimpleName(), e.toString()); } return null; } }; uploadFile.execute(); } }
From source file:com.jtschohl.androidfirewall.MainActivity.java
/** * Clear logs//from w w w .java 2 s . co m */ private void clearLog() { final Resources res = getResources(); final ProgressDialog progress = ProgressDialog.show(this, res.getString(R.string.working), res.getString(R.string.please_wait), true); final Handler handler = new Handler() { public void handleMessage(Message msg) { try { progress.dismiss(); } catch (Exception ex) { } if (!Api.hasRootAccess(MainActivity.this, true)) return; if (Api.clearLog(MainActivity.this)) { Toast.makeText(MainActivity.this, R.string.log_cleared, Toast.LENGTH_SHORT).show(); } } }; handler.sendEmptyMessageDelayed(0, 100); }
From source file:com.jtschohl.androidfirewall.MainActivity.java
/** * Purge iptable rules, showing a visual indication *///from www . ja va 2 s . co m private void purgeRules() { final Resources res = getResources(); final ProgressDialog progress = ProgressDialog.show(this, res.getString(R.string.working), res.getString(R.string.deleting_rules), true); final Handler handler = new Handler() { public void handleMessage(Message msg) { try { progress.dismiss(); } catch (Exception ex) { } if (!Api.hasRootAccess(MainActivity.this, true)) return; if (Api.purgeIptables(MainActivity.this, true)) { Toast.makeText(MainActivity.this, R.string.rules_deleted, Toast.LENGTH_SHORT).show(); if (abs_menu != null) { final MenuItem item_onoff = abs_menu.findItem(R.id.enableipv4); final MenuItem item_apply = abs_menu.findItem(R.id.applyrules); item_apply.setTitle(R.string.saverules); item_onoff.setChecked(false); } } } }; handler.sendEmptyMessageDelayed(0, 100); }
From source file:com.xperia64.timidityae.FileBrowserFragment.java
public void saveWavPart2(final int position, final String finalval, final String needToRename) { ((TimidityActivity) getActivity()).writeFile(path.get(position), finalval); final ProgressDialog prog; prog = new ProgressDialog(getActivity()); prog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() { @Override//from www .java 2 s . co m public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); prog.setTitle("Converting to WAV"); prog.setMessage("Converting..."); prog.setIndeterminate(false); prog.setCancelable(false); prog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); prog.show(); new Thread(new Runnable() { @Override public void run() { while (!localfinished && prog.isShowing()) { prog.setMax(JNIHandler.maxTime); prog.setProgress(JNIHandler.currTime); try { Thread.sleep(25); } catch (InterruptedException e) { } } if (!localfinished) { JNIHandler.stop(); getActivity().runOnUiThread(new Runnable() { public void run() { Toast.makeText(getActivity(), "Conversion canceled", Toast.LENGTH_SHORT).show(); if (!Globals.keepWav) { if (new File(finalval).exists()) new File(finalval).delete(); } else { getDir(currPath); } } }); } else { getActivity().runOnUiThread(new Runnable() { public void run() { String trueName = finalval; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && Globals.theFold != null && needToRename != null) { if (Globals.renameDocumentFile(getActivity(), finalval, needToRename)) { trueName = needToRename; } else { trueName = "Error"; } } Toast.makeText(getActivity(), "Wrote " + trueName, Toast.LENGTH_SHORT).show(); prog.dismiss(); getDir(currPath); } }); } } }).start(); }
From source file:im.vector.activity.SettingsActivity.java
private void saveChanges(final MXSession session) { LinearLayout linearLayout = mLinearLayoutBySession.get(session); EditText displayNameEditText = (EditText) linearLayout.findViewById(R.id.editText_displayName); // Save things final String nameFromForm = displayNameEditText.getText().toString(); final ApiCallback<Void> changeCallback = UIUtils.buildOnChangeCallback(this); final MyUser myUser = session.getMyUser(); final Button saveButton = (Button) linearLayout.findViewById(R.id.button_save); if (UIUtils.hasFieldChanged(myUser.displayname, nameFromForm)) { myUser.updateDisplayName(nameFromForm, new SimpleApiCallback<Void>(changeCallback) { @Override/* www .j a v a2s . c o m*/ public void onSuccess(Void info) { super.onSuccess(info); updateSaveButton(saveButton); } }); } Uri newAvatarUri = mTmpThumbnailUriBySession.get(session); if (newAvatarUri != null) { Log.d(LOG_TAG, "Selected image to upload: " + newAvatarUri); ResourceUtils.Resource resource = ResourceUtils.openResource(this, newAvatarUri); if (resource == null) { Toast.makeText(SettingsActivity.this, getString(R.string.settings_failed_to_upload_avatar), Toast.LENGTH_LONG).show(); return; } final ProgressDialog progressDialog = ProgressDialog.show(this, null, getString(R.string.message_uploading), true); session.getContentManager().uploadContent(resource.contentStream, null, resource.mimeType, null, new ContentManager.UploadCallback() { @Override public void onUploadProgress(String anUploadId, int percentageProgress) { progressDialog.setMessage( getString(R.string.message_uploading) + " (" + percentageProgress + "%)"); } @Override public void onUploadComplete(String anUploadId, ContentResponse uploadResponse, final int serverResponseCode, String serverErrorMessage) { if (uploadResponse == null) { Toast.makeText(SettingsActivity.this, (null != serverErrorMessage) ? serverErrorMessage : getString(R.string.settings_failed_to_upload_avatar), Toast.LENGTH_LONG).show(); } else { Log.d(LOG_TAG, "Uploaded to " + uploadResponse.contentUri); myUser.updateAvatarUrl(uploadResponse.contentUri, new SimpleApiCallback<Void>(changeCallback) { @Override public void onSuccess(Void info) { super.onSuccess(info); // Reset this because its being set is how we know there's been a change mTmpThumbnailUriBySession.remove(session); updateSaveButton(saveButton); } }); } progressDialog.dismiss(); } }); } }