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.atahani.telepathy.ui.fragment.AboutDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View customLayout = inflater.inflate(R.layout.fragment_about_dialog, null);
    //config app version information
    mAppPreferenceTools = new AppPreferenceTools(TApplication.applicationContext);
    AppCompatTextView txAndroidAppVerInfo = (AppCompatTextView) customLayout
            .findViewById(R.id.tx_android_ver_info);
    txAndroidAppVerInfo.setText(String.format(getString(R.string.label_telepathy_for_android),
            mAppPreferenceTools.getTheLastAppVersion()));
    txAndroidAppVerInfo.setOnClickListener(new View.OnClickListener() {
        @Override// ww w  .j av  a2s. c  o m
        public void onClick(View v) {
            try {
                //open browser to navigate telepathy website
                Uri telepathyWebSiteUri = Uri.parse("https://github.com/atahani/telepathy-android.git");
                startActivity(new Intent(Intent.ACTION_VIEW, telepathyWebSiteUri));
                ((TelepathyBaseActivity) getActivity()).setAnimationOnStart();
            } catch (Exception ex) {
                AndroidUtilities.processApplicationError(ex, true);
                if (isAdded() && getActivity() != null) {
                    Snackbar.make(getActivity().findViewById(android.R.id.content),
                            getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show();
                }
            }
        }
    });
    //config google play store link
    AppCompatTextView txRateUsOnGooglePlayStore = (AppCompatTextView) customLayout
            .findViewById(R.id.tx_rate_us_on_play_store);
    txRateUsOnGooglePlayStore.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //navigate to market for rate application
            Uri uri = Uri.parse("market://details?id=" + TApplication.applicationContext.getPackageName());
            Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
            // To count with Play market backstack, After pressing back button,
            // to taken back to our application, we need to add following flags to intent.
            goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
            try {
                startActivity(goToMarket);
                ((TelepathyBaseActivity) getActivity()).setAnimationOnStart();
            } catch (ActivityNotFoundException e) {
                startActivity(
                        new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id="
                                + TApplication.applicationContext.getPackageName())));
            }
        }
    });
    //config twitter link
    AppCompatTextView txTwitterLink = (AppCompatTextView) customLayout.findViewById(R.id.tx_twitter_telepathy);
    txTwitterLink.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                // If Twitter app is not installed, start browser.
                Uri twitterUri = Uri.parse("http://twitter.com/");
                startActivity(new Intent(Intent.ACTION_VIEW, twitterUri));
                ((TelepathyBaseActivity) getActivity()).setAnimationOnStart();
            } catch (Exception ex) {
                AndroidUtilities.processApplicationError(ex, true);
                if (isAdded() && getActivity() != null) {
                    Snackbar.make(getActivity().findViewById(android.R.id.content),
                            getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show();
                }
            }
        }
    });
    //config privacy link
    AppCompatTextView txPrivacyLink = (AppCompatTextView) customLayout.findViewById(R.id.tx_privacy);
    txPrivacyLink.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                //open browser to navigate privacy link
                Uri privacyPolicyUri = Uri
                        .parse("https://github.com/atahani/telepathy-android/blob/master/LICENSE.md");
                startActivity(new Intent(Intent.ACTION_VIEW, privacyPolicyUri));
                ((TelepathyBaseActivity) getActivity()).setAnimationOnStart();
            } catch (Exception ex) {
                AndroidUtilities.processApplicationError(ex, true);
                if (isAdded() && getActivity() != null) {
                    Snackbar.make(getActivity().findViewById(android.R.id.content),
                            getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show();
                }
            }
        }
    });
    //config report bug to open mail application and send bugs report
    AppCompatTextView txReportBug = (AppCompatTextView) customLayout.findViewById(R.id.tx_report_bug);
    txReportBug.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                final Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
                emailIntent.setType("plain/text");
                emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                        getString(R.string.label_report_bug_email_subject));
                emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailDeviceInformation());
                emailIntent.setData(Uri.parse("mailto:" + getString(R.string.telepathy_report_bug_email)));
                startActivity(Intent.createChooser(emailIntent,
                        getString(R.string.label_report_bug_choose_mail_app)));
                ((TelepathyBaseActivity) getActivity()).setAnimationOnStart();
            } catch (Exception ex) {
                AndroidUtilities.processApplicationError(ex, true);
                if (isAdded() && getActivity() != null) {
                    Snackbar.make(getActivity().findViewById(android.R.id.content),
                            getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show();
                }
            }
        }
    });
    //config the about footer image view
    AboutFooterImageView footerImageView = (AboutFooterImageView) customLayout
            .findViewById(R.id.im_delete_user_account);
    footerImageView.setTouchOnImageViewEventListener(new AboutFooterImageView.touchOnImageViewEventListener() {
        @Override
        public void onDoubleTab() {
            try {
                //confirm account delete via alert dialog
                final AlertDialog.Builder confirmAccountDeleteDialog = new AlertDialog.Builder(getActivity());
                confirmAccountDeleteDialog.setTitle(getString(R.string.label_delete_user_account));
                confirmAccountDeleteDialog
                        .setMessage(getString(R.string.label_delete_user_account_description));
                confirmAccountDeleteDialog.setNegativeButton(getString(R.string.action_no), null);
                confirmAccountDeleteDialog.setPositiveButton(getString(R.string.action_yes),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                //ok to delete account action
                                final ProgressDialog progressDialog = new ProgressDialog(getActivity());
                                progressDialog.setCancelable(false);
                                progressDialog.setCanceledOnTouchOutside(false);
                                progressDialog
                                        .setMessage(getString(R.string.re_action_on_deleting_user_account));
                                progressDialog.show();
                                TService tService = ((TelepathyBaseActivity) getActivity()).getTService();
                                tService.deleteUserAccount(new Callback<TOperationResultModel>() {
                                    @Override
                                    public void success(TOperationResultModel tOperationResultModel,
                                            Response response) {
                                        if (getActivity() != null && isAdded()) {
                                            //broad cast to close all of the realm  instance
                                            Intent intentToCloseRealm = new Intent(
                                                    Constants.TELEPATHY_BASE_ACTIVITY_INTENT_FILTER);
                                            intentToCloseRealm.putExtra(Constants.ACTION_TO_DO_PARAM,
                                                    Constants.CLOSE_REALM_DB);
                                            LocalBroadcastManager.getInstance(getActivity())
                                                    .sendBroadcastSync(intentToCloseRealm);
                                            mAppPreferenceTools.removeAllOfThePref();
                                            //                                 for sign out google first build GoogleAPIClient
                                            final GoogleApiClient googleApiClient = new GoogleApiClient.Builder(
                                                    TApplication.applicationContext)
                                                            .addApi(Auth.GOOGLE_SIGN_IN_API).build();
                                            googleApiClient.connect();
                                            googleApiClient.registerConnectionCallbacks(
                                                    new GoogleApiClient.ConnectionCallbacks() {
                                                        @Override
                                                        public void onConnected(Bundle bundle) {
                                                            Auth.GoogleSignInApi.signOut(googleApiClient)
                                                                    .setResultCallback(
                                                                            new ResultCallback<Status>() {
                                                                                @Override
                                                                                public void onResult(
                                                                                        Status status) {
                                                                                    //also revoke google access
                                                                                    Auth.GoogleSignInApi
                                                                                            .revokeAccess(
                                                                                                    googleApiClient)
                                                                                            .setResultCallback(
                                                                                                    new ResultCallback<Status>() {
                                                                                                        @Override
                                                                                                        public void onResult(
                                                                                                                Status status) {
                                                                                                            progressDialog
                                                                                                                    .dismiss();
                                                                                                            TelepathyBaseActivity currentActivity = (TelepathyBaseActivity) TApplication.mCurrentActivityInApplication;
                                                                                                            if (currentActivity != null) {
                                                                                                                Intent intent = new Intent(
                                                                                                                        TApplication.applicationContext,
                                                                                                                        SignInActivity.class);
                                                                                                                intent.setFlags(
                                                                                                                        Intent.FLAG_ACTIVITY_CLEAR_TASK
                                                                                                                                | Intent.FLAG_ACTIVITY_NEW_TASK);
                                                                                                                currentActivity
                                                                                                                        .startActivity(
                                                                                                                                intent);
                                                                                                                currentActivity
                                                                                                                        .setAnimationOnStart();
                                                                                                                currentActivity
                                                                                                                        .finish();
                                                                                                            }
                                                                                                        }
                                                                                                    });
                                                                                }
                                                                            });
                                                        }

                                                        @Override
                                                        public void onConnectionSuspended(int i) {
                                                            //do nothing
                                                        }
                                                    });
                                        }
                                    }

                                    @Override
                                    public void failure(RetrofitError error) {
                                        progressDialog.dismiss();
                                        if (getActivity() != null && isAdded()) {
                                            CommonFeedBack commonFeedBack = new CommonFeedBack(
                                                    getActivity().findViewById(android.R.id.content),
                                                    getActivity());
                                            commonFeedBack.checkCommonErrorAndBackUnCommonOne(error);
                                        }
                                    }
                                });
                            }
                        });
                confirmAccountDeleteDialog.show();
            } catch (Exception ex) {
                AndroidUtilities.processApplicationError(ex, true);
                if (isAdded() && getActivity() != null) {
                    Snackbar.make(getActivity().findViewById(android.R.id.content),
                            getString(R.string.re_action_internal_app_error), Snackbar.LENGTH_LONG).show();
                }
            }
        }
    });
    builder.setView(customLayout);
    return builder.create();
}

From source file:com.zigvine.zagriculture.UIActivity.java

private void manualUpdateCheck() {
    final ProgressDialog pd = new ProgressDialog(this);
    pd.setMessage("");
    pd.setCanceledOnTouchOutside(false);
    pd.show();// ww  w.  j a  v  a  2s .  com
    MainApp.getInstance().startCheck(new UpdateCheckListener() {
        @Override
        public void onCheckedOver(int result) {
            pd.dismiss();
            if (result == MainApp.CHECKED_NO_NEED) {
                UI.toast("?");
            } else if (result == MainApp.UNCHECKED) {
                UI.toast("");
            }
        }
    }, true);
}

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

/**
 * ?//from  www .  j a v  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());
                ((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();
    String userName = SuperWeChatApplication.getInstance().getUserName();
    OkHttpUtils2<Result> utils2 = new OkHttpUtils2<>();
    utils2.setRequestUrl(I.REQUEST_DELETE_CONTACT).addParam(I.Contact.USER_NAME, userName)
            .addParam(I.Contact.CU_NAME, tobeDeleteUser.getUsername()).targetClass(Result.class)
            .execute(new OkHttpUtils2.OnCompleteListener<Result>() {
                @Override
                public void onSuccess(Result result) {
                    if (result.isRetMsg()) {
                        UserAvatar ua = SuperWeChatApplication.getInstance().getContactMap()
                                .get(tobeDeleteUser.getUsername());
                        SuperWeChatApplication.getInstance().getUserContactList().remove(ua);
                        SuperWeChatApplication.getInstance().getContactMap()
                                .remove(tobeDeleteUser.getUsername());
                        getActivity().sendStickyBroadcast(new Intent("update_contact_list"));
                        Log.e(TAG, "delUsername=" + tobeDeleteUser.getUsername());
                    }
                }

                @Override
                public void onError(String error) {
                    Log.e(TAG, "error=" + error);
                }
            });
}

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

/**
 * ?//  w  ww .j  a v a  2s  .  c  om
 */
private void setLoginClickListener() {
    findViewById(R.id.btnLogin).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!CommonUtils.isNetWorkConnected(LoginActivity.this)) {
                Toast.makeText(LoginActivity.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(LoginActivity.this, R.string.User_name_cannot_be_empty, Toast.LENGTH_SHORT)
                        .show();
                return;
            }
            if (TextUtils.isEmpty(currentPassword)) {
                Toast.makeText(LoginActivity.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();
            // sdk??
            EMChatManager.getInstance().login(currentUsername, currentPassword, new EMCallBack() {
                @Override
                public void onSuccess() {

                    if (!progressShow) {
                        return;
                    }

                    runOnUiThread(new Runnable() {
                        public void run() {
                            pd.setMessage(getString(R.string.list_is_for));
                        }
                    });
                    try {

                        //?
                        boolean isSuccess = loginAppServer(currentUsername, currentPassword);
                        if (!isSuccess) {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    Toast.makeText(LoginActivity.this, "", 2000).show();
                                    return;
                                }
                            });
                        }
                        final String userName = SuperQQApplication.getInstance().getUserName();
                        //?
                        isSuccess = NetUtils.downloadAvatar(LoginActivity.this, userName);

                        if (SuperQQApplication.getInstance().getContacts().size() == 0) {
                            //,20userName??
                            new DownloadContactsTask(LoginActivity.this, userName, 0, 20)
                                    .execute(I.SERVER_ROOT);
                        }
                        if (!isSuccess) {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    Toast.makeText(LoginActivity.this, userName + "?", 3000)
                                            .show();
                                }
                            });
                        }
                        // ** ?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();
                        }
                    });
                }
            });
            //                Intent intent = new Intent(LoginActivity.this, com.sxt.superqq.activity.AlertDialogActivity.class);
            //                intent.putExtra("editTextShow", true);
            //                intent.putExtra("titleIsCancel", true);
            //                intent.putExtra("msg", getResources().getString(R.string.please_set_the_current));
            //                intent.putExtra("edit_text", currentUsername);
            //                startActivityForResult(intent, REQUEST_CODE_SETNICK);
        }
    });
}

From source file:com.hyphenate.easeui.ui.EaseContactListFragment.java

/**
 * move user to blacklist/*from   w ww  .jav a 2  s. c  om*/
 */
protected 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 {
                //move to blacklist
                EMClient.getInstance().contactManager().addUserToBlackList(username, false);
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2, Toast.LENGTH_SHORT).show();
                        refresh();
                    }
                });
            } catch (HyphenateException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st3, Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    }).start();

}

From source file:com.nxt.njitong.ContactlistActivity.java

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

}

From source file:cn.ucai.wechat.ui.SettingsActivity.java

void logout() {
    final ProgressDialog pd = new ProgressDialog(SettingsActivity.this);
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);/*from  w  w  w .  j a  v a2 s .c  om*/
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    WeChatHelper.getInstance().logout(false, new EMCallBack() {

        @Override
        public void onSuccess() {
            runOnUiThread(new Runnable() {
                public void run() {
                    pd.dismiss();
                    finish();
                    // show login screen
                    MFGT.gotoLoginActivity(SettingsActivity.this);

                }
            });
        }

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

        }

        @Override
        public void onError(int code, String message) {
            runOnUiThread(new Runnable() {

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

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

/**
 * ?//  ww w.jav a  2 s  .  c o m
 * 
 * @param tobeDeleteUser
 */
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.getMContactCname())
                .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:com.eleybourn.bookcatalogue.utils.SimpleTaskQueueProgressFragment.java

/**
 * Create the underlying dialog/*  w  ww.  j a v a  2  s . c  om*/
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    ProgressDialog dialog = new ProgressDialog(getActivity());
    dialog.setCancelable(true);
    dialog.setCanceledOnTouchOutside(false);

    int msg = getArguments().getInt("title");
    if (msg != 0)
        dialog.setMessage(getActivity().getString(msg));
    final boolean isIndet = getArguments().getBoolean("isIndeterminate");
    dialog.setIndeterminate(isIndet);
    if (isIndet) {
        dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    } else {
        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    }

    // We can't use "this.requestUpdateProgress()" because getDialog() will still return null
    if (!isIndet) {
        dialog.setMax(mMax);
        dialog.setProgress(mProgress);
        if (mMessage != null)
            dialog.setMessage(mMessage);
        setDialogNumberFormat(dialog);
    }

    return dialog;
}

From source file:com.app.khclub.base.easeim.activity.ContactlistFragment.java

/**
 * ?//  w  w  w  .j av  a 2s  .  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();

    // ?
    RequestParams params = new RequestParams();
    params.addBodyParameter("user_id", UserManager.getInstance().getUser().getUid() + "");
    params.addBodyParameter("target_id", tobeDeleteUser.getUsername().replace(KHConst.KH, ""));

    HttpManager.post(KHConst.DELETE_FRIEND, params,
            new JsonRequestCallBack<String>(new LoadDataHandler<String>() {
                @Override
                public void onSuccess(JSONObject jsonResponse, String flag) {
                    super.onSuccess(jsonResponse, flag);
                    int status = jsonResponse.getInteger(KHConst.HTTP_STATUS);
                    if (status == KHConst.STATUS_SUCCESS) {
                        new Thread(new Runnable() {
                            public void run() {
                                try {
                                    EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
                                    // db?
                                    UserDao dao = new UserDao(getActivity());
                                    dao.deleteContact(tobeDeleteUser.getUsername());
                                    ((KHHXSDKHelper) HXSDKHelper.getInstance()).getContactList()
                                            .remove(tobeDeleteUser.getUsername());
                                    getActivity().runOnUiThread(new Runnable() {
                                        public void run() {
                                            pd.dismiss();
                                            adapter.remove(tobeDeleteUser);
                                            adapter.notifyDataSetChanged();
                                        }
                                    });
                                    // ?
                                    InviteMessgeDao msgDao = new InviteMessgeDao(getActivity());
                                    msgDao.deleteMessage(toBeProcessUser.getUsername());
                                } catch (final Exception e) {
                                    getActivity().runOnUiThread(new Runnable() {
                                        public void run() {
                                            pd.dismiss();
                                            Toast.makeText(getActivity(), st2 + e.getMessage(), 1).show();
                                        }
                                    });
                                }
                            }
                        }).start();
                    } else {
                        ToastUtil.show(getActivity(), R.string.net_error);
                        pd.dismiss();
                    }
                }

                @Override
                public void onFailure(HttpException arg0, String arg1, String flag) {
                    super.onFailure(arg0, arg1, flag);
                    ToastUtil.show(getActivity(), R.string.net_error);
                    pd.dismiss();
                }
            }, null));

    // new Thread(new Runnable() {
    // public void run() {
    // try {
    // EMContactManager.getInstance().deleteContact(tobeDeleteUser.getUsername());
    // // db?
    // UserDao dao = new UserDao(getActivity());
    // dao.deleteContact(tobeDeleteUser.getUsername());
    // ((KHHXSDKHelper)HXSDKHelper.getInstance()).getContactList().remove(tobeDeleteUser.getUsername());
    // getActivity().runOnUiThread(new Runnable() {
    // public void run() {
    // pd.dismiss();
    // adapter.remove(tobeDeleteUser);
    // adapter.notifyDataSetChanged();
    //
    // }
    // });
    // // ?
    // InviteMessgeDao msgDao = new InviteMessgeDao(getActivity());
    // msgDao.deleteMessage(toBeProcessUser.getUsername());
    // } catch (final Exception e) {
    // getActivity().runOnUiThread(new Runnable() {
    // public void run() {
    // pd.dismiss();
    // Toast.makeText(getActivity(), st2 + e.getMessage(), 1).show();
    // }
    // });
    //
    // }
    //
    // }
    // }).start();
}