List of usage examples for android.app ProgressDialog dismiss
@Override public void dismiss()
From source file:com.hzx.luoyechat.activity.SettingsFragment.java
void logout() { final ProgressDialog pd = new ProgressDialog(getActivity()); String st = getResources().getString(R.string.Are_logged_out); pd.setMessage(st);//from w w w .j ava 2 s .c o m pd.setCanceledOnTouchOutside(false); pd.show(); DemoHXSDKHelper.getInstance().logout(true, new EMCallBack() { @Override public void onSuccess() { getActivity().runOnUiThread(new Runnable() { public void run() { if (pd.isShowing()) { pd.dismiss(); // ?? getActivity().finish(); startActivity(new Intent(getActivity(), LoginActivity.class)); } } }); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, String message) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { pd.dismiss(); Snackbar.make(check_new_version, "unbind devicetokens failed", Snackbar.LENGTH_SHORT) .show(); } }); } }); }
From source file:com.ccxt.whl.activity.RegisterActivity.java
public void reg(final String username, final String pwd) { if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(pwd)) { final ProgressDialog pd = new ProgressDialog(this); pd.setMessage("..."); pd.show();/*from www . jav a2 s . c o m*/ new Thread(new Runnable() { public void run() { try { // sdk EMChatManager.getInstance().createAccountOnServer(username, pwd); runOnUiThread(new Runnable() { public void run() { if (!RegisterActivity.this.isFinishing()) pd.dismiss(); RequestParams params = new RequestParams(); params.add("user", username); if (DemoApplication.getInstance().getlastloc() != null) { double Latitude = DemoApplication.getInstance().getlastloc().getLatitude(); double Longitude = DemoApplication.getInstance().getlastloc().getLongitude(); String adr = DemoApplication.getInstance().getlastloc().getAddrStr(); params.add("jiedao", adr); } HttpRestClient.get(Constant.REGISTER_URL_HUIZHI, params, new BaseJsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, String rawJsonResponse, Object response) { // TODO Auto-generated method stub Log.d("login_res_json" + rawJsonResponse); if (CommonUtils.isNullOrEmpty(rawJsonResponse)) { Toast.makeText(getApplicationContext(), "?,?", 0).show(); return; } Map<String, Object> lm = JsonToMapList.getMap(rawJsonResponse); if (lm.get("status").toString() != null && lm.get("status").toString().equals("yes")) { Map<String, Object> result = JsonToMapList .getMap(lm.get("result").toString()); String resultStr = "status:" + lm.get("status") + "\n" + "message:" + lm.get("message") + "\n" + "result:" + lm.get("result") + "\n"; Log.d("login_res_obj" + resultStr); pd.dismiss(); // ??? // DemoApplication.getInstance().setUserName(username); DemoApplication.getInstance().setUser(username); Toast.makeText(getApplicationContext(), "?", 0) .show(); finish(); } else { Toast.makeText(getApplicationContext(), lm.get("message").toString(), 0).show(); pd.dismiss(); } } @Override public void onFailure(int statusCode, Header[] headers, Throwable throwable, String rawJsonData, Object errorResponse) { // TODO Auto-generated method stub Toast.makeText(getApplicationContext(), "??", 0).show(); } @Override protected Object parseResponse(String rawJsonData, boolean isFailure) throws Throwable { // TODO Auto-generated method stub return null; } }); } }); } catch (final Exception e) { runOnUiThread(new Runnable() { public void run() { if (!RegisterActivity.this.isFinishing()) pd.dismiss(); if (e != null && e.getMessage() != null) { String errorMsg = e.getMessage(); if (errorMsg.indexOf("EMNetworkUnconnectedException") != -1) { Toast.makeText(getApplicationContext(), "?", 0).show(); } else if (errorMsg.indexOf("conflict") != -1) { //???? Toast.makeText(getApplicationContext(), "??", 0) .show(); } else if (errorMsg.indexOf("not support the capital letters") != -1) { Toast.makeText(getApplicationContext(), "??????", 0).show(); } else { Toast.makeText(getApplicationContext(), ": " + e.getMessage(), 1).show(); } } else { Toast.makeText(getApplicationContext(), ": ", 1).show(); } } }); } } }).start(); } }
From source file:com.rastating.droidbeard.fragments.ShowFragment.java
@Override public void onClick(View v) { if (v == mPauseButton) { mShow.setPaused(!mShow.getPaused()); setupPauseViews(mShow.getPaused()); new SetPausedTask(ShowFragment.this.getActivity(), mShowSummary.getTvDbId()).start(mShow.getPaused()); } else if (v == mDeleteButton) { new AlertDialog.Builder(ShowFragment.this.getActivity()).setTitle("Confirm") .setMessage("Are you sure you want to delete this show?") .setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface d, int whichButton) { final ProgressDialog dialog = createProgressDialog("Deleting Show", "Please wait..."); dialog.show();/*from w ww . ja v a 2 s . co m*/ DeleteShowTask task = new DeleteShowTask(ShowFragment.this.getActivity()); task.addResponseListener(new ApiResponseListener<Boolean>() { @Override public void onApiRequestFinished(SickbeardAsyncTask sender, Boolean result) { dialog.dismiss(); getMainActivity().displayAndRefreshShowsFragment(); } }); task.start(mShowSummary.getTvDbId()); } }).setNegativeButton("No", null).show(); } }
From source file:com.easemob.chatuidemo.adapter.NewFriendsMsgAdapter.java
/** * ???//from ww w .java2 s. co m * * @param button * @param username */ public void acceptInvitation(final Button button, final InviteMessage msg) { final ProgressDialog pd = new ProgressDialog(context); String str1 = context.getResources().getString(R.string.Are_agree_with); final String str2 = context.getResources().getString(R.string.Has_agreed_to); final String str3 = context.getResources().getString(R.string.Agree_with_failure); pd.setMessage(str1); pd.setCanceledOnTouchOutside(false); pd.show(); RequestQueue requestQueue = Volley.newRequestQueue(context); requestQueue.start(); requestQueue.add(new AutoLoginRequest(context, Request.Method.POST, Model.PathLoad, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { pd.dismiss(); button.setText(str2); msg.setStatus(InviteMesageStatus.AGREED); // db ContentValues values = new ContentValues(); values.put(InviteMessgeDao.COLUMN_NAME_STATUS, msg.getStatus().ordinal()); messgeDao.updateMessage(msg.getId(), values); button.setBackgroundDrawable(null); button.setEnabled(false); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(context, str3 + error.getMessage(), 1).show(); } }) { @Override protected void setParams(Map<String, String> params) { if (msg.getGroupId() == null) {//??? params.put("sys", "msg"); params.put("ctrl", "msger"); params.put("action", "add_friend"); params.put("friend_name", msg.getFrom()); } else //?? { params.put("sys", "msg"); params.put("ctrl", "msger"); params.put("action", "agree_group"); params.put("stranger", msg.getFrom()); params.put("group_sn", msg.getGroupId()); } } }); }
From source file:ca.rmen.android.scrumchatter.main.MainActivity.java
/** * Share a file using an intent chooser. * //from w w w . jav a 2 s . c o m * @param fileExport The object responsible for creating the file to share. */ private void shareFile(final FileExport fileExport) { final ProgressDialog progressDialog = ProgressDialog.show(this, null, getString(R.string.progress_dialog_message), true); AsyncTask<Void, Void, Boolean> asyncTask = new AsyncTask<Void, Void, Boolean>() { @Override protected Boolean doInBackground(Void... params) { return fileExport.export(); } @Override protected void onPreExecute() { progressDialog.show(); } @Override protected void onPostExecute(Boolean success) { progressDialog.dismiss(); if (!success) Toast.makeText(MainActivity.this, R.string.export_error, Toast.LENGTH_LONG).show(); } }; asyncTask.execute(); }
From source file:com.fortysevendeg.labs.bbc.rest.android.activities.BeerActivity.java
/** * Add beer on server/*from w ww . j av a 2s .c o m*/ */ private void addBeer() { if (TextUtils.isEmpty(etAlcohol.getText().toString()) || TextUtils.isEmpty(etName.getText().toString())) { Toast.makeText(BeerActivity.this, R.string.fieldsEmpty, Toast.LENGTH_SHORT).show(); return; } 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(); BeerRequest beerRequest = new BeerRequest(); beerRequest.setAvb(Double.parseDouble(etAlcohol.getText().toString())); beerRequest.setName(etName.getText().toString()); beerRequest.setDescription(etDescription.getText().toString()); APIService.get().addBeer(beerRequest, new ContextAwareAPIDelegate<BeerResponse>(this, BeerResponse.class) { @Override public void onResults(BeerResponse beerResponse) { progressDialog.dismiss(); Toast.makeText(BeerActivity.this, R.string.beerSaved, 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.color.kid.kidpaint.activity.OptionsActivity.java
protected void loadBitmapFromUriAndRun(final Uri uri, final RunnableWithBitmap runnable) { String loadMessge = getResources().getString(R.string.dialog_load); final ProgressDialog dialog = ProgressDialog.show(OptionsActivity.this, "", loadMessge, true); Thread thread = new Thread("loadBitmapFromUriAndRun") { @Override/*from ww w.j a v a2s .c o m*/ public void run() { Bitmap bitmap = null; try { bitmap = FileIO.getBitmapFromUri(uri); } catch (Exception e) { loadBitmapFailed = true; } if (bitmap != null) { runnable.run(bitmap); } else { loadBitmapFailed = true; } dialog.dismiss(); PaintroidApplication.currentTool.resetInternalState(Tool.StateChange.NEW_IMAGE_LOADED); if (loadBitmapFailed) { loadBitmapFailed = false; new InfoDialog(InfoDialog.DialogType.WARNING, R.string.dialog_loading_image_failed_title, R.string.dialog_loading_image_failed_text).show(getSupportFragmentManager(), "loadbitmapdialogerror"); } else { if (!(PaintroidApplication.currentTool instanceof ImportTool)) { PaintroidApplication.savedPictureUri = uri; } } } }; thread.start(); }
From source file:com.sxit.dreamiya.fragment.SettingsFragment.java
void logout() { final ProgressDialog pd = new ProgressDialog(getActivity()); String st = getResources().getString(R.string.Are_logged_out); pd.setMessage(st);/*from w w w . jav a 2 s. c om*/ pd.setCanceledOnTouchOutside(false); pd.show(); DemoApplication.getInstance().logout(new EMCallBack() { @Override public void onSuccess() { getActivity().runOnUiThread(new Runnable() { public void run() { // ?? DBHelper dbh = new DBHelper(getActivity()); int db_res_int = dbh.clearAllUserInfo(); pd.dismiss(); // ?? ((MainActivity) getActivity()).finish(); startActivity(new Intent(getActivity(), LoginActivity.class)); } }); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, String message) { } }); }
From source file:im.afterclass.android.fragment.ContactlistFragment.java
/** * ?/*from w ww .j av a 2 s. c o m*/ * @param toDeleteUser */ public void deleteContact(final User 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()); DemoApplication.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(), Toast.LENGTH_SHORT) .show(); } }); } } }).start(); }
From source file:com.ysls.imhere.fragment.ContactlistFragment.java
/** * ?//from w ww.j av a 2s. c om * * @param toDeleteUser */ public void deleteContact(final User 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()); MyApplication.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(); }