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:com.callba.phone.ui.GroupSimpleDetailActivity.java

public void addToGroup(View view) {
    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 w  ww.  ja va2  s .co  m
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                //membersOnly??join
                if (group.isMembersOnly()) {
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            showDialog();
                        }
                    });
                } else {
                    EMClient.getInstance().groupManager().joinGroup(groupid);
                    LocalBroadcastManager.getInstance(GroupSimpleDetailActivity.this)
                            .sendBroadcast(new Intent(Constant.ACTION_GROUP_CHANAGED));
                }
                runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        btn_add_group.setEnabled(false);
                        if (!group.isMembersOnly()) {
                            Toast.makeText(GroupSimpleDetailActivity.this, st4, Toast.LENGTH_SHORT).show();
                            finish();
                        }
                    }
                });
            } catch (final HyphenateException e) {
                e.printStackTrace();
                runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(GroupSimpleDetailActivity.this, st5 + e.getMessage(), Toast.LENGTH_SHORT)
                                .show();
                        btn_add_group.setEnabled(true);
                    }
                });
            }
        }
    }).start();
}

From source file:xj.property.fragment.ContactlistFragment.java

/**
 * ?/*  w  w w  . ja va2s .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());
                XjApplication.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

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

            }

        }
    }).start();

}

From source file:itstudio.instructor.fragment.ContactlistFragment.java

/**
 * user???/*from   www  .j a  v  a  2s . c  o  m*/
 */
private void moveToBlacklist(final String username) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage("???...");
    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(), "????", 0).show();
                        refresh();
                    }
                });
            } catch (EaseMobException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), "???", 0).show();
                    }
                });
            }
        }
    }).start();

}

From source file:cn.kangeqiu.kq.activity.ContactlistFragment.java

/**
 * ?/*from w  w  w  .  java2s  .  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());
                BaseApplication.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:com.nxt.njitong.ContactlistActivity.java

/**
 * ?/* www  .  j av  a2s.  com*/
 *
 * @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(context);
    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(context);
                dao.deleteContact(tobeDeleteUser.getUsername());
                DemoApplication.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
                runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

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

            }

        }
    }).start();

}

From source file:at.bitfire.davdroid.ui.CreateCollectionFragment.java

@NonNull
@Override// ww w  .j  a  v  a  2s .  c om
public Dialog onCreateDialog(Bundle savedInstanceState) {
    ProgressDialog progress = new ProgressDialog(getContext());
    progress.setTitle(R.string.create_collection_creating);
    progress.setMessage(getString(R.string.please_wait));
    progress.setIndeterminate(true);
    progress.setCanceledOnTouchOutside(false);
    setCancelable(false);
    return progress;
}

From source file:com.example.Bama.chat.chatuidemo.activity.ContactlistFragment.java

/**
 * ?//from   w  w  w .j  a va  2s.co  m
 *
 * @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());
                HCApplication.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();

}

From source file:com.xiaoyu.DoctorHelp.chat.chatuidemo.activity.ContactlistFragment.java

/**
 * ?//from   www  .j  av a  2  s.  c  o  m
 *
 * @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());
                HCApplicaton.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();

}

From source file:la.zmkm.agent.activity.ContactlistFragment.java

/**
 * ?//from w  w  w .java2s  . c o  m
 * 
 * @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());
                DemoApplication.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

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

            }

        }
    }).start();

}

From source file:com.aibasis.parent.ui.entrance.LoginActivity.java

/**
 * /*from   ww w . j  a v a 2 s .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;
    }
    currentUsername = usernameEditText.getText().toString().trim();
    currentPassword = passwordEditText.getText().toString().trim();

    if (TextUtils.isEmpty(currentUsername)) {
        Toast.makeText(this, R.string.User_name_cannot_be_empty, Toast.LENGTH_SHORT).show();
        return;
    }
    if (TextUtils.isEmpty(currentPassword)) {
        Toast.makeText(this, R.string.Password_cannot_be_empty, Toast.LENGTH_SHORT).show();
        return;
    }

    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(getString(R.string.Is_landing));
    pd.show();

    final long start = System.currentTimeMillis();

    accountAPI.login(currentUsername, currentPassword, new RequestListener() {
        @Override
        public void onComplete(String result) {
            try {
                final LoginResult loginResult = LoginResult.parse(result);
                if (LoginResult.SUCCESS.equals(loginResult.getResult())) {
                    // sdk??
                    EMChatManager.getInstance().login(loginResult.getEaseId(), loginResult.getEasePassword(),
                            new EMCallBack() {

                                @Override
                                public void onSuccess() {
                                    if (!progressShow) {
                                        return;
                                    }
                                    // ?????
                                    DemoApplication.getInstance().setUserName(currentUsername);
                                    DemoApplication.getInstance().setPassword(currentPassword);
                                    DemoApplication.getInstance().setEaseId(loginResult.getEaseId());
                                    DemoApplication.getInstance()
                                            .setEasePassword(loginResult.getEasePassword());
                                    DemoApplication.getInstance().setParentId(loginResult.getParentId());

                                    SharePreferenceUtil sharePreferenceUtil = new SharePreferenceUtil(
                                            LoginActivity.this);
                                    sharePreferenceUtil
                                            .setParentId(DemoApplication.getInstance().getParentId());

                                    try {
                                        // ** ?logout???
                                        // ** manually load all local groups and
                                        EMGroupManager.getInstance().loadAllGroups();
                                        EMChatManager.getInstance().loadAllConversations();
                                        // ??
                                        initializeContacts();
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                        // ?????
                                        runOnUiThread(new Runnable() {
                                            public void run() {
                                                pd.dismiss();
                                                DemoHXSDKHelper.getInstance().logout(true, null);
                                                Toast.makeText(getApplicationContext(),
                                                        R.string.login_failure_failed, Toast.LENGTH_SHORT)
                                                        .show();
                                            }
                                        });
                                        return;
                                    }
                                    // ?nickname ios?nick
                                    boolean updatenick = EMChatManager.getInstance()
                                            .updateCurrentUserNick(DemoApplication.currentUserNick.trim());
                                    if (!updatenick) {
                                        Log.e("LoginActivity", "update current user nick fail");
                                    }
                                    if (!LoginActivity.this.isFinishing() && pd.isShowing()) {
                                        pd.dismiss();
                                    }
                                    // ?
                                    Intent intent = new Intent(LoginActivity.this, MainActivity.class);
                                    startActivity(intent);

                                    finish();
                                }

                                @Override
                                public void onProgress(int progress, String status) {
                                }

                                @Override
                                public void onError(final int code, final String message) {
                                    if (!progressShow) {
                                        return;
                                    }
                                    runOnUiThread(new Runnable() {
                                        public void run() {
                                            pd.dismiss();
                                            Toast.makeText(getApplicationContext(),
                                                    getString(R.string.Login_failed) + message,
                                                    Toast.LENGTH_SHORT).show();
                                        }
                                    });
                                }
                            });
                } else if (LoginResult.FAILED.equals(loginResult.getResult())) {
                    {
                        Toast.makeText(getApplicationContext(), getString(R.string.Login_failed),
                                Toast.LENGTH_SHORT).show();
                    }
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onAPIException(APIException exception) {

        }
    });
}