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:org.openremote.android.console.AppSettingsActivity.java

/**
 * Submits a Certification Request to the controller
 *///from  w  w  w  . j a  v  a 2 s  .  c  o  m
private void requestAccess() {
    final String hostname = AppSettingsActivity.currentServer;

    if (!TextUtils.isEmpty(hostname)) {
        final ProgressDialog progress = new ProgressDialog(this);
        final Handler handler = new Handler() {
            public void handleMessage(Message msg) {
                if (progress.isShowing()) {
                    progress.dismiss();
                }
            }
        };

        if (isActivityResumed()) {
            progress.show();
        }

        new Thread() {
            public void run() {
                handler.sendEmptyMessage(ORPKCS10CertificationRequest.getInstance(getApplicationContext())
                        .submitCertificationRequest(hostname));
            }
        }.start();
    }
}

From source file:com.grass.caishi.cc.frag.FriendsListFragment.java

/**
 * ?/*from ww w  .j  a  va  2s.  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());
                MyApplication.getInstance().getContactList(false).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();

}

From source file:com.grass.caishi.cc.activity.main.FriendsListFragment.java

/**
 * ?/*from ww  w. j  a  v a2 s. com*/
 * 
 * @param
 */
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(false).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.sxt.superqq.fragment.ContactlistFragment.java

/**
 * ?/*w w  w .j a va  2 s.co m*/
 * 
 * @param toDeleteUser
 */
public void deleteContact(final UserBean 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?
                EMUserDao dao = new EMUserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getUserName());
                SuperQQApplication.getInstance().getContact_List().remove(tobeDeleteUser.getUserName());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        mAdapter.remove(tobeDeleteUser);

                    }
                });
            } 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:com.sxt.superqq.fragment.SettingsFragment.java

void logout() {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);//  w  ww  . j a  v  a  2  s. co  m
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    SuperQQApplication.getInstance().logout(new EMCallBack() {

        @Override
        public void onSuccess() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    //????
                    ArrayList<UserBean> contactList = SuperQQApplication.getInstance().getContactList();
                    contactList.clear();
                    HashMap<Integer, ContactBean> contacts = SuperQQApplication.getInstance().getContacts();
                    contacts.clear();
                    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:com.liangxun.yuejiula.huanxin.chat.activity.GroupsActivity.java

public void addToGroup(final EMGroup group) {
    String st1 = getResources().getString(R.string.Is_sending_a_request);
    final String st2 = getResources().getString(R.string.Request_to_join);
    final String st3 = getResources().getString(R.string.send_the_request_is);
    final String st4 = getResources().getString(R.string.Join_the_group_chat);
    final String st5 = getResources().getString(R.string.Failed_to_join_the_group_chat);
    final ProgressDialog pd = new ProgressDialog(this);
    //      getResources().getString(R.string)
    pd.setMessage(st1);/*from   ww w. j  av  a  2s.  c om*/
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                //membersOnly??join
                if (group.isMembersOnly()) {
                    EMGroupManager.getInstance().applyJoinToGroup(group.getGroupId(), st2);
                } else {
                    EMGroupManager.getInstance().joinGroup(group.getGroupId());
                }
                runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        if (group.isMembersOnly())
                            Toast.makeText(GroupsActivity.this, st3, Toast.LENGTH_SHORT).show();
                        else
                            Toast.makeText(GroupsActivity.this, st4, Toast.LENGTH_SHORT).show();
                    }
                });
            } catch (final EaseMobException e) {
                e.printStackTrace();
                runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(GroupsActivity.this, st5 + e.getMessage(), Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    }).start();
}

From source file:cn.ucai.fulicenter.fragment.SettingsFragment.java

void logout() {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);/*  w  w w . j  a va  2s .  com*/
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    DemoHXSDKHelper.getInstance().logout(true, new EMCallBack() {

        @Override
        public void onSuccess() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    FuLiCenterApplication intance = FuLiCenterApplication.getInstance();
                    intance.getContactList().clear();
                    intance.getUserList().clear();
                    intance.getGroupMembers().clear();
                    intance.getContacts().clear();

                    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) {
            getActivity().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    pd.dismiss();
                    Toast.makeText(getActivity(), "unbind devicetokens failed", Toast.LENGTH_SHORT).show();

                }
            });
        }
    });
}

From source file:cf.obsessiveorange.rhcareerfairlayout.ui.activities.MainActivity.java

/**
 * Private helper method to reload data, presenting dialog on failure.
 *///ww w  .  j  a  v a 2s  .c o m
private void reloadData() {

    final ProgressDialog progressDialog = ProgressDialog.show(MainActivity.this, "", "Loading...");

    // If successful, notify all that that refreshed.
    Runnable successHandler = new Runnable() {
        @Override
        public void run() {
            synchronized (RHCareerFairLayout.refreshCompaniesNotifier) {
                RHCareerFairLayout.refreshCompaniesNotifier.notifyChanged();
            }
            synchronized (RHCareerFairLayout.refreshMapNotifier) {
                RHCareerFairLayout.refreshMapNotifier.notifyChanged();
            }

            progressDialog.dismiss();
        }
    };

    // If exception or failure, show error message, and ask if they want to retry.
    Runnable exceptionHandler = new Runnable() {
        @Override
        public void run() {

            progressDialog.dismiss();

            runOnUiThread(new Runnable() {
                @Override
                public void run() {

                    DialogFragment df = new DialogFragment() {
                        @Override
                        public Dialog onCreateDialog(Bundle savedInstanceState) {
                            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                            builder.setTitle("Error");
                            builder.setMessage(
                                    getResources().getString(R.string.loadingStatus_errorDownloadingData));
                            builder.setPositiveButton("Retry", new DialogInterface.OnClickListener() {

                                @Override
                                public void onClick(DialogInterface dialog, int which) {

                                    dismiss();

                                    reloadData();

                                }
                            });
                            builder.setNegativeButton(android.R.string.cancel,
                                    new DialogInterface.OnClickListener() {

                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                            dismiss();
                                        }
                                    });
                            return builder.create();
                        }
                    };
                    df.show(getFragmentManager(), null);
                }
            });
        }
    };

    Runnable failHandler = new Runnable() {
        @Override
        public void run() {

            progressDialog.dismiss();

            runOnUiThread(new Runnable() {
                @Override
                public void run() {

                    DialogFragment df = new DialogFragment() {
                        @Override
                        public Dialog onCreateDialog(Bundle savedInstanceState) {
                            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                            builder.setTitle("Error");
                            builder.setMessage(
                                    getResources().getString(R.string.loadingStatus_errorParsingData));
                            builder.setPositiveButton("Retry", new DialogInterface.OnClickListener() {

                                @Override
                                public void onClick(DialogInterface dialog, int which) {

                                    dismiss();

                                    reloadData();

                                }
                            });
                            builder.setNegativeButton(android.R.string.cancel,
                                    new DialogInterface.OnClickListener() {

                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                            dismiss();
                                        }
                                    });
                            return builder.create();
                        }
                    };
                    df.show(getFragmentManager(), null);
                }
            });
        }
    };

    GetAllDataRequest req = new GetAllDataRequest(successHandler, exceptionHandler, failHandler);

    Log.d(RHCareerFairLayout.RH_CFL, "Data not saved or outdated. Downloading.");
    ConnectionManager.enqueueRequest(req);
}

From source file:com.huison.DriverAssistant_Web.util.LoginHelper.java

public static void login(final BaseActivity activity, final String username, final String password,
        final boolean autoLogin) {
    Log.i(TAG, "call login func:" + username + "/" + password);
    ctx = activity;//from   w  w  w .  j a v a 2s.co  m
    UmengEventSender.sendEvent(activity, UmengEventTypes.login);
    final ProgressDialog pd = new ProgressDialog(activity);
    pd.setMessage(activity.getString(R.string.logging_wait));
    pd.show();
    AsyncHttpClient client = activity.getAsyncHttpClient();
    RequestParams params = new RequestParams();
    try {
        JSONObject p = new JSONObject();
        p.put("mobile", username);
        p.put("password", password);
        p.put("method", "login");
        p.put("version", activity.getVersionName());
        p.put("devicetype", "android");
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date curDate = new Date(System.currentTimeMillis());
        String time = formatter.format(curDate);
        p.put("time", time);
        Log.i(TAG, "request parameters: " + p.toString());
        String data = Util.DesJiaMi(p.toString(), "czxms520");
        Log.i(TAG, "post data:" + data);
        params.put("data", data);
    } catch (Exception e) {
        activity.showMessageBox(activity.getString(R.string.wrong_profile));
        Log.e(TAG, e.getMessage());
        e.printStackTrace();
        return;
    }
    // params.put("xml", BaseActivity.getXML(map));
    Log.i(TAG, "AsyncHttpClient post:" + BaseActivity.REQUESTURL);
    client.post(BaseActivity.REQUESTURL, params, new JsonHttpResponseHandler() {
        @Override
        public void onDispatchSuccess(int statusCode, Header[] headers, String result) {
            Log.i(TAG, "onDispatchSuccess: " + result);
            pd.dismiss();
            try {
                Log.i(TAG, "decrypting...");
                result = Util.decrypt(result, "czxms520");
                Log.v(TAG, "result decrypted :" + result);
                JSONObject jo = new JSONObject(result);
                String code = jo.getString("code");
                String msg = getJSONValueAsString(jo, "message");
                if (code.equals("0")) {
                    jo = new JSONObject(jo.getString("data"));
                    // 
                    String loginTime = getJSONValueAsString(jo, "LastLogin");
                    // 
                    String lastLoginTime = getJSONValueAsString(jo, "LastLogin");
                    // SESSIONKEY
                    /*
                     * String sessionKey = getJSONValueAsString( jo,
                     * "sessionkey");
                     */
                    // 
                    String urlHead = getJSONValueAsString(jo, "PhotoUrl");
                    String photoUrl = getJSONValueAsString(jo, "PhotoUrl");
                    String phone = getJSONValueAsString(jo, "Mobile");
                    Boolean vip = false;
                    if (String.valueOf(jo.getInt("Vip")).equals("1")) {
                        vip = true;
                    } else {
                        vip = false;
                    }
                    Env.isLogined = BaseActivity.isLogined = true;
                    Log.v(TAG, ":1");
                    activity.markLogin(phone, phone, password, autoLogin, "", loginTime, lastLoginTime, vip);
                    if (!photoUrl.equals("")) {
                        String finalHeadUrl = URLDecoder.decode(photoUrl, "utf-8");
                        BaseActivity.setUserHeadUrl(finalHeadUrl);
                        BaseActivity.setUserHeadDrawable(null);
                    } else {
                        BaseActivity.setUserHeadUrl("");
                        BaseActivity.setUserHeadDrawable(null);
                    }
                    // sendMsg(ConfigActivity.thiz,0);
                    //  start
                    HomeActivity.now_mobile = phone;
                    //  end
                    // 
                    // 
                    Log.v("", "kk" + phone);
                    LoginActivity.instance.finish();
                    Util.saveFile(phone, Environment.getExternalStorageDirectory() + "/xmsphone.txt");
                    SharedPreferences.Editor sharedata = activity.getSharedPreferences("MyData", 0).edit();
                    sharedata.putString("isJZMM_czxms", "true");
                    sharedata.commit();
                    Log.i(TAG, ":2");
                    sendMsg(0);
                    sendMsg(ConfigActivity.thiz, 2);
                    activity.finish();
                } else {
                    Log.e(TAG, "server notify failed: error:" + msg);
                    LoginActivity.pw.setText("");
                    activity.showMessageBox(msg);
                }
            } catch (JSONException e) {
                Log.e(TAG, "login error" + Log.getStackTraceString(e));
                e.printStackTrace();
                activity.showMessageBox(activity.getText(R.string.server404));
            } catch (Exception e) {
                Log.e(TAG, Log.getStackTraceString(e));
                //e.printStackTrace();
                activity.showMessageBox(",.");
            }
        }

        @Override
        public void onFailureAnyway(int statusCode, Header[] headers, Throwable throwable,
                BaseBinaryResponse jsonResponse) {
            Log.i(TAG, "onFailureAnyway: " + statusCode);
            pd.dismiss();
            activity.showMessageBox(activity.getText(R.string.server404));
        }

        @Override
        public void onSuccessAnyway(int statusCode, Header[] headers, BaseBinaryResponse jsonResponse) {
            Log.i(TAG, "onSuccessAnyway: " + statusCode);
        }
    });
    TimeCounter.countTime(activity, pd);
}

From source file:cn.ucai.superwechat.fragments.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 a v a  2  s .c  om
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    DemoHXSDKHelper.getInstance().logout(true, new EMCallBack() {

        @Override
        public void onSuccess() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    SuperWeChatApplication instance = SuperWeChatApplication.getInstance();
                    instance.getContactList().clear();
                    instance.getUserList().clear();
                    instance.getGroupList().clear();
                    instance.getPublicGroupList().clear();
                    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) {
            getActivity().runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    // TODO Auto-generated method stub
                    pd.dismiss();
                    Toast.makeText(getActivity(), "unbind devicetokens failed", Toast.LENGTH_SHORT).show();

                }
            });
        }
    });
}