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:cn.ucai.superwechat.ui.SettingsActivity.java

void logout() {
    final ProgressDialog pd = new ProgressDialog(this);
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);
    pd.setCanceledOnTouchOutside(false);
    pd.show();/*  w  ww.j  a  va  2 s  .c o  m*/
    SuperWeChatHelper.getInstance().logout(false, new EMCallBack() {

        @Override
        public void onSuccess() {
            runOnUiThread(new Runnable() {
                public void run() {
                    pd.dismiss();
                    //                show login screen
                    //               ExitAppUtils.getInstance().exit();
                    finish();
                    startActivity(new Intent(SettingsActivity.this, LoginActivity.class)
                            .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK));

                }
            });
        }

        @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:com.liangxun.yuejiula.huanxin.chat.activity.GroupsActivity.java

public void addToGroup(final EMGroup group) {
    String st1 = getResources().getString(R.string.Is_sending_a_request);
    final String st2 = getResources().getString(R.string.Request_to_join);
    final String st3 = getResources().getString(R.string.send_the_request_is);
    final String st4 = getResources().getString(R.string.Join_the_group_chat);
    final String st5 = getResources().getString(R.string.Failed_to_join_the_group_chat);
    final ProgressDialog pd = new ProgressDialog(this);
    //      getResources().getString(R.string)
    pd.setMessage(st1);
    pd.setCanceledOnTouchOutside(false);
    pd.show();/*from   www .  jav a  2 s.  co  m*/
    new Thread(new Runnable() {
        public void run() {
            try {
                //membersOnly??join
                if (group.isMembersOnly()) {
                    EMGroupManager.getInstance().applyJoinToGroup(group.getGroupId(), st2);
                } else {
                    EMGroupManager.getInstance().joinGroup(group.getGroupId());
                }
                runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        if (group.isMembersOnly())
                            Toast.makeText(GroupsActivity.this, st3, Toast.LENGTH_SHORT).show();
                        else
                            Toast.makeText(GroupsActivity.this, st4, Toast.LENGTH_SHORT).show();
                    }
                });
            } catch (final EaseMobException e) {
                e.printStackTrace();
                runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(GroupsActivity.this, st5 + e.getMessage(), Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    }).start();
}

From source file:com.mobicage.rogerthat.GetLocationActivity.java

@Override
protected void onServiceBound() {
    T.UI();/*w  w w.ja v  a2s .  com*/
    setContentView(R.layout.get_location);

    mProgressDialog = new ProgressDialog(this);
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    mProgressDialog.setMessage(getString(R.string.updating_location));
    mProgressDialog.setCancelable(true);
    mProgressDialog.setCanceledOnTouchOutside(true);
    mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            T.UI();
            if (mLocationManager != null) {
                try {
                    mLocationManager.removeUpdates(mLocationListener);
                } catch (SecurityException e) {
                    L.bug(e); // Should never happen
                }
            }
        }
    });
    mProgressDialog.setMax(10000);

    mUseGPS = (CheckBox) findViewById(R.id.use_gps_provider);
    mGetCurrentLocationButton = (Button) findViewById(R.id.get_current_location);
    mAddress = (EditText) findViewById(R.id.address);
    mCalculate = (Button) findViewById(R.id.calculate);

    mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
    if (mLocationManager == null) {
        mGetCurrentLocationButton.setEnabled(false);
    } else {
        mUseGPS.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked && !mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
                    new AlertDialog.Builder(GetLocationActivity.this).setMessage(R.string.gps_is_not_enabled)
                            .setPositiveButton(R.string.yes, new SafeDialogInterfaceOnClickListener() {
                                @Override
                                public void safeOnClick(DialogInterface dialog, int which) {
                                    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                                    startActivityForResult(intent, TURNING_ON_GPS);
                                }
                            }).setNegativeButton(R.string.no, new SafeDialogInterfaceOnClickListener() {
                                @Override
                                public void safeOnClick(DialogInterface dialog, int which) {
                                    mUseGPS.setChecked(false);
                                }
                            }).create().show();
                }
            }
        });

        mGetCurrentLocationButton.setOnClickListener(new SafeViewOnClickListener() {
            @Override
            public void safeOnClick(View v) {
                T.UI();
                if (mService.isPermitted(Manifest.permission.ACCESS_FINE_LOCATION)) {
                    getMyLocation();
                } else {
                    ActivityCompat.requestPermissions(GetLocationActivity.this,
                            new String[] { Manifest.permission.ACCESS_FINE_LOCATION },
                            PERMISSION_REQUEST_ACCESS_FINE_LOCATION);
                }
            }
        });
    }

    mCalculate.setOnClickListener(new SafeViewOnClickListener() {
        @Override
        public void safeOnClick(View v) {
            final ProgressDialog pd = new ProgressDialog(GetLocationActivity.this);
            pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            pd.setMessage(getString(R.string.updating_location));
            pd.setCancelable(false);
            pd.setIndeterminate(true);
            pd.show();
            final String addressText = mAddress.getText().toString();
            mService.postOnIOHandler(new SafeRunnable() {
                @Override
                protected void safeRun() throws Exception {
                    Geocoder geoCoder = new Geocoder(GetLocationActivity.this, Locale.getDefault());
                    try {
                        List<Address> addresses = geoCoder.getFromLocationName(addressText, 5);
                        if (addresses.size() > 0) {
                            Address address = addresses.get(0);
                            final Location location = new Location("");
                            location.setLatitude(address.getLatitude());
                            location.setLongitude(address.getLongitude());
                            mService.postOnUIHandler(new SafeRunnable() {
                                @Override
                                protected void safeRun() throws Exception {
                                    pd.dismiss();
                                    mLocation = location;
                                    showMap();
                                }
                            });
                            return;
                        }
                    } catch (IOException e) {
                        L.d("Failed to geo code address " + addressText, e);
                    }
                    mService.postOnUIHandler(new SafeRunnable() {
                        @Override
                        protected void safeRun() throws Exception {
                            pd.dismiss();
                            UIUtils.showLongToast(GetLocationActivity.this,
                                    getString(R.string.failed_to_lookup_address));
                        }
                    });
                }
            });
        }
    });
}

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

void logout() {
    ParseUser.logOut();/*from ww w  . j  av  a  2s .  c  om*/
    PreferencesManager mPreferencesManager = new PreferencesManager(getActivity());
    mPreferencesManager.writeBooleanPreference("LoggedIn", false);
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);
    pd.setCanceledOnTouchOutside(false);
    pd.show();
    IMHXSDKHelper.getInstance().logout(true, new EMCallBack() {

        @Override
        public void onSuccess() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    pd.dismiss();
                    // ??
                    ((IMMainActivity) getActivity()).finish();
                    startActivity(new Intent(getActivity(), cmu.cconfs.LoginActivity.class));

                }
            });
        }

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

        }

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

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

                }
            });
        }
    });
}

From source file:com.rastating.droidbeard.fragments.ShowFragment.java

private ProgressDialog createProgressDialog(String title, String message) {
    ProgressDialog dialog = new ProgressDialog(getActivity());
    dialog.setTitle(title);//from ww w .  ja  v a2s .c  o m
    dialog.setMessage(message);
    dialog.setCancelable(false);
    dialog.setIndeterminate(true);
    return dialog;
}

From source file:com.nanosheep.bikeroute.Feedback.java

@Override
public Dialog onCreateDialog(final int id) {
    AlertDialog.Builder builder;//from  w  ww  .j  a  v  a 2 s .  c  om
    ProgressDialog pDialog;
    Dialog dialog;
    switch (id) {
    case R.id.send:
        pDialog = new ProgressDialog(this);
        pDialog.setCancelable(true);
        pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        pDialog.setMessage(getText(R.string.send_msg));
        pDialog.setOnDismissListener(new OnDismissListener() {
            @Override
            public void onDismiss(final DialogInterface arg0) {
                removeDialog(R.id.send);
            }
        });
        pDialog.setOnCancelListener(new OnCancelListener() {

            @Override
            public void onCancel(final DialogInterface arg0) {
                submitHandler.cancel(true);
            }

        });
        dialog = pDialog;
        break;
    case R.id.thanks:
        builder = new AlertDialog.Builder(this);
        builder.setMessage(getText(R.string.thanks_message)).setCancelable(true)
                .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, final int id) {
                        dialog.dismiss();
                        finish();
                    }
                });
        dialog = builder.create();
        break;
    case R.id.feedback_fail:
        builder = new AlertDialog.Builder(this);
        builder.setMessage(getText(R.string.feedback_fail_message)).setCancelable(true)
                .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, final int id) {
                        dialog.dismiss();
                    }
                });
        dialog = builder.create();
        break;
    default:
        dialog = null;
    }
    return dialog;
}

From source file:com.sven.im.ui.SettingsFragment.java

void logout() {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);
    pd.setCanceledOnTouchOutside(false);
    pd.show();// www . j  a va  2s  .c o m

    BmobUser.logOut(getActivity());

    Tencent mTencent = Tencent.createInstance("1105318381", App.getInstance().getContext());
    mTencent.logout(getActivity());

    DemoHelper.getInstance().logout(false, new EMCallBack() {

        @Override
        public void onSuccess() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    pd.dismiss();
                    // ??
                    ((MainActivity) getActivity()).finish();
                    startActivity(new Intent(getActivity(), LoginActivity.class));
                }
            });
        }

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

        }

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

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

                }
            });
        }
    });
}

From source file:cn.ucai.SuperWechat.activity.SettingsFragment.java

void logout() {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);
    pd.setCanceledOnTouchOutside(false);
    pd.show();/*from  w  ww  .ja v a2 s .co  m*/
    DemoHXSDKHelper.getInstance().logout(true, new EMCallBack() {

        @Override
        public void onSuccess() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    SuperWeChatApplication.getInstance().getStringUserAvatarMap().clear();
                    SuperWeChatApplication.getInstance().getUserAvatars().clear();
                    SuperWeChatApplication.getInstance().getGroupList().clear();
                    SuperWeChatApplication.getInstance().setUserAvatar(null);
                    pd.dismiss();
                    // ??
                    ((MainActivity) getActivity()).finish();
                    startActivity(new Intent(getActivity(), LoginActivity.class));

                }
            });
        }

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

        }

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

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

                }
            });
        }
    });
}

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

void logout() {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);
    pd.setCanceledOnTouchOutside(false);
    pd.show();/*  w w  w .ja  v a2 s.c om*/
    TuApplication.getInstance().logout(new EMCallBack() {

        @Override
        public void onSuccess() {
            MyUmengCommunityLogin.getInstance().logout(getActivity(), new LoginListener() {
                @Override
                public void onStart() {
                    System.out.print("? start");
                }

                @Override
                public void onComplete(int i, CommUser commUser) {
                    System.out.print("?");
                    CommonUtils.logout();
                    CommConfig.getConfig().loginedUser = new CommUser();
                    Pushable var3 = PushSDKManager.getInstance().getCurrentSDK();
                    var3.disable();
                }
            });
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    pd.dismiss();
                    // ??
                    getActivity().finish();
                    startActivity(new Intent(getActivity(), LoginActivity.class));

                }
            });
        }

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

        }

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

        }
    });
}

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

void logout() {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st = getResources().getString(R.string.Are_logged_out);
    pd.setMessage(st);
    pd.setCanceledOnTouchOutside(false);
    pd.show();/*from   ww w .j  a  va2  s  .  co  m*/
    DemoHXSDKHelper.getInstance().logout(true, new EMCallBack() {

        @Override
        public void onSuccess() {
            getActivity().runOnUiThread(new Runnable() {
                public void run() {
                    SuperWeChatApplication.getInstance().setUa(null);
                    SuperWeChatApplication.getInstance().getUserContactList().clear();
                    SuperWeChatApplication.getInstance().getContactMap().clear();
                    SuperWeChatApplication.getInstance().getGaList().clear();
                    SuperWeChatApplication.getInstance().getGaMap().clear();
                    SuperWeChatApplication.getInstance().getMuaMap().clear();
                    pd.dismiss();
                    // ??
                    ((MainActivity) getActivity()).finish();
                    startActivity(new Intent(getActivity(), LoginActivity.class));

                }
            });
        }

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

        }

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

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

                }
            });
        }
    });
}