List of usage examples for android.app ProgressDialog dismiss
@Override public void dismiss()
From source file:cn.ucai.superwechart.activity.ContactlistFragment.java
/** * ?// w w w. java 2 s . c om * * @param */ public void deleteContact(final User tobeDeleteUser) { String st1 = getResources().getString(R.string.deleting); final String st2 = getResources().getString(R.string.Delete_failed); final ProgressDialog pd = new ProgressDialog(getActivity()); pd.setMessage(st1); 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()); ((DemoHXSDKHelper) HXSDKHelper.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(), st2 + e.getMessage(), Toast.LENGTH_LONG).show(); } }); } } }).start(); String userName = SuperWeChatApplication.getInstance().getUserName(); OkHttpUtils2<Result> utils2 = new OkHttpUtils2<>(); utils2.setRequestUrl(I.REQUEST_DELETE_CONTACT).addParam(I.Contact.USER_NAME, userName) .addParam(I.Contact.CU_NAME, tobeDeleteUser.getUsername()).targetClass(Result.class) .execute(new OkHttpUtils2.OnCompleteListener<Result>() { @Override public void onSuccess(Result result) { if (result.isRetMsg()) { UserAvatar ua = SuperWeChatApplication.getInstance().getContactMap() .get(tobeDeleteUser.getUsername()); SuperWeChatApplication.getInstance().getUserContactList().remove(ua); SuperWeChatApplication.getInstance().getContactMap() .remove(tobeDeleteUser.getUsername()); getActivity().sendStickyBroadcast(new Intent("update_contact_list")); Log.e(TAG, "delUsername=" + tobeDeleteUser.getUsername()); } } @Override public void onError(String error) { Log.e(TAG, "error=" + error); } }); }
From source file:org.messic.android.smartphone.activities.main.fragments.downloaded.DownloadedFragment.java
private void removeAlbum(final MDMAlbum album, final DownloadedAlbumViewHolder holder) { DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: final ProgressDialog pd = ProgressDialog.show(getActivity(), getActivity().getString(R.string.action_removing_local_album_title), getActivity().getString(R.string.action_removing_local_album_content), true); presenter.removeAlbum(album).subscribe(new Action1<MDMSong>() { @Override//from w w w. j ava 2 s . c om public void call(MDMSong mdmSong) { } }, new Action1<Throwable>() { @Override public void call(Throwable throwable) { Toast.makeText(getActivity(), "Error:" + throwable.getMessage(), Toast.LENGTH_SHORT) .show(); Timber.e(throwable.getMessage(), throwable); throwable.printStackTrace(); } }, new Action0() { @Override public void call() { pd.dismiss(); Toast.makeText(getActivity(), getActivity().getString(R.string.action_local_album_removed) + album.getName(), Toast.LENGTH_SHORT).show(); mAdapter.removeAlbum(holder.getAdapterPosition()); mAdapter.notifyItemRemoved(holder.getAdapterPosition()); } }); break; case DialogInterface.BUTTON_NEGATIVE: // No button clicked break; } } }; android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(getActivity()); builder.setMessage(getActivity().getString(R.string.action_remove_local_album)); builder.setPositiveButton(getActivity().getString(R.string.yes), dialogClickListener); builder.setNegativeButton(getActivity().getString(R.string.no), dialogClickListener); builder.show(); }
From source file:ansteph.com.beecabfordrivers.view.registration.RegistrationFragment.java
private void registerClient() throws JSONException { //Displaying a progress dialog final ProgressDialog loading = ProgressDialog.show(getActivity(), "Registering", "Please wait... you will soon be in our awesome network", false, false); //Getting user data fullName = txtFullName.getText().toString().trim(); email = txtEmail.getText().toString().trim(); mobile = txtMobile.getText().toString().trim(); pwd = txtPassword.getText().toString().trim(); companyname = txtCompanyName.getText().toString().trim(); carmodel = txtCarModel.getText().toString().trim(); numPlate = txtNumPlate.getText().toString().trim(); licence = txtLicence.getText().toString().trim(); year = txtYear.getText().toString().trim(); //create the string request StringRequest stringRequest = new StringRequest(Request.Method.POST, Config.REGISTER_URL, new Response.Listener<String>() { @Override// w w w. jav a2s. co m public void onResponse(String response) { loading.dismiss(); try { //creating the Json object from the response JSONObject jsonResponse = new JSONObject(response); boolean error = jsonResponse.getBoolean(Config.ERROR_RESPONSE); String serverMsg = jsonResponse.getString("message"); //if it is success if (!error) { //asking user to confirm OTP confirmOtp(); } else { Toast.makeText(getActivity(), serverMsg, Toast.LENGTH_LONG).show(); } /* if(jsonResponse.getString(Config.TAG_RESPONSE).equalsIgnoreCase("success")){ //asking user to confirm OTP confirmOtp(); }else{ //if not succcess Toast.makeText(getActivity(), "Welcome back to our network, we happy to have you back", Toast.LENGTH_LONG).show(); }*/ } catch (JSONException e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { loading.dismiss(); Toast.makeText(getActivity(), error.getMessage(), Toast.LENGTH_LONG).show(); } }) { @Override protected Map<String, String> getParams() throws AuthFailureError { Map<String, String> params = new HashMap<>(); //Adding the parameters to the request name','email','mobile','password', 'company_name', 'carmodel', 'numplate', 'license', 'year params.put(Config.KEY_NAME, fullName); params.put(Config.KEY_EMAIL, email); params.put(Config.KEY_MOBILE, mobile); params.put(Config.KEY_COMNAME, companyname); params.put(Config.KEY_CARMODEL, carmodel); params.put(Config.KEY_NUMPLATE, numPlate); params.put(Config.KEY_LICENSE, licence); params.put(Config.KEY_YEAR, year); params.put(Config.KEY_PWD, pwd); return params; } }; //Adding request the queue requestQueue.add(stringRequest); }
From source file:com.app.khclub.base.easeim.activity.ContactlistFragment.java
/** * user???//from w ww .ja v a2 s .c o m */ private void moveToBlacklist(final String username) { final ProgressDialog pd = new ProgressDialog(getActivity()); String st1 = getResources().getString(R.string.Is_moved_into_blacklist); final String st2 = getResources().getString(R.string.Move_into_blacklist_success); final String st3 = getResources().getString(R.string.Move_into_blacklist_failure); pd.setMessage(st1); 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(), st2, 0).show(); refresh(); } }); } catch (EaseMobException e) { e.printStackTrace(); getActivity().runOnUiThread(new Runnable() { public void run() { pd.dismiss(); Toast.makeText(getActivity(), st3, 0).show(); } }); } } }).start(); }
From source file:piuk.blockchain.android.ui.NewAccountFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.new_account_dialog, null); final Button createButton = (Button) view.findViewById(R.id.create_button); final TextView password = (TextView) view.findViewById(R.id.password); final TextView password2 = (TextView) view.findViewById(R.id.password2); final TextView captcha = (TextView) view.findViewById(R.id.captcha); refreshCaptcha(view);/* w w w.j av a 2 s .c o m*/ createButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { final WalletApplication application = (WalletApplication) getActivity().getApplication(); if (password.getText().length() < 10 || password.getText().length() > 255) { Toast.makeText(application, R.string.new_account_password_length_error, Toast.LENGTH_LONG) .show(); return; } if (!password.getText().toString().equals(password2.getText().toString())) { Toast.makeText(application, R.string.new_account_password_mismatch_error, Toast.LENGTH_LONG) .show(); return; } if (captcha.getText().length() == 0) { Toast.makeText(application, R.string.new_account_no_kaptcha_error, Toast.LENGTH_LONG).show(); return; } final ProgressDialog progressDialog = ProgressDialog.show(getActivity(), "", getString(R.string.creating_account), true); progressDialog.show(); final Handler handler = new Handler(); new Thread() { @Override public void run() { try { if (!application.getRemoteWallet().isNew()) return; application.getRemoteWallet().setTemporyPassword(password.getText().toString()); if (!application.getRemoteWallet().remoteSave(captcha.getText().toString())) { throw new Exception("Unknown Error inserting wallet"); } EventListeners.invokeWalletDidChange(); application.hasDecryptionError = false; handler.post(new Runnable() { public void run() { progressDialog.dismiss(); dismiss(); Toast.makeText(getActivity().getApplication(), R.string.new_account_success, Toast.LENGTH_LONG).show(); Editor edit = PreferenceManager .getDefaultSharedPreferences(application.getApplicationContext()) .edit(); edit.putString("guid", application.getRemoteWallet().getGUID()); edit.putString("sharedKey", application.getRemoteWallet().getSharedKey()); edit.putString("password", password.getText().toString()); if (edit.commit()) { application.checkIfWalletHasUpdatedAndFetchTransactions(); } else { Activity activity = (Activity) getActivity(); final Builder dialog = new AlertDialog.Builder(activity); dialog.setTitle(R.string.error_pairing_wallet); dialog.setMessage("Error saving preferences"); dialog.setNeutralButton(R.string.button_dismiss, null); dialog.show(); } } }); } catch (final Exception e) { e.printStackTrace(); handler.post(new Runnable() { public void run() { progressDialog.dismiss(); refreshCaptcha(view); captcha.setText(null); Toast.makeText(getActivity().getApplication(), e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } }); } } }.start(); } }); return view; }
From source file:org.namelessrom.devicecontrol.appmanager.AppDetailsActivity.java
private void uninstall() { // try via native package manager api AppHelper.uninstallPackage(mPm, mAppItem.getPackageName()); // build our command final StringBuilder sb = new StringBuilder(); sb.append(String.format("pm uninstall %s;", mAppItem.getPackageName())); if (mAppItem.isSystemApp()) { sb.append("busybox mount -o rw,remount /system;"); }/* w w w . ja va 2 s . c o m*/ sb.append(String.format("rm -rf %s;", mAppItem.getApplicationInfo().publicSourceDir)); sb.append(String.format("rm -rf %s;", mAppItem.getApplicationInfo().sourceDir)); sb.append(String.format("rm -rf %s;", mAppItem.getApplicationInfo().dataDir)); if (mAppItem.isSystemApp()) { sb.append("busybox mount -o ro,remount /system;"); } final String cmd = sb.toString(); Logger.v(this, cmd); // create the dialog (will not be shown for a long amount of time though) final ProgressDialog dialog; dialog = new ProgressDialog(this); dialog.setTitle(R.string.uninstalling); dialog.setMessage(getString(R.string.applying_wait)); dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); dialog.setCancelable(false); new AsyncTask<Void, Void, Void>() { @Override protected void onPreExecute() { dialog.show(); } @Override protected Void doInBackground(Void... voids) { Utils.runRootCommand(cmd, true); return null; } @Override protected void onPostExecute(Void aVoid) { dialog.dismiss(); Toast.makeText(AppDetailsActivity.this, getString(R.string.uninstall_success, mAppItem.getLabel()), Toast.LENGTH_SHORT).show(); mAppItem = null; finish(); } }.execute(); }
From source file:com.zhenlaidian.ui.InputCarNumberActivity.java
public void getParkInfo(String carnumber) throws UnsupportedEncodingException { if (!IsNetWork.IsHaveInternet(this)) { Toast.makeText(this, "???", Toast.LENGTH_SHORT).show(); return;//from w w w .ja va 2 s.c o m } String car = URLEncoder.encode(carnumber, "utf-8"); AQuery aQuery = new AQuery(InputCarNumberActivity.this); String path = baseurl; String url = path + "collectorrequest.do?action=getecsorder&token=" + token + "&car_number=" + URLEncoder.encode(car, "utf-8") + "&berthid=" + SharedPreferencesUtils.getIntance(this).getberthid() + "&version=" + CommontUtils.getVersion(this) + "&out=json"; MyLog.w("InputCarNumberActivity-->>", "?URL-->>" + url); final ProgressDialog dialog = ProgressDialog.show(InputCarNumberActivity.this, "...", "???...", true, true); dialog.setCancelable(false); aQuery.ajax(url, String.class, new AjaxCallback<String>() { @Override public void callback(String url, String object, AjaxStatus status) { dialog.dismiss(); if (getIntent().getStringExtra("from").equals("input")) { // if (object != null) { Gson gson = new Gson(); listEntity = gson.fromJson(object, ZhuiJiaoListEntity.class); MyLog.i("ParkingInfoActivity-->>", "??" + listEntity.toString()); ismonthuser = listEntity.getIsmonthuser(); if (listEntity.getResult().equals("0")) { //?? //? putStringToPreference("preorderid", listEntity.getOrderid()); if (getBooleanFromPreference("next")) { //? intent2(); } else { entity = listEntity.getOrders(); Intent i = new Intent(context, ZhuiJiaoListActivity.class); putStringToPreference("carnumber", et_carnumber.getText().toString()); i.putExtra("list", entity); startActivityForResult(i, Constant.BACK_FROM_OWE); } } else if (listEntity.getResult().equals("1")) { //?? putStringToPreference("preorderid", listEntity.getOrderid()); intent2(); } else if (listEntity.getResult().equals("-2")) { new AlertDialog.Builder(InputCarNumberActivity.this).setTitle("??") .setIcon(R.drawable.app_icon_32).setMessage("" + listEntity.getErrmsg()) .setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { putStringToPreference("preorderid", listEntity.getOrderid()); entity = listEntity.getOrders(); if (getBooleanFromPreference("next")) { //? intent2(); } else if (!(entity != null && entity.size() > 0)) { //? intent2(); } else { Intent i = new Intent(context, ZhuiJiaoListActivity.class); putStringToPreference("carnumber", et_carnumber.getText().toString()); i.putExtra("list", entity); startActivityForResult(i, Constant.BACK_FROM_OWE); } } }).setNegativeButton("?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }).create().show(); } else { // -1 -3 new AlertDialog.Builder(InputCarNumberActivity.this).setTitle("??") .setIcon(R.drawable.app_icon_32).setMessage("" + listEntity.getErrmsg()) .setPositiveButton("", null).create().show(); } } else { putStringToPreference("preorderid", ""); intent2(); } } else { //? if (object != null) { Gson gson = new Gson(); listEntity = gson.fromJson(object, ZhuiJiaoListEntity.class); MyLog.i("ParkingInfoActivity-->>", "??" + listEntity.toString()); if (listEntity.getResult().equals("1")) { //?? CommontUtils.toast(context, ""); finish(); } else { //?? entity = listEntity.getOrders(); if (CommontUtils.checkList(entity)) { Intent i = new Intent(context, ZhuiJiaoListActivity.class); putStringToPreference("carnumber", et_carnumber.getText().toString()); i.putExtra("list", entity); startActivityForResult(i, Constant.BACK_FROM_OWE); } else { CommontUtils.toast(context, ""); finish(); } } } else { CommontUtils.toast(context, ""); finish(); } } } }.timeout(5000)); }
From source file:com.jakebasile.android.linkshrink.ShortenUrl.java
private void shortenWithIsgd(final String longUrl) { String display = String.format(getResources().getString(R.string.shortening_message), ISGD); final ProgressDialog pd = ProgressDialog.show(ShortenUrl.this, getResources().getString(R.string.shortening_title), display, true); new Thread() { @Override/*from ww w . j a v a 2 s. c om*/ public void run() { try { String requestUrl = String.format(ISGD_URL, URLEncoder.encode(longUrl)); ByteArrayOutputStream stream = new ByteArrayOutputStream(); HttpClient httpClient = new DefaultHttpClient(); HttpGet request = new HttpGet(new URI(requestUrl)); HttpResponse response = httpClient.execute(request); if (response.getStatusLine().getStatusCode() == 200) { response.getEntity().writeTo(stream); _shortUrl = new String(stream.toByteArray()).trim(); } else { _shortUrl = null; } _handler.sendEmptyMessage(0); } catch (IOException ex) { _handler.sendEmptyMessage(1); } catch (URISyntaxException ex) { _handler.sendEmptyMessage(2); } finally { pd.dismiss(); } } }.start(); }
From source file:net.bytten.comicviewer.ComicViewerActivity.java
public void loadComicImage(Uri uri) { webview.clearView();/*from w w w .j a v a 2 s. c o m*/ final ProgressDialog pd = ProgressDialog.show(this, getStringAppName(), "Loading comic image...", false, true, new OnCancelListener() { public void onCancel(DialogInterface dialog) { webview.stopLoading(); webview.requestFocus(); } }); pd.setProgress(0); webview.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); pd.dismiss(); webview.requestFocus(); } }); webview.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { super.onProgressChanged(view, newProgress); pd.setProgress(newProgress * 100); } }); if ("".equals(uri.toString())) { failed("Couldn't identify image in post"); webview.loadUrl("about:blank"); } else { webview.loadUrl(uri.toString()); } }
From source file:cn.hbm.superwechat.activity.ContactlistFragment.java
/** * ?/*from www .ja v a 2s .c o m*/ * * @param tobeDeleteUser */ public void deleteContact(final User tobeDeleteUser) { String st1 = getResources().getString(R.string.deleting); final String st2 = getResources().getString(R.string.Delete_failed); final ProgressDialog pd = new ProgressDialog(getActivity()); pd.setMessage(st1); pd.setCanceledOnTouchOutside(false); pd.show(); new Thread(new Runnable() { public void run() { try { EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername()); //?? deleteMyContact(toBeProcessUser); // db? UserDao dao = new UserDao(getActivity()); dao.deleteContact(tobeDeleteUser.getUsername()); ((DemoHXSDKHelper) HXSDKHelper.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(), st2 + e.getMessage(), Toast.LENGTH_SHORT).show(); } }); } } }).start(); }