Example usage for android.app ProgressDialog setMessage

List of usage examples for android.app ProgressDialog setMessage

Introduction

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

Prototype

@Override
    public void setMessage(CharSequence message) 

Source Link

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//from  w ww  .j ava2  s .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:cn.edu.nju.dapenti.activity.EditFeedActivity.java

public void onClickSearch(View view) {
    final View dialogView = getLayoutInflater().inflate(R.layout.dialog_search_feed, null);
    final EditText searchText = (EditText) dialogView.findViewById(R.id.searchText);
    final RadioGroup radioGroup = (RadioGroup) dialogView.findViewById(R.id.radioGroup);

    new AlertDialog.Builder(EditFeedActivity.this) //
            .setIcon(R.drawable.action_search) //
            .setTitle(R.string.feed_search) //
            .setView(dialogView) //
            .setPositiveButton(android.R.string.search_go, new DialogInterface.OnClickListener() {
                @Override/*from  w w  w . j ava  2s  . c om*/
                public void onClick(DialogInterface dialog, int which) {

                    if (searchText.getText().length() > 0) {
                        String tmp = searchText.getText().toString();
                        try {
                            tmp = URLEncoder.encode(searchText.getText().toString(), Constants.UTF8);
                        } catch (UnsupportedEncodingException ignored) {
                        }
                        final String text = tmp;

                        switch (radioGroup.getCheckedRadioButtonId()) {
                        case R.id.byWebSearch:
                            final ProgressDialog pd = new ProgressDialog(EditFeedActivity.this);
                            pd.setMessage(getString(R.string.loading));
                            pd.setCancelable(true);
                            pd.setIndeterminate(true);
                            pd.show();

                            getLoaderManager().restartLoader(1, null,
                                    new LoaderCallbacks<ArrayList<HashMap<String, String>>>() {

                                        @Override
                                        public Loader<ArrayList<HashMap<String, String>>> onCreateLoader(int id,
                                                Bundle args) {
                                            return new GetFeedSearchResultsLoader(EditFeedActivity.this, text);
                                        }

                                        @Override
                                        public void onLoadFinished(
                                                Loader<ArrayList<HashMap<String, String>>> loader,
                                                final ArrayList<HashMap<String, String>> data) {
                                            pd.cancel();

                                            if (data == null) {
                                                Toast.makeText(EditFeedActivity.this, R.string.error,
                                                        Toast.LENGTH_SHORT).show();
                                            } else if (data.isEmpty()) {
                                                Toast.makeText(EditFeedActivity.this, R.string.no_result,
                                                        Toast.LENGTH_SHORT).show();
                                            } else {
                                                AlertDialog.Builder builder = new AlertDialog.Builder(
                                                        EditFeedActivity.this);
                                                builder.setTitle(R.string.feed_search);

                                                // create the grid item mapping
                                                String[] from = new String[] { FEED_SEARCH_TITLE,
                                                        FEED_SEARCH_DESC };
                                                int[] to = new int[] { android.R.id.text1, android.R.id.text2 };

                                                // fill in the grid_item layout
                                                SimpleAdapter adapter = new SimpleAdapter(EditFeedActivity.this,
                                                        data, R.layout.item_search_result, from, to);
                                                builder.setAdapter(adapter,
                                                        new DialogInterface.OnClickListener() {
                                                            @Override
                                                            public void onClick(DialogInterface dialog,
                                                                    int which) {
                                                                mNameEditText.setText(
                                                                        data.get(which).get(FEED_SEARCH_TITLE));
                                                                mUrlEditText.setText(
                                                                        data.get(which).get(FEED_SEARCH_URL));
                                                            }
                                                        });
                                                builder.show();
                                            }
                                        }

                                        @Override
                                        public void onLoaderReset(
                                                Loader<ArrayList<HashMap<String, String>>> loader) {
                                        }
                                    }).forceLoad();
                            break;

                        case R.id.byTopic:
                            mUrlEditText.setText("http://www.faroo.com/api?q=" + text
                                    + "&start=1&length=10&l=en&src=news&f=rss");
                            break;

                        case R.id.byYoutube:
                            mUrlEditText.setText("http://www.youtube.com/rss/user/" + text.replaceAll("\\+", "")
                                    + "/videos.rss");
                            break;
                        }
                    }
                }
            }).setNegativeButton(android.R.string.cancel, null).show();
}

From source file:co.nerdart.ourss.activity.EditFeedActivity.java

public void onClickSearch(View view) {
    final View dialogView = getLayoutInflater().inflate(R.layout.search_feed, null);
    final EditText searchText = (EditText) dialogView.findViewById(R.id.searchText);
    final RadioGroup radioGroup = (RadioGroup) dialogView.findViewById(R.id.radioGroup);

    new AlertDialog.Builder(EditFeedActivity.this) //
            .setIcon(R.drawable.action_search) //
            .setTitle(R.string.feed_search) //
            .setView(dialogView) //
            .setPositiveButton(android.R.string.search_go, new DialogInterface.OnClickListener() {
                @Override//from   ww w. ja v  a 2 s. c  om
                public void onClick(DialogInterface dialog, int which) {

                    if (searchText.getText().length() > 0) {
                        String tmp = searchText.getText().toString();
                        try {
                            tmp = URLEncoder.encode(searchText.getText().toString(), Constants.UTF8);
                        } catch (UnsupportedEncodingException ignored) {
                        }
                        final String text = tmp;

                        switch (radioGroup.getCheckedRadioButtonId()) {
                        case R.id.byWebSearch:
                            final ProgressDialog pd = new ProgressDialog(EditFeedActivity.this);
                            pd.setMessage(getString(R.string.loading));
                            pd.setCancelable(true);
                            pd.setIndeterminate(true);
                            pd.show();

                            getLoaderManager().restartLoader(1, null,
                                    new LoaderCallbacks<ArrayList<HashMap<String, String>>>() {

                                        @Override
                                        public Loader<ArrayList<HashMap<String, String>>> onCreateLoader(int id,
                                                Bundle args) {
                                            return new GetFeedSearchResultsLoader(EditFeedActivity.this, text);
                                        }

                                        @Override
                                        public void onLoadFinished(
                                                Loader<ArrayList<HashMap<String, String>>> loader,
                                                final ArrayList<HashMap<String, String>> data) {
                                            pd.cancel();

                                            if (data == null) {
                                                Crouton.makeText(EditFeedActivity.this, R.string.error,
                                                        Style.INFO);
                                            } else if (data.isEmpty()) {
                                                Crouton.makeText(EditFeedActivity.this, R.string.no_result,
                                                        Style.INFO);
                                            } else {
                                                AlertDialog.Builder builder = new AlertDialog.Builder(
                                                        EditFeedActivity.this);
                                                builder.setTitle(R.string.feed_search);

                                                // create the grid item mapping
                                                String[] from = new String[] { FEED_SEARCH_TITLE,
                                                        FEED_SEARCH_DESC };
                                                int[] to = new int[] { android.R.id.text1, android.R.id.text2 };

                                                // fill in the grid_item layout
                                                SimpleAdapter adapter = new SimpleAdapter(EditFeedActivity.this,
                                                        data, R.layout.search_result_item, from, to);
                                                builder.setAdapter(adapter,
                                                        new DialogInterface.OnClickListener() {
                                                            @Override
                                                            public void onClick(DialogInterface dialog,
                                                                    int which) {
                                                                mNameEditText.setText(
                                                                        data.get(which).get(FEED_SEARCH_TITLE));
                                                                mUrlEditText.setText(
                                                                        data.get(which).get(FEED_SEARCH_URL));
                                                            }
                                                        });
                                                builder.show();
                                            }
                                        }

                                        @Override
                                        public void onLoaderReset(
                                                Loader<ArrayList<HashMap<String, String>>> loader) {
                                        }
                                    }).forceLoad();
                            break;

                        case R.id.byTopic:
                            mUrlEditText.setText("http://www.faroo.com/api?q=" + text
                                    + "&start=1&length=10&l=en&src=news&f=rss");
                            break;

                        case R.id.byYoutube:
                            mUrlEditText.setText("http://www.youtube.com/rss/user/" + text.replaceAll("\\+", "")
                                    + "/videos.rss");
                            break;
                        }
                    }
                }
            }).setNegativeButton(android.R.string.cancel, null).show();
}

From source file:com.xabber.android.ui.activity.ContactList.java

@Override
protected Dialog onCreateDialog(int id) {
    super.onCreateDialog(id);
    switch (id) {
    case DIALOG_CLOSE_APPLICATION_ID:
        ProgressDialog progressDialog = new ProgressDialog(this);
        progressDialog.setMessage(getString(R.string.application_state_closing));
        progressDialog.setOnCancelListener(new OnCancelListener() {
            @Override//  ww  w  .  ja v  a  2  s.c  o m
            public void onCancel(DialogInterface dialog) {
                finish();
            }
        });
        progressDialog.setIndeterminate(true);
        return progressDialog;
    default:
        return null;
    }
}

From source file:com.cellobject.oikos.FormActivity.java

/**
 * For API level 8 or newer. /*  w  ww  .j  a v  a 2  s .  c om*/
 */
public Dialog onCreateDialog(final int id, final Bundle args) {
    if (id == SUBMITTING_DIALOG) {
        final ProgressDialog dlg = new ProgressDialog(this);
        dlg.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        dlg.setMessage(getText(R.string.submitting));
        dlg.setIndeterminate(true);
        return dlg;
    }
    return null;
}

From source file:com.cellobject.oikos.FormActivity.java

/**
 * For API level lower than 8. /*from   ww  w. j  a va  2s.  c o m*/
 */
public Dialog onCreateDialog(final int id) {
    if (id == SUBMITTING_DIALOG) {
        final ProgressDialog dlg = new ProgressDialog(this);
        dlg.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        dlg.setMessage(getText(R.string.submitting));
        dlg.setIndeterminate(true);
        return dlg;
    }
    return null;
}

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

/**
 * ??//  w  ww.  jav  a 2 s . c  o m
 */
public void s_reg_login(final String username, final String pwd) {
    if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(pwd)) {
        final ProgressDialog pd = new ProgressDialog(this);
        pd.setMessage("...");
        pd.show();
        new Thread(new Runnable() {
            public void run() {
                try {
                    // sdk
                    EMChatManager.getInstance().createAccountOnServer(username, pwd);
                    runOnUiThread(new Runnable() {
                        public void run() {
                            if (!LoginActivity.this.isFinishing())
                                pd.dismiss();
                            // ???
                            //                        DemoApplication.getInstance().setUserName(username);
                            DemoApplication.getInstance().setUser(username);
                            Toast.makeText(getApplicationContext(), "?", 0).show();
                            login(username, pwd);
                            //finish();
                        }
                    });
                } catch (final Exception e) {
                    runOnUiThread(new Runnable() {
                        public void run() {
                            if (!LoginActivity.this.isFinishing())
                                pd.dismiss();
                            if (e != null && e.getMessage() != null) {
                                String errorMsg = e.getMessage();
                                if (errorMsg.indexOf("EMNetworkUnconnectedException") != -1) {
                                    Toast.makeText(getApplicationContext(), "?",
                                            0).show();
                                } else if (errorMsg.indexOf("conflict") != -1) {
                                    login(username, pwd);
                                    //Toast.makeText(getApplicationContext(), "?", 0).show();
                                } else if (errorMsg.indexOf("not support the capital letters") != -1) {
                                    Toast.makeText(getApplicationContext(), "??????",
                                            0).show();
                                } else {
                                    Toast.makeText(getApplicationContext(), ": " + e.getMessage(),
                                            1).show();
                                }

                            } else {
                                Toast.makeText(getApplicationContext(), ": ", 1).show();

                            }
                        }
                    });
                }
            }
        }).start();

    }
}

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

/**
 * ?//w  ww . j  a  v a 2  s. c  om
 * 
 * @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();
}

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

private void applyCurrentPrivacySettings() {
    TLRPC.TL_account_setPrivacy req = new TLRPC.TL_account_setPrivacy();
    if (isGroup) {
        req.key = new TLRPC.TL_inputPrivacyKeyChatInvite();
    } else {//  w  w  w .ja  va  2  s.c om
        req.key = new TLRPC.TL_inputPrivacyKeyStatusTimestamp();
    }
    if (currentType != 0 && currentPlus.size() > 0) {
        TLRPC.TL_inputPrivacyValueAllowUsers rule = new TLRPC.TL_inputPrivacyValueAllowUsers();
        for (int a = 0; a < currentPlus.size(); a++) {
            TLRPC.User user = MessagesController.getInstance().getUser(currentPlus.get(a));
            if (user != null) {
                TLRPC.InputUser inputUser = MessagesController.getInputUser(user);
                if (inputUser != null) {
                    rule.users.add(inputUser);
                }
            }
        }
        req.rules.add(rule);
    }
    if (currentType != 1 && currentMinus.size() > 0) {
        TLRPC.TL_inputPrivacyValueDisallowUsers rule = new TLRPC.TL_inputPrivacyValueDisallowUsers();
        for (int a = 0; a < currentMinus.size(); a++) {
            TLRPC.User user = MessagesController.getInstance().getUser(currentMinus.get(a));
            if (user != null) {
                TLRPC.InputUser inputUser = MessagesController.getInputUser(user);
                if (inputUser != null) {
                    rule.users.add(inputUser);
                }
            }
        }
        req.rules.add(rule);
    }
    if (currentType == 0) {
        req.rules.add(new TLRPC.TL_inputPrivacyValueAllowAll());
    } else if (currentType == 1) {
        req.rules.add(new TLRPC.TL_inputPrivacyValueDisallowAll());
    } else if (currentType == 2) {
        req.rules.add(new TLRPC.TL_inputPrivacyValueAllowContacts());
    }
    ProgressDialog progressDialog = null;
    if (getParentActivity() != null) {
        progressDialog = new ProgressDialog(getParentActivity());
        progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
        progressDialog.setCanceledOnTouchOutside(false);
        progressDialog.setCancelable(false);
        progressDialog.show();
    }
    final ProgressDialog progressDialogFinal = progressDialog;
    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 {
                        if (progressDialogFinal != null) {
                            progressDialogFinal.dismiss();
                        }
                    } catch (Exception e) {
                        FileLog.e("tmessages", e);
                    }
                    if (error == null) {
                        finishFragment();
                        TLRPC.TL_account_privacyRules rules = (TLRPC.TL_account_privacyRules) response;
                        MessagesController.getInstance().putUsers(rules.users, false);
                        ContactsController.getInstance().setPrivacyRules(rules.rules, isGroup);
                    } else {
                        showErrorAlert();
                    }
                }
            });
        }
    }, ConnectionsManager.RequestFlagFailOnServerErrors);
}

From source file:jp.co.noxi.app.NXProgressDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        final ProgressDialog dialog = mProgressDialog = new ProgressDialog(getActivity());
        dialog.setProgressStyle(mStyle);
        dialog.setIndeterminate(mIndeterminate);
        if (mMax > 0) {
            dialog.setMax(mMax);/* ww  w .j  a va2  s .c o  m*/
        }
        if (mProgressVal > 0) {
            dialog.setProgress(mProgressVal);
        }
        if (mSecondaryProgressVal > 0) {
            dialog.setSecondaryProgress(mSecondaryProgressVal);
        }
        if (mMessage != null) {
            dialog.setMessage(mMessage);
        }
        if (mFormat != null) {
            dialog.setProgressNumberFormat(mFormat);
        }
        return dialog;
    } else {
        final ProgressDialogGB dialog = mProgressDialogGB = new ProgressDialogGB(getActivity());
        dialog.setProgressStyle(mStyle);
        dialog.setIndeterminate(mIndeterminate);
        if (mMax > 0) {
            dialog.setMax(mMax);
        }
        if (mProgressVal > 0) {
            dialog.setProgress(mProgressVal);
        }
        if (mSecondaryProgressVal > 0) {
            dialog.setSecondaryProgress(mSecondaryProgressVal);
        }
        if (mMessage != null) {
            dialog.setMessage(mMessage);
        }
        if (mFormat != null) {
            dialog.setProgressNumberFormat(mFormat);
        }
        return dialog;
    }
}