Example usage for android.app ProgressDialog dismiss

List of usage examples for android.app ProgressDialog dismiss

Introduction

In this page you can find the example usage for android.app ProgressDialog dismiss.

Prototype

@Override
public void dismiss() 

Source Link

Document

Dismiss this dialog, removing it from the screen.

Usage

From source file:com.youti.chat.activity.ContactlistFragment.java

/**
 * ?/*from  w  ww  .ja v a2s  .com*/
 * 
 * @param toDeleteUser
 */
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());
                YoutiApplication.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(), 1).show();
                    }
                });

            }

        }
    }).start();

}

From source file:org.telegram.ui.PrivacyControlActivity.java

private void applyCurrentPrivacySettings() {
    TLRPC.TL_account_setPrivacy req = new TLRPC.TL_account_setPrivacy();
    if (isGroup) {
        req.key = new TLRPC.TL_inputPrivacyKeyChatInvite();
    } else {//from ww w .j a  v a  2  s. c  o  m
        req.key = new TLRPC.TL_inputPrivacyKeyStatusTimestamp();
    }
    if (currentType != 0 && currentPlus.size() > 0) {
        TLRPC.TL_inputPrivacyValueAllowUsers rule = new TLRPC.TL_inputPrivacyValueAllowUsers();
        for (int a = 0; a < currentPlus.size(); a++) {
            TLRPC.User user = MessagesController.getInstance().getUser(currentPlus.get(a));
            if (user != null) {
                TLRPC.InputUser inputUser = MessagesController.getInputUser(user);
                if (inputUser != null) {
                    rule.users.add(inputUser);
                }
            }
        }
        req.rules.add(rule);
    }
    if (currentType != 1 && currentMinus.size() > 0) {
        TLRPC.TL_inputPrivacyValueDisallowUsers rule = new TLRPC.TL_inputPrivacyValueDisallowUsers();
        for (int a = 0; a < currentMinus.size(); a++) {
            TLRPC.User user = MessagesController.getInstance().getUser(currentMinus.get(a));
            if (user != null) {
                TLRPC.InputUser inputUser = MessagesController.getInputUser(user);
                if (inputUser != null) {
                    rule.users.add(inputUser);
                }
            }
        }
        req.rules.add(rule);
    }
    if (currentType == 0) {
        req.rules.add(new TLRPC.TL_inputPrivacyValueAllowAll());
    } else if (currentType == 1) {
        req.rules.add(new TLRPC.TL_inputPrivacyValueDisallowAll());
    } else if (currentType == 2) {
        req.rules.add(new TLRPC.TL_inputPrivacyValueAllowContacts());
    }
    ProgressDialog progressDialog = null;
    if (getParentActivity() != null) {
        progressDialog = new ProgressDialog(getParentActivity());
        progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
        progressDialog.setCanceledOnTouchOutside(false);
        progressDialog.setCancelable(false);
        progressDialog.show();
    }
    final ProgressDialog progressDialogFinal = progressDialog;
    ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
        @Override
        public void run(final TLObject response, final TLRPC.TL_error error) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public void run() {
                    try {
                        if (progressDialogFinal != null) {
                            progressDialogFinal.dismiss();
                        }
                    } catch (Exception e) {
                        FileLog.e("tmessages", e);
                    }
                    if (error == null) {
                        finishFragment();
                        TLRPC.TL_account_privacyRules rules = (TLRPC.TL_account_privacyRules) response;
                        MessagesController.getInstance().putUsers(rules.users, false);
                        ContactsController.getInstance().setPrivacyRules(rules.rules, isGroup);
                    } else {
                        showErrorAlert();
                    }
                }
            });
        }
    }, ConnectionsManager.RequestFlagFailOnServerErrors);
}

From source file:at.tugraz.kmi.energy2live.remote.E2LNetworkConnection.java

private void postData(final ACTION a, final String url, final List<NameValuePair> nameValuePairs) {
    String message = null;/*from  w  ww  .  j a  va2  s  . co  m*/
    switch (a) {
    case LOGIN:
        message = mContext.getString(R.string.msg_remote_post_login);
        break;
    case REGISTER:
        message = mContext.getString(R.string.msg_remote_post_register);
        break;
    case ACTIVITY:
        message = mContext.getString(R.string.msg_remote_post_activity);
        break;
    }
    final ProgressDialog progressDialog = ProgressDialog.show(mContext, "", message, true);
    Thread thread = new Thread() {
        @Override
        public void run() {
            HttpParams httpParameters = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(httpParameters, 4000);
            HttpClient httpclient = new DefaultHttpClient(httpParameters);
            HttpPost httppost = new HttpPost(url);
            HttpResponse response = null;

            try {
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                response = httpclient.execute(httppost);
            } catch (ClientProtocolException e) {
                Log.e("E2L", "Cannot post data\n", e);
            } catch (IOException e) {
                Log.e("E2L", "Cannot post data\n", e);
            } finally {
                progressDialog.dismiss();
                postDataDone(a, response);
            }
        }
    };
    thread.start();
}

From source file:com.quickcar.thuexe.UI.ListPassengerActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    GPSTracker gps = new GPSTracker(mContext);
    if (!gps.canGetLocation()) {
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setTitle("Thng bo"); // GPS not found
        builder.setMessage(//ww w  .j a v  a  2  s. co  m
                "Chc nng ny cn ly v tr hin ti ca bn.Bn c mun bt nh v?"); // Want to enable?
        builder.setPositiveButton("Tip tc", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialogInterface, int i) {
                startActivityForResult(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS),
                        1);
            }
        });
        builder.setNegativeButton("Khng", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        builder.create().show();
        return;
    }
    final ProgressDialog locate = new ProgressDialog(mContext);
    locate.setIndeterminate(true);
    locate.setCancelable(false);
    locate.setMessage("?ang ly v tr...");
    locate.show();
    if (gps.getLongitude() == 0 && gps.getLatitude() == 0) {
        gps.getLocationCoodinate(new GPSTracker.LocateListener() {
            @Override
            public void onLocate(double mlongitude, double mlatitude) {
                if (dataMap != null)
                    dataMap.OnDataMap();
                if (dataPasser != null)
                    dataPasser.onDataPass();
                locate.dismiss();
                //Toast.makeText(mContext, mlongitude+","+mlatitude,Toast.LENGTH_SHORT).show();
            }
        });
    } else {
        if (dataMap != null)
            dataMap.OnDataMap();
        if (dataPasser != null)
            dataPasser.onDataPass();
        //Toast.makeText(mContext, gps.getLongitude()+","+gps.getLatitude(),Toast.LENGTH_SHORT).show();
        locate.dismiss();
    }

}

From source file:com.doplgangr.secrecy.settings.SettingsFragment.java

void moveStorageRoot(String path, ProgressDialog progressDialog) {
    File oldRoot = Storage.getRoot();
    try {/* www  .j  a  v  a  2 s .com*/
        org.apache.commons.io.FileUtils.copyDirectory(oldRoot, new File(path));
        Storage.setRoot(path);
        Preference vault_root = findPreference(Config.VAULT_ROOT);
        vault_root.setSummary(Storage.getRoot().getAbsolutePath());
        Util.toast(getActivity(), String.format(getString(R.string.Settings__moved_vault), path),
                Toast.LENGTH_LONG);
    } catch (Exception E) {
        Util.alert(context, context.getString(R.string.Error__moving_vault),
                context.getString(R.string.Error__moving_vault_message), Util.emptyClickListener, null);
        progressDialog.dismiss();
        return;
    }
    try {
        org.apache.commons.io.FileUtils.deleteDirectory(oldRoot);
    } catch (IOException ignored) {
        //ignore
    }
    progressDialog.dismiss();
}

From source file:com.mobility.android.ui.vehicle.AddVehicleActivity.java

private void uploadPicture(File file) {
    ProgressDialog dialog = new ProgressDialog(this, R.style.DialogStyle);
    dialog.setMessage("Loading image...");
    dialog.setIndeterminate(true);/* w  w  w . j  a  va2s. c  o m*/
    dialog.setCancelable(false);
    dialog.show();

    Glide.with(AddVehicleActivity.this).load(file).animate(android.R.anim.fade_in).into(imageBackground);

    base64(file).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Observer<String>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    e.printStackTrace();
                    dialog.dismiss();

                    UIUtils.okDialog(AddVehicleActivity.this, "Error", "Couldn't load image.");
                }

                @Override
                public void onNext(String s) {
                    Timber.w("Loaded image base64, size: %s KB", s.length() / 1024);
                    vehicle.image = s;

                    dialog.dismiss();
                }
            });
}

From source file:com.example.sujit.customerapp.Get_Taxi.java

private void showProfile() {
    LayoutInflater li = LayoutInflater.from(this);
    //Creating a view to get the dialog box
    View confirmDialog = li.inflate(R.layout.dialog_profile, null);

    buttonCall = (AppCompatButton) confirmDialog.findViewById(R.id.buttonCall);
    textViewName1 = (TextView) confirmDialog.findViewById(R.id.textViewName1);
    textViewLicenseNo1 = (TextView) confirmDialog.findViewById(R.id.textViewLicenseNo1);
    textViewAddress1 = (TextView) confirmDialog.findViewById(R.id.textViewAddress1);
    textViewMobile1 = (TextView) confirmDialog.findViewById(R.id.textViewMobile1);
    textViewTaxiNo1 = (TextView) confirmDialog.findViewById(R.id.textViewTaxiNo1);
    textusername1 = (TextView) confirmDialog.findViewById(R.id.textusername1);

    AlertDialog.Builder alert = new AlertDialog.Builder(this);

    //Adding our dialog box to the view of alert dialog
    alert.setView(confirmDialog);/*from   w ww  .  j av a2  s. c o  m*/

    //Creating an alert dialog
    final AlertDialog alertDialog = alert.create();

    //Displaying the alert dialog
    alertDialog.show();

    //  RequestQueue requestQueue = Volley.newRequestQueue(Get_Taxi.this);
    //Yesbata mobile no pani POST ma pathauna parcha

    final ProgressDialog loading = ProgressDialog.show(this, "Getting Nearest Driver", "Please wait...", false,
            false);
    StringRequest stringRequest = new StringRequest(Request.Method.POST, "http://6e1e7877.ngrok.io/findmeataxi",
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    loading.dismiss();
                    Log.d("FINDMEATAXI", response);
                    try {
                        JSONObject jsonObject = new JSONObject(response);
                        JSONArray jsonArray = jsonObject.getJSONArray("driver");
                        for (int i = 0; i < jsonArray.length(); i++) {
                            JSONObject jsonObject1 = jsonArray.getJSONObject(i);
                            String username = jsonObject1.getString("username");
                            String taxi_number = jsonObject1.getString("taxi_number");
                            String license_number = jsonObject1.getString("license_number");
                            String mobile_number = jsonObject1.getString("mobile_number");
                            String full_name = jsonObject1.getString("full_name");
                            String address = jsonObject1.getString("address");

                            textusername1.setText(username);
                            textViewTaxiNo1.setText(taxi_number);
                            textViewLicenseNo1.setText(license_number);
                            textViewMobile1.setText(mobile_number);
                            textViewName1.setText(full_name);
                            textViewAddress1.setText(address);
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                        loading.dismiss();
                    }
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    loading.dismiss();
                    Log.d("Volley Error Response:", error.toString());

                }
            }) {
        @Override
        protected Map<String, String> getParams() {

            SharedPreferences sharedPreferences = getSharedPreferences("LoggedInUser", MODE_PRIVATE);
            String phnNo = sharedPreferences.getString("phoneNo", "");

            Map<String, String> params = new HashMap<>();
            params.put("latitude", String.valueOf(currentLatitude));
            params.put("longitude", String.valueOf(currentLongitude));
            params.put("mobile_number", phnNo);

            return params;
        }
    };

    MySingleton.getInstance(getApplicationContext()).addToRequestQueue(stringRequest);
    buttonCall.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            alertDialog.dismiss();
            SendInfo(textusername1.getText().toString());
            // callDriver();
        }
    });
}

From source file:com.sven.im.ui.ContactListFragment.java

public void deleteContact(final EaseUser 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);/*from  w ww.j a  v  a  2s.  c  om*/
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                EMClient.getInstance().contactManager().deleteContact(tobeDeleteUser.getUsername());
                // db?
                UserDao dao = new UserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getUsername());
                DemoHelper.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        contactList.remove(tobeDeleteUser);
                        contactListLayout.refresh();

                    }
                });
            } catch (final Exception e) {
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2 + e.getMessage(), Toast.LENGTH_SHORT).show();
                    }
                });

            }

        }
    }).start();
}

From source file:com.snsplus.soqlive.Fragment.Found_Fragment.java

/**
 *
 *
 *///w ww.j  a v  a 2  s .  co m
private void toggleLikeUserApi(final String vjUserId, final int isGuanzu) {
    String dialogText = mContext.getResources().getString(R.string.server_loading);
    final ProgressDialog mProgressDialog = mCustomProgressDialogUtil.getCustomProgressDialog(dialogText);

    ChinaHttpApi.toggleLikeUser(mContext, mAppData.getUserInfo().getUserId(), vjUserId,
            new ChinaHttpApi.Callback() {
                @Override
                public void onResponse(final String response) {
                    LogUtil.i("ToggleUser", "result : " + response);
                    mainHandler.post(new Runnable() {
                        @Override
                        public void run() {
                            if (mProgressDialog != null && mProgressDialog.isShowing()) {
                                mProgressDialog.dismiss();
                            }
                            boolean isSuccess = false;

                            try {
                                JSONObject temp = new JSONObject(response);
                                isSuccess = temp.optBoolean("isSuccessFlag");
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                            if (isSuccess) {
                                //isFans 0 , 1
                                for (int i = 0; i < mFoundAdapter.listData.size(); i++) {
                                    if (mFoundAdapter.listData.get(i).userInfo.getUserId()
                                            .equalsIgnoreCase(vjUserId)) {
                                        if (isGuanzu == 0) {
                                            mFoundAdapter.listData.get(i).isFans = 1;
                                        } else {
                                            mFoundAdapter.listData.get(i).isFans = 0;
                                        }
                                        break;
                                    }
                                }
                                mUserInfor_Pref = new UserInfor_Pref(getActivity());
                                HashMap<String, Boolean> mLikeMap = mUserInfor_Pref.getUserLikeMap();
                                if (mLikeMap != null) {
                                    if (mLikeMap.containsKey(vjUserId)) {
                                        if (isGuanzu == 0) {
                                            mLikeMap.remove(vjUserId);
                                            mLikeMap.put(vjUserId, true);
                                        } else {
                                            mLikeMap.remove(vjUserId);
                                        }
                                    } else {
                                        if (isGuanzu == 0) {
                                            mLikeMap.put(vjUserId, true);
                                        }
                                    }
                                } else {
                                    mLikeMap = new HashMap<String, Boolean>();
                                    if (isGuanzu == 0) {
                                        mLikeMap.put(vjUserId, true);
                                    }
                                }
                                mUserInfor_Pref.saveUserLikeMap(mLikeMap);

                                //                                 ??? local 
                                mServerData_Pref.changeSaveGuanzuData(vjUserId, isGuanzu);
                                mFoundAdapter.notifyDataSetChanged();
                            }
                        }
                    });
                }

                @Override
                public void onErrorResponse(VolleyError error) {
                    LogUtil.e(TAG, "error", error);

                    if (mProgressDialog != null && mProgressDialog.isShowing()) {
                        mProgressDialog.dismiss();
                    }
                }
            });
}

From source file:org.zeroxlab.benchmark.Benchmark.java

@SuppressWarnings("unused")
private void initAuto() {
    Intent intent = getIntent();/*  w w  w. ja v  a2  s  .c o  m*/
    String TAG = intent.getStringExtra("TAG");
    String CAT = intent.getStringExtra("CAT");

    _checkAllCase(false);
    if (TAG != null)
        _checkTagCase(TAG.split(","));
    if (CAT != null)
        _checkCatCase(CAT.split(","));
    if (TAG == null && CAT == null)
        _checkAllCase(true);
    final Handler h = new Handler() {
        public void handleMessage(Message msg) {
            if (msg.what == 0x1234)
                onClick(mRun);
        }
    };

    final ProgressDialog dialog = ProgressDialog.show(this, "Starting Benchmark", "Please wait...", true,
            false);

    new Thread() {
        public void run() {
            SystemClock.sleep(1000);
            dialog.dismiss();
            Message m = new Message();
            m.what = 0x1234;
            h.sendMessage(m);
        }
    }.start();
    mTouchable = true;
}