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:cn.ucai.chatuidemo.activity.ContactlistFragment.java

/**
 * ?/* w  w w .  j a v  a  2 s  .c o m*/
 * 
 * @param tobeDeleteUser
 */
public void deleteContact(final User tobeDeleteUser) {
    String st1 = getResources().getString(R.string.deleting);
    final String st2 = getResources().getString(R.string.Delete_failed);
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
                // db?
                UserDao dao = new UserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getUsername());
                ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList()
                        .remove(tobeDeleteUser.getUsername());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

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

            }

        }
    }).start();

}

From source file:dong.lan.tuyi.activity.ContactlistFragment.java

/**
 * ?//from w  ww  . ja v  a2s  . c om
 *
 */
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 {
                BmobQuery<TUser> query = new BmobQuery<TUser>();
                query.addWhereEqualTo("tUser", tobeDeleteUser.getUsername());
                query.findObjects(getActivity(), new FindListener<TUser>() {
                    @Override
                    public void onSuccess(List<TUser> list) {
                        if (list.isEmpty()) {
                            Config.Show(getActivity(), "");
                        } else {
                            BmobRelation relation = new BmobRelation();
                            relation.remove(list.get(0));
                            Config.tUser.update(getActivity(), new UpdateListener() {
                                @Override
                                public void onSuccess() {
                                    try {
                                        EMContactManager.getInstance()
                                                .deleteContact(tobeDeleteUser.getUsername());
                                    } catch (EaseMobException e) {
                                        e.printStackTrace();
                                    }
                                    // db?
                                    UserDao dao = new UserDao(getActivity());
                                    dao.deleteContact(tobeDeleteUser.getUsername());
                                    TuApplication.getInstance().getContactList()
                                            .remove(tobeDeleteUser.getUsername());
                                    getActivity().runOnUiThread(new Runnable() {
                                        public void run() {
                                            pd.dismiss();
                                            adapter.remove(tobeDeleteUser);
                                            adapter.notifyDataSetChanged();

                                        }
                                    });
                                }

                                @Override
                                public void onFailure(int i, String s) {

                                }
                            });
                        }
                    }

                    @Override
                    public void onError(int i, String s) {

                    }
                });
            } 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:org.telegram.ui.ChangeUsernameActivity.java

private void saveName() {
    if (!checkUserName(firstNameField.getText().toString(), true)) {
        return;/*from  ww  w  .  jav  a 2 s.co  m*/
    }
    TLRPC.User user = UserConfig.getCurrentUser();
    if (getParentActivity() == null || user == null) {
        return;
    }
    String currentName = user.username;
    if (currentName == null) {
        currentName = "";
    }
    String newName = firstNameField.getText().toString();
    if (currentName.equals(newName)) {
        finishFragment();
        return;
    }

    final ProgressDialog progressDialog = new ProgressDialog(getParentActivity());
    progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setCancelable(false);

    TLRPC.TL_account_updateUsername req = new TLRPC.TL_account_updateUsername();
    req.username = newName;

    NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces,
            MessagesController.UPDATE_MASK_NAME);
    final int reqId = ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
        @Override
        public void run(TLObject response, final TLRPC.TL_error error) {
            if (error == null) {
                final TLRPC.User user = (TLRPC.User) response;
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            progressDialog.dismiss();
                        } catch (Exception e) {
                            FileLog.e("tmessages", e);
                        }
                        ArrayList<TLRPC.User> users = new ArrayList<>();
                        users.add(user);
                        MessagesController.getInstance().putUsers(users, false);
                        MessagesStorage.getInstance().putUsersAndChats(users, null, false, true);
                        UserConfig.saveConfig(true);
                        finishFragment();
                    }
                });
            } else {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            progressDialog.dismiss();
                        } catch (Exception e) {
                            FileLog.e("tmessages", e);
                        }
                        showErrorAlert(error.text);
                    }
                });
            }
        }
    }, ConnectionsManager.RequestFlagFailOnServerErrors);
    ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid);

    progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
            LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    ConnectionsManager.getInstance().cancelRequest(reqId, true);
                    try {
                        dialog.dismiss();
                    } catch (Exception e) {
                        FileLog.e("tmessages", e);
                    }
                }
            });
    progressDialog.show();
}

From source file:com.easemob.chatui.activity.ContactlistFragment.java

/**
 * ?/*from   w w w .j  a  va 2s .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());
                /**?????*/
                HttpUtils httpUtils = new HttpUtils();
                MyRequestParams params = new MyRequestParams();
                params.addQueryStringParameter("userid",
                        BeewayApplication.getInstance().getmUserid(getActivity()));
                params.addQueryStringParameter("friendid", tobeDeleteUser.getUsername());
                //                        params.addBodyParameter("iden", iden);
                String url = params.myRequestParams(params);
                httpUtils.send(HttpRequest.HttpMethod.POST, UrlPools.DEL_FRIEND + "?" + url,
                        new RequestCallBack<String>() {

                            @Override
                            public void onSuccess(ResponseInfo<String> responseInfo) {
                                String result = responseInfo.result;
                                DelBean delBean = paraseDelData(result);
                                if (delBean.getStatus() == 1) {
                                    /**db??*/
                                    FriendDao friendDao = new FriendDao(getActivity());
                                    friendDao.deleteFriend(tobeDeleteUser.getUsername());
                                    Toast.makeText(getActivity(), "?", Toast.LENGTH_SHORT).show();

                                }
                            }

                            @Override
                            public void onFailure(HttpException e, String s) {
                                LogUtils.e(s);
                            }
                        });
                BeewayApplication.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.ame.armymax.SearchActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);

    context = this;
    DataUser.context = context;/*  www .  j a  v  a2 s. c  o  m*/
    aq = new AQuery(this);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setTitle("");

    query = getIntent().getStringExtra("query");

    searchBox = (BootstrapEditText) findViewById(R.id.room_name);
    searchBox.setText(query);

    searchButton = (Button) findViewById(R.id.search_button);
    searchButton.setVisibility(View.GONE);

    intent = new Intent(this, ProfileActivity.class);

    searchButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            query = searchBox.getEditableText().toString();

            if (!query.equals("")) {
                String resultUrl = "http://www.armymax.com/api/?action=search&txt=" + query
                        + "&startPoint=0&sizePage=50";
                ProgressDialog dialog = new ProgressDialog(context);
                dialog.setIndeterminate(true);
                dialog.setCancelable(true);
                dialog.setInverseBackgroundForced(false);
                dialog.setCanceledOnTouchOutside(true);
                dialog.setTitle("Finding ...");
                Log.e("searchurl", resultUrl);
                newSearch = true;
                aq.progress(dialog).ajax(resultUrl, JSONObject.class, context, "newSearchResultCb");

            }

        }
    });

    searchBox.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            query = searchBox.getEditableText().toString();

            if (!query.equals("")) {
                String resultUrl = "http://www.armymax.com/api/?action=search&txt=" + query
                        + "&startPoint=0&sizePage=20";

                ProgressDialog dialog = new ProgressDialog(context);
                dialog.setIndeterminate(true);
                dialog.setCancelable(true);
                dialog.setInverseBackgroundForced(false);
                dialog.setCanceledOnTouchOutside(true);
                dialog.setTitle("Finding ...");
                newSearch = true;
                Log.e("q", query);
                aq.ajax(resultUrl, JSONObject.class, context, "newSearchResultCb");
            }

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub

        }

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

        }
    });

    String resultUrl = "http://www.armymax.com/api/?action=search&txt=" + query + "&startPoint=0&sizePage=50";
    aq.ajax(resultUrl, JSONObject.class, this, "searchResultCb");

}

From source file:com.sxt.superqq.activity.LoginActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {
        if (requestCode == REQUEST_CODE_SETNICK) {
            SuperQQApplication.currentUserNick = data.getStringExtra("edittext");

            progressShow = true;//  ww w.  j  a v a 2 s. com
            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();
            // sdk??
            EMChatManager.getInstance().login(currentUsername, currentPassword, new EMCallBack() {

                @Override
                public void onSuccess() {

                    if (!progressShow) {
                        return;
                    }
                    // ?????
                    SuperQQApplication.getInstance().setUserName(currentUsername);
                    SuperQQApplication.getInstance().setPassword(currentPassword);

                    runOnUiThread(new Runnable() {
                        public void run() {
                            pd.setMessage(getString(R.string.list_is_for));
                        }
                    });
                    try {
                        // ** ?logout???
                        // ** manually load all local groups and
                        // conversations in case we are auto login
                        EMGroupManager.getInstance().loadAllGroups();
                        EMChatManager.getInstance().loadAllConversations();
                        //??
                        processContactsAndGroups();
                    } catch (Exception e) {
                        e.printStackTrace();
                        //?????
                        runOnUiThread(new Runnable() {
                            public void run() {
                                pd.dismiss();
                                SuperQQApplication.getInstance().logout(null);
                                Toast.makeText(getApplicationContext(), R.string.login_failure_failed, 1)
                                        .show();
                            }
                        });
                        return;
                    }
                    //?nickname ios?nick
                    boolean updatenick = EMChatManager.getInstance()
                            .updateCurrentUserNick(SuperQQApplication.currentUserNick.trim());
                    if (!updatenick) {
                        Log.e("LoginActivity", "update current user nick fail");
                    }
                    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(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();
                        }
                    });
                }
            });

        }
    }
}

From source file:com.easemob.chatuidemo.activity.ContactlistFragment.java

/**
 * ?//  w w w.j ava  2 s.co  m
 * 
 */
public void deleteContact(final User tobeDeleteUser) {
    String st1 = getResources().getString(R.string.deleting);
    final String st2 = getResources().getString(R.string.Delete_failed);
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
                // db?
                UserDao dao = new UserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getUsername());
                ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList()
                        .remove(tobeDeleteUser.getUsername());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

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

            }

        }
    }).start();

}

From source file:cn.ucai.superwechat.fragment.ContactlistFragment.java

/**
 * ?/*from  w w w  .  jav  a  2s.  co  m*/
 * 
 * @param
 */
public void deleteContact(final Contact tobeDeleteUser) {
    String st1 = getResources().getString(cn.ucai.superwechat.R.string.deleting);
    final String st2 = getResources().getString(cn.ucai.superwechat.R.string.Delete_failed);
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    try {
        String path = new ApiParams()
                .with(I.Contact.USER_NAME, superWeChatApplication.getInstance().getUserName())
                .with(I.Contact.CU_NAME, tobeDeleteUser.getMUserName()).getRequestUrl(I.REQUEST_DELETE_CONTACT);
        ((MainActivity) getActivity()).executeRequest(new GsonRequest<Boolean>(path, Boolean.class,
                responseDeleteContactListener(tobeDeleteUser), ((MainActivity) getActivity()).errorListener()));
    } catch (Exception e) {
        e.printStackTrace();
    }
    new Thread(new Runnable() {
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getMContactCname());
                // db?
                EMUserDao dao = new EMUserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getMContactCname());
                ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList()
                        .remove(tobeDeleteUser.getMContactCname());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

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

            }

        }
    }).start();

}

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

/**
 * ?/*from w  w  w. ja  va 2s  .c om*/
 * 
 * @param tobeDeleteUser
 */
public void deleteContact(final Contact 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();
    try {
    } catch (Exception e) {
        e.printStackTrace();
    }
    new Thread(new Runnable() {
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getMContactCname());
                // db?
                EMUserDao dao = new EMUserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getMContactCname());
                ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList()
                        .remove(tobeDeleteUser.getMContactCname());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

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

            }

        }
    }).start();

}

From source file:cn.hbm.superwechat.activity.ContactlistFragment.java

/**
 * ?/*from w w  w.j a  va 2  s . c o m*/
 *
 * @param tobeDeleteUser
 */
public void deleteContact(final User tobeDeleteUser) {
    String st1 = getResources().getString(R.string.deleting);
    final String st2 = getResources().getString(R.string.Delete_failed);
    final ProgressDialog pd = new ProgressDialog(getActivity());
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    new Thread(new Runnable() {
        public void run() {
            try {
                EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
                //??
                deleteMyContact(toBeProcessUser);
                // db?
                UserDao dao = new UserDao(getActivity());
                dao.deleteContact(tobeDeleteUser.getUsername());
                ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList()
                        .remove(tobeDeleteUser.getUsername());
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        adapter.remove(tobeDeleteUser);
                        adapter.notifyDataSetChanged();

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

            }

        }
    }).start();

}