Example usage for android.app ProgressDialog setCanceledOnTouchOutside

List of usage examples for android.app ProgressDialog setCanceledOnTouchOutside

Introduction

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

Prototype

public void setCanceledOnTouchOutside(boolean cancel) 

Source Link

Document

Sets whether this dialog is canceled when touched outside the window's bounds.

Usage

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

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);
    actionBar.setTitle(LocaleController.getString("PrivacySettings", R.string.PrivacySettings));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override//from   w w  w .  ja va2 s .  c  o  m
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

    listAdapter = new ListAdapter(context);

    fragmentView = new FrameLayout(context);
    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background));

    ListView listView = new ListView(context);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setVerticalScrollBarEnabled(false);
    listView.setDrawSelectorOnTop(true);
    frameLayout.addView(listView,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
    listView.setAdapter(listAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
            if (i == blockedRow) {
                presentFragment(new BlockedUsersActivity());
            } else if (i == sessionsRow) {
                presentFragment(new SessionsActivity());
            } else if (i == deleteAccountRow) {
                if (getParentActivity() == null) {
                    return;
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                builder.setTitle(LocaleController.getString("DeleteAccountTitle", R.string.DeleteAccountTitle));
                builder.setItems(
                        new CharSequence[] { LocaleController.formatPluralString("Months", 1),
                                LocaleController.formatPluralString("Months", 3),
                                LocaleController.formatPluralString("Months", 6),
                                LocaleController.formatPluralString("Years", 1) },
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                int value = 0;
                                if (which == 0) {
                                    value = 30;
                                } else if (which == 1) {
                                    value = 90;
                                } else if (which == 2) {
                                    value = 182;
                                } else if (which == 3) {
                                    value = 365;
                                }
                                final ProgressDialog progressDialog = new ProgressDialog(getParentActivity());
                                progressDialog
                                        .setMessage(LocaleController.getString("Loading", R.string.Loading));
                                progressDialog.setCanceledOnTouchOutside(false);
                                progressDialog.setCancelable(false);
                                progressDialog.show();

                                final TLRPC.TL_account_setAccountTTL req = new TLRPC.TL_account_setAccountTTL();
                                req.ttl = new TLRPC.TL_accountDaysTTL();
                                req.ttl.days = value;
                                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 {
                                                    progressDialog.dismiss();
                                                } catch (Exception e) {
                                                    FileLog.e("tmessages", e);
                                                }
                                                if (response instanceof TLRPC.TL_boolTrue) {
                                                    ContactsController.getInstance()
                                                            .setDeleteAccountTTL(req.ttl.days);
                                                    listAdapter.notifyDataSetChanged();
                                                }
                                            }
                                        });
                                    }
                                });
                            }
                        });
                builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
                showDialog(builder.create());
            } else if (i == lastSeenRow) {
                presentFragment(new PrivacyControlActivity(false));
            } else if (i == groupsRow) {
                presentFragment(new PrivacyControlActivity(true));
            } else if (i == passwordRow) {
                presentFragment(new TwoStepVerificationActivity(0));
            } else if (i == passcodeRow) {
                if (UserConfig.passcodeHash.length() > 0) {
                    presentFragment(new PasscodeActivity(2));
                } else {
                    presentFragment(new PasscodeActivity(0));
                }
            } else if (i == secretWebpageRow) {
                if (MessagesController.getInstance().secretWebpagePreview == 1) {
                    MessagesController.getInstance().secretWebpagePreview = 0;
                } else {
                    MessagesController.getInstance().secretWebpagePreview = 1;
                }
                ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE)
                        .edit().putInt("secretWebpage2", MessagesController.getInstance().secretWebpagePreview)
                        .commit();
                if (view instanceof TextCheckCell) {
                    ((TextCheckCell) view)
                            .setChecked(MessagesController.getInstance().secretWebpagePreview == 1);
                }
            }
        }
    });

    return fragmentView;
}

From source file:com.kkbox.toolkit.dialog.KKDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    DialogInterface.OnClickListener positiveListener = new DialogInterface.OnClickListener() {
        @Override/*from  w  w  w .  j av  a2  s  .com*/
        public void onClick(DialogInterface dialog, int id) {
            if (!isDismissed) {
                if (listener != null) {
                    listener.onPositive();
                }
                onDialogFinishedByUser();
                isDismissed = true;
            }
        }
    };

    DialogInterface.OnClickListener neutralListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            if (!isDismissed) {
                if (listener != null) {
                    listener.onNeutral();
                }
                onDialogFinishedByUser();
                isDismissed = true;
            }
        }
    };

    DialogInterface.OnClickListener negativeListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            if (!isDismissed) {
                if (listener != null) {
                    listener.onNegative();
                }
                onDialogFinishedByUser();
                isDismissed = true;
            }
        }
    };

    switch (dialogType) {
    case Type.PROGRESSING_DIALOG:
        ProgressDialog progressDialog;
        if (theme != -1) {
            progressDialog = new ProgressDialog(getActivity(), theme);
        } else {
            progressDialog = new ProgressDialog(getActivity());
        }
        progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progressDialog.setMessage(message);
        progressDialog.setIndeterminate(true);
        progressDialog.setCanceledOnTouchOutside(false);
        progressDialog.setCancelable(listener != null);
        return progressDialog;
    case Type.ALERT_DIALOG:
        AlertDialog.Builder builder;
        AlertDialog alertDialog;
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        builder.setMessage(message);
        builder.setTitle(title);
        builder.setPositiveButton(positiveButtonText, positiveListener);
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.THREE_CHOICE_DIALOG:
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        builder.setMessage(message);
        builder.setTitle(title);
        builder.setPositiveButton(positiveButtonText, positiveListener);
        builder.setNeutralButton(neutralButtonText, neutralListener);
        builder.setNegativeButton(negativeButtonText, negativeListener);
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.YES_OR_NO_DIALOG:
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        builder.setMessage(message);
        builder.setTitle(title);
        builder.setPositiveButton(positiveButtonText, positiveListener);
        builder.setNegativeButton(negativeButtonText, negativeListener);
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.SELECT_DIALOG:
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        builder.setMessage(message);
        builder.setTitle(title);
        builder.setSingleChoiceItems(entries, selectedIndex, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                if (!isDismissed) {
                    if (listener != null) {
                        listener.onEvent(id);
                    }
                    dismiss();
                    onDialogFinishedByUser();
                    isDismissed = true;
                }
            }
        });
        builder.setNegativeButton(negativeButtonText, negativeListener);
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.CUSTOMIZE_DIALOG:
        if (theme != -1) {
            builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), theme));
        } else {
            builder = new AlertDialog.Builder(getActivity());
        }
        if (customizeView != null && customizeView.getParent() != null) {
            ((ViewGroup) customizeView.getParent()).removeView(customizeView);
        }
        builder.setView(customizeView);

        if (!TextUtils.isEmpty(title)) {
            builder.setTitle(title);
        }
        if (!TextUtils.isEmpty(positiveButtonText)) {
            builder.setPositiveButton(positiveButtonText, positiveListener);
        }
        if (!TextUtils.isEmpty(neutralButtonText)) {
            builder.setNeutralButton(neutralButtonText, neutralListener);
        }
        if (!TextUtils.isEmpty(negativeButtonText)) {
            builder.setNegativeButton(negativeButtonText, negativeListener);
        }
        alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(isAlertDialogCanceledOnTouchOutside);
        return alertDialog;
    case Type.CUSTOMIZE_FULLSCREEN_DIALOG:
        Dialog dialog;
        if (theme != -1) {
            dialog = new Dialog(getActivity(), theme);
        } else {
            dialog = new Dialog(getActivity(), android.R.style.Theme_NoTitleBar);
        }
        if (customizeView != null && customizeView.getParent() != null) {
            ((ViewGroup) customizeView.getParent()).removeView(customizeView);
        }
        dialog.setContentView(customizeView);
        return dialog;
    }
    return null;
}

From source file:com.ccxt.whl.activity.LoginActivity.java

/**
 * /*from  w w w  .ja v  a 2s .c o m*/
 * 
 * @param view
 */
public void login(View view) {
    if (!CommonUtils.isNetWorkConnected(this)) {
        Toast.makeText(this, R.string.network_isnot_available, Toast.LENGTH_SHORT).show();
        return;
    }
    final String email = usernameEditText.getText().toString();
    final String password = passwordEditText.getText().toString();
    if (!TextUtils.isEmpty(email) && !TextUtils.isEmpty(password)) {
        progressShow = true;
        final ProgressDialog pd = new ProgressDialog(LoginActivity.this);
        pd.setCanceledOnTouchOutside(false);
        pd.setOnCancelListener(new OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                progressShow = false;
            }
        });
        pd.setMessage("...");
        pd.show();
        // sdk??
        RequestParams params = new RequestParams();
        params.add("tel_email", email);
        params.add("pwd", MD5.MD5Hash(password));
        params.add("uid", uid);
        HttpRestClient.get(Constant.LOGIN_URL, params, new BaseJsonHttpResponseHandler() {

            @Override
            public void onSuccess(int statusCode, Header[] headers, String rawJsonResponse, Object response) {
                Log.d("login_res_json" + rawJsonResponse);
                pd.dismiss();
                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" + "uid:" + result.get("uid") + "\n"
                            + "umd5:" + result.get("umd5") + "\n" + "is_res:" + result.get("is_res") + "\n"
                            + "headurl:" + result.get("headurl") + "\n" + "name:" + result.get("name") + "\n"
                            + "sex:" + result.get("sex") + "\n" + "age:" + result.get("age") + "\n"
                            + "province:" + result.get("province") + "\n" + "city:" + result.get("city") + "\n"
                            + "pwd:" + result.get("pwd") + "\n";
                    Log.d("login_res_obj" + resultStr);
                    //???id nullsaveinfo Preference
                    //DemoApplication.getInstance().setUser(result.get("umd5").toString());
                    //System.out.println("========================"+result.get("umd5").toString());
                    /********/
                    PreferenceUtils.getInstance(getBaseContext())
                            .setSettingUserPic(result.get("headurl").toString());
                    PreferenceUtils.getInstance(getBaseContext())
                            .setSettingUserNickName(result.get("name").toString());
                    PreferenceUtils.getInstance(getBaseContext())
                            .setSettingUserSex(result.get("sex").toString());
                    PreferenceUtils.getInstance(getBaseContext())
                            .setSettingUserAge(result.get("age").toString());
                    PreferenceUtils.getInstance(getBaseContext()).setSettingUserArea(
                            result.get("province").toString() + " " + result.get("city").toString());
                    PreferenceUtils.getInstance(getBaseContext())
                            .setSettingUserZhiye(result.get("zhiye").toString());
                    PreferenceUtils.getInstance(getBaseContext())
                            .setSettingUserQianming(result.get("qianming").toString());

                    String huanxin_username = result.get("umd5").toString();
                    String huanxin_pwd = result.get("pwd").toString();
                    Log.d("log huanxin_username:" + huanxin_username + "|huanxin_pwd:" + huanxin_pwd);

                    //?? 
                    login(huanxin_username, huanxin_pwd);

                    /*???
                    progressShow = false;
                    pd.dismiss();*/

                } else {
                    Toast.makeText(getApplicationContext(), lm.get("message").toString(), 0).show();
                }

            }

            @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;
            }

        });
    }
}

From source file:com.hzx.luoyechat.activity.ContactlistFragment.java

/**
 * user???/* ww  w .  j  a  v  a 2s  .  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, Toast.LENGTH_SHORT).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:com.hx.hxchat.activity.ContactlistFragment.java

/**
 * ?//ww w . j  a  v a2 s.c  o m
 * 
 * @param toDeleteUser
 */
public void deleteContact(final User tobeDeleteUser) {
    final ProgressDialog pd = CommonUtils.getProgrossDialog(getActivity(), "...", false);
    pd.setCanceledOnTouchOutside(false);
    pd.show();

    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                JSONObject oJSONObject = UserUtils.delfriend(getActivity(), tobeDeleteUser.getUsername());
                if (oJSONObject != null) {
                    if (oJSONObject.getString("flag").equals("0")) {
                        // db?
                        UserDao dao = new UserDao(getActivity());
                        dao.deleteContact(tobeDeleteUser.getUsername());
                        BaseApplication.getApplication().getContactList().remove(tobeDeleteUser.getUsername());
                        getActivity().runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                pd.dismiss();
                                adapter.remove(tobeDeleteUser);
                                Define_C.s_HasChangeContent = true;
                                adapter.notifyDataSetChanged();

                            }
                        });
                        EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
                    } else {
                        getActivity().runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                pd.dismiss();
                                Toast.makeText(getActivity(), "", 1).show();
                            }
                        });
                    }
                } else {
                    getActivity().runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            pd.dismiss();
                            Toast.makeText(getActivity(), "", 1).show();
                        }
                    });
                }
            } catch (final Exception e) {
                getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), "" + e.getMessage(), 1).show();
                    }
                });
            }

        }
    }).start();

}

From source file:com.ccxt.whl.activity.LoginActivity.java

/**
 * ?/* w  w  w  . j  a v a  2 s. c  o  m*/
 * 
 * @param view
 */
public void login(final String username, final String password) {
    if (!CommonUtils.isNetWorkConnected(this)) {
        Toast.makeText(this, R.string.network_isnot_available, Toast.LENGTH_SHORT).show();
        return;
    }
    //final String username = usernameEditText.getText().toString();
    //final String password = passwordEditText.getText().toString();
    if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(password)) {
        progressShow = true;
        final ProgressDialog pd = new ProgressDialog(LoginActivity.this);
        pd.setCanceledOnTouchOutside(false);
        pd.setOnCancelListener(new OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                progressShow = false;
            }
        });
        pd.setMessage("...");
        pd.show();
        // sdk??
        EMChatManager.getInstance().login(username, password, new EMCallBack() {

            @Override
            public void onSuccess() {
                /*****************
                 * ?
                 *****************/
                if (!progressShow) {
                    return;
                }
                // ?????
                //               DemoApplication.getInstance().setUserName(username);
                DemoApplication.getInstance().setUser(username);
                DemoApplication.getInstance().setPassword(password);
                DemoApplication.getInstance().setUserNickName(name);
                runOnUiThread(new Runnable() {
                    public void run() {
                        pd.setMessage("???...");
                    }
                });
                try {
                    // demo??????username??
                    List<String> usernames = EMChatManager.getInstance().getContactUserNames();
                    Map<String, User> userlist = new HashMap<String, User>();
                    for (String username : usernames) {
                        User user = new User();
                        user.setUsername(username);
                        setUserHearder(username, user);
                        userlist.put(username, user);
                    }
                    // user""
                    User newFriends = new User();
                    newFriends.setUsername(Constant.NEW_FRIENDS_USERNAME);
                    newFriends.setNick("");
                    newFriends.setHeader("");
                    userlist.put(Constant.NEW_FRIENDS_USERNAME, newFriends);
                    // "?"
                    User groupUser = new User();
                    groupUser.setUsername(Constant.GROUP_USERNAME);
                    groupUser.setNick("?");
                    groupUser.setHeader("");
                    userlist.put(Constant.GROUP_USERNAME, groupUser);

                    // 
                    DemoApplication.getInstance().setContactList(userlist);
                    /***?MainActivity?db* /
                    // db
                    UserDao dao = new UserDao(LoginActivity.this);
                    List<User> users = new ArrayList<User>(userlist.values());
                    dao.saveContactList(users);/**/

                    // ??,sdkEMGroupManagerdb
                    EMGroupManager.getInstance().getGroupsFromServer();
                    // after login, we join groups in separate threads;
                    EMGroupManager.getInstance().joinGroupsAfterLogin();
                } catch (Exception e) {
                    e.printStackTrace();
                }

                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(int code, final String message) {
                if (!progressShow) {
                    return;
                }
                //Log.d("log","code"+code);
                runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();

                        Toast.makeText(getApplicationContext(), ": " + message, 0).show();

                    }
                });
            }
        });
    }
}

From source file:com.eason.marker.emchat.chatuidemo.activity.ContactlistFragment.java

/**
 * user???//from   w  w  w .  ja v  a 2 s .c  om
 */
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();
                        GreenToast.makeText(getActivity(), st2, 0).show();
                        refresh();
                    }
                });
            } catch (EaseMobException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        GreenToast.makeText(getActivity(), st3, 0).show();
                    }
                });
            }
        }
    }).start();

}

From source file:cmu.cconfs.instantMessage.activities.ContactlistFragment.java

/**
 * user???//from w  ww . j  a  v  a2s .  c om
 */
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:it.scoppelletti.mobilepower.app.ProgressDialogFragment.java

/**
 * Crea il dialogo.//w  w  w. j a v  a  2s .c  o m
 * 
 * @param  savedInstanceState Stato dell&rsquo;istanza.
 * @return                    Dialogo.
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    int max, resId;
    ProgressDialog dlg;
    Bundle args = getArguments();

    dlg = new ProgressDialog(getActivity(), AppUtils.getDialogTheme());

    resId = args.getInt(ProgressDialogFragment.ARG_TITLEID);
    dlg.setTitle(getString(resId));
    max = args.getInt(ProgressDialogFragment.ARG_MAX, -1);

    if (max > 0) {
        dlg.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        dlg.setIndeterminate(false);
        dlg.setMax(max);
    } else {
        dlg.setIndeterminate(true);
        dlg.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    }

    dlg.setCancelable(args.getBoolean(ProgressDialogFragment.ARG_CANCELABLE));
    dlg.setCanceledOnTouchOutside(false);

    return dlg;
}

From source file:cn.ucai.chatuidemo.activity.ContactlistFragment.java

/**
 * user???//from   w  w  w .  ja v  a  2  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, Toast.LENGTH_LONG).show();
                        refresh();
                    }
                });
            } catch (EaseMobException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st3, Toast.LENGTH_LONG).show();
                    }
                });
            }
        }
    }).start();

}