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.ccxt.whl.activity.LoginActivity.java

private void userinfo(String accessToken) {
    final ProgressDialog pd = new ProgressDialog(this);
    pd.setMessage("?...");
    pd.show();/*from w ww  .j av  a2 s .  c o  m*/

    mAuthorization.getUserInfo(accessToken, new UserInfoListener() {

        @Override
        public void onSuccess(FrontiaUser.FrontiaUserDetail result) {
            //if (null != mResultTextView) {
            Log.d("log useid===>" + result.getId());
            Log.d("log AccessToken===>" + result.getAccessToken());
            Log.d("log BaiduAccessToken===>" + result.getBaiduAccessToken());
            Log.d("log MediaUserId===>" + result.getMediaUserId());
            //Log.d("log MediaUserId===>"+result.get);

            String resultStr = "username:" + result.getName() + "\n" + "birthday:" + result.getBirthday() + "\n"
                    + "city:" + result.getCity() + "\n" + "province:" + result.getProvince() + "\n" + "sex:"
                    + result.getSex() + "\n" + "pic url:" + result.getHeadUrl() + "\n";
            Log.d("log userinfo===>" + resultStr);

            sex = "" + result.getSex();
            birthday = result.getBirthday();
            headurl = result.getHeadUrl();
            province = result.getProvince();
            city = result.getCity();

            RequestParams params = new RequestParams();
            params.add("name", name);
            params.add("access_token", access_token);
            params.add("sex", sex);
            params.add("birthday", birthday);
            params.add("headurl", headurl);
            params.add("province", province);
            params.add("city", city);
            params.add("meida_type", "sinaweibo");
            params.add("meida_uid", meida_uid);
            //id
            params.add("uid", uid);

            /*
             //Log.d("log",response);
                  try {
                     Map<String, Object> lm = JsonToMapList.getMap(response);
                       Map<String, Object> result = JsonToMapList.getMap(lm.get("result").toString());
                       String resultStr = "status:" + lm.get("status") + "\n"
                         + "message:" + lm.get("message") + "\n"
                         + "result:" + lm.get("result") + "\n"
                         + "uid:" + result.get("uid") + "\n"
                         + "umd5:" + result.get("umd5") + "\n"
                         + "is_res:" + result.get("is_res") + "\n";
                       Log.d("log",resultStr);
             } catch (Exception e) {
                // TODO: handle exception
             }
                         
                         
                 //String huanxin_username = MD5.MD5Hash(result.getName());
             //String huanxin_pwd = MD5.MD5Hash(result.getName());
             //s_reg_login(huanxin_username, huanxin_pwd);
             */

            HttpRestClient.get(Constant.S_LOGIN_URL, params, new BaseJsonHttpResponseHandler() {

                @Override
                public void onSuccess(int statusCode, Header[] headers, String rawJsonResponse,
                        Object response) {
                    // TODO Auto-generated method stub
                    Log.d("log" + rawJsonResponse);
                    //if(str != null && str.length()!= 0){//?   
                    //}
                    if (!LoginActivity.this.isFinishing())
                        pd.dismiss();

                    if (CommonUtils.isNullOrEmpty(rawJsonResponse)) {
                        Toast.makeText(getApplicationContext(), "?,?", 0)
                                .show();
                        return;
                    }
                    Map<String, Object> lm = JsonToMapList.getMap(rawJsonResponse);

                    if (CommonUtils.isNullOrEmpty(lm.get("result").toString())) {
                        //if(false){

                    } else {
                        Map<String, Object> result = JsonToMapList.getMap(lm.get("result").toString());
                        String resultStr = "status:" + lm.get("status") + "\n" + "message:" + lm.get("message")
                                + "\n" + "result:" + lm.get("result") + "\n" + "uid:" + result.get("uid") + "\n"
                                + "umd5:" + result.get("umd5") + "\n" + "is_res:" + result.get("is_res") + "\n"
                                + "headurl:" + result.get("headurl") + "\n" + "name:" + result.get("name")
                                + "\n" + "sex:" + result.get("sex") + "\n" + "age:" + result.get("age") + "\n"
                                + "province:" + result.get("province") + "\n" + "city:" + result.get("city")
                                + "\n" + "pwd:" + result.get("pwd") + "\n";
                        Log.d("log" + resultStr);
                        //???id nullsaveinfo Preference
                        //DemoApplication.getInstance().setUser(result.get("umd5").toString());
                        //System.out.println("========================"+result.get("umd5").toString());
                        /********/
                        PreferenceUtils.getInstance(getBaseContext())
                                .setSettingUserPic(result.get("headurl").toString());
                        PreferenceUtils.getInstance(getBaseContext())
                                .setSettingUserNickName(result.get("name").toString());
                        PreferenceUtils.getInstance(getBaseContext())
                                .setSettingUserSex(result.get("sex").toString());
                        PreferenceUtils.getInstance(getBaseContext())
                                .setSettingUserAge(result.get("age").toString());
                        PreferenceUtils.getInstance(getBaseContext()).setSettingUserArea(
                                result.get("province").toString() + " " + result.get("city").toString());
                        PreferenceUtils.getInstance(getBaseContext())
                                .setSettingUserZhiye(result.get("zhiye").toString());
                        PreferenceUtils.getInstance(getBaseContext())
                                .setSettingUserQianming(result.get("qianming").toString());

                        String huanxin_username = result.get("umd5").toString();
                        String huanxin_pwd = result.get("pwd").toString();
                        Log.d("log huanxin_username:" + huanxin_username + "|huanxin_pwd:" + huanxin_pwd
                                + "|token:" + access_token);
                        //???
                        if (result.get("is_res").toString().equals("yes")) {
                            login(huanxin_username, huanxin_pwd);
                        } else {
                            s_reg_login(huanxin_username, huanxin_pwd);
                        }

                    }

                }

                @Override
                public void onFailure(int statusCode, Header[] headers, Throwable throwable, String rawJsonData,
                        Object errorResponse) {
                    pd.dismiss();
                    Toast.makeText(getApplicationContext(), ",?", 0).show();
                    return;
                    // TODO Auto-generated method stub

                }

                @Override
                protected Object parseResponse(String rawJsonData, boolean isFailure) throws Throwable {
                    // TODO Auto-generated method stub
                    return null;
                }
            });

        }

        @Override
        public void onFailure(int errCode, String errMsg) {
            Log.d("log nihao ===>" + "errCode:" + errCode + ", errMsg:" + errMsg);
            sex = "";
            birthday = "";
            headurl = "";
            province = "";
            city = "";
            pd.dismiss();
            Toast.makeText(getApplicationContext(), "????", 0).show();
            return;
        }

    });
}

From source file:de.ub0r.android.callmeter.ui.prefs.Preferences.java

/**
 * Import data previously exported./*w  w  w .ja v a 2  s  .c o  m*/
 * 
 * @param context
 *            {@link Context}
 * @param uri
 *            {@link Uri}
 */
private void importData(final Context context, final Uri uri) {
    Log.d(TAG, "importData(ctx, " + uri + ")");
    final ProgressDialog d1 = new ProgressDialog(this);
    d1.setCancelable(true);
    d1.setMessage(this.getString(R.string.import_progr));
    d1.setIndeterminate(true);
    d1.show();

    new AsyncTask<Void, Void, String>() {
        @Override
        protected String doInBackground(final Void... params) {
            StringBuilder sb = new StringBuilder();
            try {
                final BufferedReader bufferedReader = // .
                        new BufferedReader(new InputStreamReader(// .
                                Preferences.this.getStream(Preferences.this.getContentResolver(), uri)),
                                BUFSIZE);
                String line = bufferedReader.readLine();
                while (line != null) {
                    sb.append(line);
                    sb.append("\n");
                    line = bufferedReader.readLine();
                }
            } catch (Exception e) {
                Log.e(TAG, "error in reading export: " + e.toString(), e);
                return null;
            }
            return sb.toString();
        }

        @Override
        protected void onPostExecute(final String result) {
            Log.d(TAG, "import:\n" + result);
            d1.dismiss();
            if (result == null || result.length() == 0) {
                Toast.makeText(Preferences.this, R.string.err_export_read, Toast.LENGTH_LONG).show();
                return;
            }
            String[] lines = result.split("\n");
            if (lines.length <= 2) {
                Toast.makeText(Preferences.this, R.string.err_export_read, Toast.LENGTH_LONG).show();
                return;
            }
            Builder builder = new Builder(Preferences.this);
            builder.setCancelable(true);
            builder.setTitle(R.string.import_rules_);
            builder.setMessage(Preferences.this.getString(R.string.import_rules_hint) + "\n"
                    + URLDecoder.decode(lines[1]));
            builder.setNegativeButton(android.R.string.cancel, null);
            builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
                @Override
                public void onClick(final DialogInterface dialog, final int which) {
                    d1.setCancelable(false);
                    d1.setIndeterminate(true);
                    d1.show();
                    new AsyncTask<Void, Void, Void>() {

                        @Override
                        protected Void doInBackground(final Void... params) {
                            DataProvider.importData(Preferences.this, result);
                            return null;
                        }

                        @Override
                        protected void onPostExecute(final Void result) {
                            de.ub0r.android.callmeter.ui.Plans.reloadList();
                            d1.dismiss();
                        }
                    } // .
                            .execute((Void) null);
                }
            });
            builder.show();
        }
    } // .
            .execute((Void) null);
}

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

/**
 * user???/* www. j  a  va2 s .com*/
 */
private 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 {
                //???
                EMContactManager.getInstance().addUserToBlackList(username, false);
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2, Toast.LENGTH_SHORT).show();
                        refresh();
                    }
                });
            } catch (EaseMobException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st3, Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    }).start();

}

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

private void cleanupFolders() {
    final ProgressDialog progressDialog = new ProgressDialog(getParentActivity());
    progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.setCancelable(false);
    progressDialog.show();//from  w ww  . j  a  v  a 2s .  c om
    Utilities.globalQueue.postRunnable(new Runnable() {
        @Override
        public void run() {
            boolean imagesCleared = false;
            for (int a = 0; a < 6; a++) {
                if (!clear[a]) {
                    continue;
                }
                int type = -1;
                int documentsMusicType = 0;
                if (a == 0) {
                    type = FileLoader.MEDIA_DIR_IMAGE;
                } else if (a == 1) {
                    type = FileLoader.MEDIA_DIR_VIDEO;
                } else if (a == 2) {
                    type = FileLoader.MEDIA_DIR_DOCUMENT;
                    documentsMusicType = 1;
                } else if (a == 3) {
                    type = FileLoader.MEDIA_DIR_DOCUMENT;
                    documentsMusicType = 2;
                } else if (a == 4) {
                    type = FileLoader.MEDIA_DIR_AUDIO;
                } else if (a == 5) {
                    type = FileLoader.MEDIA_DIR_CACHE;
                }
                if (type == -1) {
                    continue;
                }
                File file = FileLoader.getInstance().checkDirectory(type);
                if (file != null) {
                    try {
                        File[] array = file.listFiles();
                        if (array != null) {
                            for (int b = 0; b < array.length; b++) {
                                String name = array[b].getName().toLowerCase();
                                if (documentsMusicType == 1 || documentsMusicType == 2) {
                                    if (name.endsWith(".mp3") || name.endsWith(".m4a")) {
                                        if (documentsMusicType == 1) {
                                            continue;
                                        }
                                    } else if (documentsMusicType == 2) {
                                        continue;
                                    }
                                }
                                if (name.equals(".nomedia")) {
                                    continue;
                                }
                                if (array[b].isFile()) {
                                    array[b].delete();
                                }
                            }
                        }
                    } catch (Throwable e) {
                        FileLog.e("tmessages", e);
                    }
                }
                if (type == FileLoader.MEDIA_DIR_CACHE) {
                    cacheSize = getDirectorySize(
                            FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_CACHE),
                            documentsMusicType);
                    imagesCleared = true;
                } else if (type == FileLoader.MEDIA_DIR_AUDIO) {
                    audioSize = getDirectorySize(
                            FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_AUDIO),
                            documentsMusicType);
                } else if (type == FileLoader.MEDIA_DIR_DOCUMENT) {
                    if (documentsMusicType == 1) {
                        documentsSize = getDirectorySize(
                                FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_DOCUMENT),
                                documentsMusicType);
                    } else {
                        musicSize = getDirectorySize(
                                FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_DOCUMENT),
                                documentsMusicType);
                    }
                } else if (type == FileLoader.MEDIA_DIR_IMAGE) {
                    imagesCleared = true;
                    photoSize = getDirectorySize(
                            FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_IMAGE),
                            documentsMusicType);
                } else if (type == FileLoader.MEDIA_DIR_VIDEO) {
                    videoSize = getDirectorySize(
                            FileLoader.getInstance().checkDirectory(FileLoader.MEDIA_DIR_VIDEO),
                            documentsMusicType);
                }
            }
            final boolean imagesClearedFinal = imagesCleared;
            totalSize = cacheSize + videoSize + audioSize + photoSize + documentsSize + musicSize;
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public void run() {
                    if (imagesClearedFinal) {
                        ImageLoader.getInstance().clearMemory();
                    }
                    if (listAdapter != null) {
                        listAdapter.notifyDataSetChanged();
                    }
                    try {
                        progressDialog.dismiss();
                    } catch (Exception e) {
                        FileLog.e("tmessages", e);
                    }
                }
            });
        }
    });
}

From source file:de.ub0r.android.callmeter.ui.prefs.Preferences.java

/**
 * Export data./*from w ww  .jav a 2s . co m*/
 * 
 * @param descr
 *            description of the exported rule set
 * @param fn
 *            one of the predefined file names from {@link DataProvider}.
 */
private void exportData(final String descr, final String fn) {
    if (descr == null) {
        final EditText et = new EditText(this);
        Builder builder = new Builder(this);
        builder.setView(et);
        builder.setCancelable(true);
        builder.setTitle(R.string.export_rules_descr);
        builder.setNegativeButton(android.R.string.cancel, null);
        builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
            @Override
            public void onClick(final DialogInterface dialog, final int which) {
                Preferences.this.exportData(et.getText().toString(), fn);
            }
        });
        builder.show();
    } else {
        final ProgressDialog d = new ProgressDialog(this);
        d.setIndeterminate(true);
        d.setMessage(this.getString(R.string.export_progr));
        d.setCancelable(false);
        d.show();

        // run task in background
        final AsyncTask<Void, Void, String> task = // .
                new AsyncTask<Void, Void, String>() {
                    @Override
                    protected String doInBackground(final Void... params) {
                        if (fn.equals(DataProvider.EXPORT_RULESET_FILE)) {
                            return DataProvider.backupRuleSet(Preferences.this, descr);
                        } else if (fn.equals(DataProvider.EXPORT_LOGS_FILE)) {
                            return DataProvider.backupLogs(Preferences.this, descr);
                        } else if (fn.equals(DataProvider.EXPORT_NUMGROUPS_FILE)) {
                            return DataProvider.backupNumGroups(Preferences.this, descr);
                        } else if (fn.equals(DataProvider.EXPORT_HOURGROUPS_FILE)) {
                            return DataProvider.backupHourGroups(Preferences.this, descr);
                        }
                        return null;
                    }

                    @Override
                    protected void onPostExecute(final String result) {
                        Log.d(TAG, "export:\n" + result);
                        System.out.println("\n" + result);
                        d.dismiss();
                        if (result != null && result.length() > 0) {
                            Uri uri = null;
                            int resChooser = -1;
                            if (fn.equals(DataProvider.EXPORT_RULESET_FILE)) {
                                uri = DataProvider.EXPORT_RULESET_URI;
                                resChooser = R.string.export_rules_;
                            } else if (fn.equals(DataProvider.EXPORT_LOGS_FILE)) {
                                uri = DataProvider.EXPORT_LOGS_URI;
                                resChooser = R.string.export_logs_;
                            } else if (fn.equals(DataProvider.EXPORT_NUMGROUPS_FILE)) {
                                uri = DataProvider.EXPORT_NUMGROUPS_URI;
                                resChooser = R.string.export_numgroups_;
                            } else if (fn.equals(DataProvider.EXPORT_HOURGROUPS_FILE)) {
                                uri = DataProvider.EXPORT_HOURGROUPS_URI;
                                resChooser = R.string.export_hourgroups_;
                            }
                            final Intent intent = new Intent(Intent.ACTION_SEND);
                            intent.setType(DataProvider.EXPORT_MIMETYPE);
                            intent.putExtra(Intent.EXTRA_STREAM, uri);
                            intent.putExtra(Intent.EXTRA_SUBJECT, // .
                                    "Call Meter 3G export");
                            intent.addCategory(Intent.CATEGORY_DEFAULT);

                            try {
                                final File d = Environment.getExternalStorageDirectory();
                                final File f = new File(d, DataProvider.PACKAGE + File.separator + fn);
                                f.mkdirs();
                                if (f.exists()) {
                                    f.delete();
                                }
                                f.createNewFile();
                                FileWriter fw = new FileWriter(f);
                                fw.append(result);
                                fw.close();
                                // call an exporting app with the uri to the
                                // preferences
                                Preferences.this.startActivity(
                                        Intent.createChooser(intent, Preferences.this.getString(resChooser)));
                            } catch (IOException e) {
                                Log.e(TAG, "error writing export file", e);
                                Toast.makeText(Preferences.this, R.string.err_export_write, Toast.LENGTH_LONG)
                                        .show();
                            }
                        }
                    }
                };
        task.execute((Void) null);
    }
}

From source file:com.nttec.everychan.chans.fourchan.FourchanModule.java

private void addPasscodePreference(PreferenceGroup preferenceGroup) {
    final Context context = preferenceGroup.getContext();
    PreferenceScreen passScreen = preferenceGroup.getPreferenceManager().createPreferenceScreen(context);
    passScreen.setTitle("4chan pass");
    EditTextPreference passTokenPreference = new EditTextPreference(context);
    EditTextPreference passPINPreference = new EditTextPreference(context);
    Preference passLoginPreference = new Preference(context);
    Preference passClearPreference = new Preference(context);
    passTokenPreference.setTitle("Token");
    passTokenPreference.setDialogTitle("Token");
    passTokenPreference.setKey(getSharedKey(PREF_KEY_PASS_TOKEN));
    passTokenPreference.getEditText().setSingleLine();
    passTokenPreference.getEditText()/*from www .  j  a va 2 s  . c  o  m*/
            .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
    passPINPreference.setTitle("PIN");
    passPINPreference.setDialogTitle("PIN");
    passPINPreference.setKey(getSharedKey(PREF_KEY_PASS_PIN));
    passPINPreference.getEditText().setSingleLine();
    passPINPreference.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
    passLoginPreference.setTitle("Log In");
    passLoginPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (!useHttps())
                Toast.makeText(context, "Using HTTPS even if HTTP is selected", Toast.LENGTH_SHORT).show();
            final String token = preferences.getString(getSharedKey(PREF_KEY_PASS_TOKEN), "");
            final String pin = preferences.getString(getSharedKey(PREF_KEY_PASS_PIN), "");
            final String authUrl = "https://sys.4chan.org/auth"; //only https
            final CancellableTask passAuthTask = new CancellableTask.BaseCancellableTask();
            final ProgressDialog passAuthProgressDialog = new ProgressDialog(context);
            passAuthProgressDialog.setMessage("Logging in");
            passAuthProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    passAuthTask.cancel();
                }
            });
            passAuthProgressDialog.setCanceledOnTouchOutside(false);
            passAuthProgressDialog.show();
            Async.runAsync(new Runnable() {
                @Override
                public void run() {
                    try {
                        if (passAuthTask.isCancelled())
                            return;
                        setPasscodeCookie(null, true);
                        List<NameValuePair> pairs = new ArrayList<NameValuePair>();
                        pairs.add(new BasicNameValuePair("act", "do_login"));
                        pairs.add(new BasicNameValuePair("id", token));
                        pairs.add(new BasicNameValuePair("pin", pin));
                        HttpRequestModel request = HttpRequestModel.builder()
                                .setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).build();
                        String response = HttpStreamer.getInstance().getStringFromUrl(authUrl, request,
                                httpClient, null, passAuthTask, false);
                        if (passAuthTask.isCancelled())
                            return;
                        if (response.contains("Your device is now authorized")) {
                            String passId = null;
                            for (Cookie cookie : httpClient.getCookieStore().getCookies()) {
                                if (cookie.getName().equals("pass_id")) {
                                    String value = cookie.getValue();
                                    if (!value.equals("0")) {
                                        passId = value;
                                        break;
                                    }
                                }
                            }
                            if (passId == null) {
                                showToast("Could not get pass id");
                            } else {
                                setPasscodeCookie(passId, true);
                                showToast("Success! Your device is now authorized.");
                            }
                        } else if (response.contains("Your Token must be exactly 10 characters")) {
                            showToast("Incorrect token");
                        } else if (response.contains("You have left one or more fields blank")) {
                            showToast("You have left one or more fields blank");
                        } else if (response.contains("Incorrect Token or PIN")) {
                            showToast("Incorrect Token or PIN");
                        } else {
                            Matcher m = Pattern
                                    .compile("<strong style=\"color: red; font-size: larger;\">(.*?)</strong>")
                                    .matcher(response);
                            if (m.find()) {
                                showToast(m.group(1));
                            } else {
                                showWebView(response);
                            }
                        }
                    } catch (Exception e) {
                        showToast(e.getMessage() == null ? resources.getString(R.string.error_unknown)
                                : e.getMessage());
                    } finally {
                        passAuthProgressDialog.dismiss();
                    }
                }

                private void showToast(final String message) {
                    if (context instanceof Activity) {
                        ((Activity) context).runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                Toast.makeText(context, message, Toast.LENGTH_LONG).show();
                            }
                        });
                    }
                }

                private void showWebView(final String html) {
                    if (context instanceof Activity) {
                        ((Activity) context).runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                WebView webView = new WebView(context);
                                webView.getSettings().setSupportZoom(true);
                                webView.loadData(html, "text/html", null);
                                new AlertDialog.Builder(context).setView(webView)
                                        .setNeutralButton(android.R.string.ok, null).show();
                            }
                        });
                    }
                }
            });
            return true;
        }
    });
    passClearPreference.setTitle("Reset pass cookie");
    passClearPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            setPasscodeCookie(null, true);
            Toast.makeText(context, "Cookie is reset", Toast.LENGTH_LONG).show();
            return true;
        }
    });
    passScreen.addPreference(passTokenPreference);
    passScreen.addPreference(passPINPreference);
    passScreen.addPreference(passLoginPreference);
    passScreen.addPreference(passClearPreference);
    preferenceGroup.addPreference(passScreen);
}

From source file:com.sakisds.icymonitor.activities.AddServerActivity.java

@SuppressWarnings("ConstantConditions")
@Override//w w w  . jav  a2s .c om
public void onClick(View view) {
    // Check if name is empty
    if (mEditText_name.getText().toString().equals("")) {
        mEditText_name.setError(getResources().getString(R.string.error_empty_name));
        mEditText_name.requestFocus();
    } else if (mEditText_port.getText().toString().equals("")) {
        mEditText_port.setError(getString(R.string.error_empty_port));
        mEditText_port.requestFocus();
    } else if (mEditText_address.getText().toString().equals("")) {
        mEditText_address.setError(getString(R.string.error_empty_address));
        mEditText_address.requestFocus();
    } else { // If it's not
        // Validate URL
        String url = mEditText_address.getText().toString();
        // Add http:// if needed
        if (!url.substring(0, 7).equals("http://")) {
            url = "http://" + url;
        }
        url += ":" + mEditText_port.getText().toString();
        url = url.replace(" ", "");
        if (!URLUtil.isValidUrl(url)) { // If invalid
            mEditText_address.setError(getResources().getString(R.string.error_invalid_address));
            mEditText_address.requestFocus();
        } else { // If URL is valid
            // Create a dialog
            final ProgressDialog progress = ProgressDialog.show(this, "",
                    getResources().getString(R.string.connecting), false);

            // Store actual URL
            final String actualURL = url;

            // Check if auth is enabled
            mClient.get(url + "/authEnabled", null, new JsonHttpResponseHandler() {
                @Override
                public void onSuccess(JSONObject response) {
                    try {
                        if (response.getBoolean("AuthEnabled")) {
                            progress.setMessage(getString(R.string.check_computer));
                        }
                    } catch (JSONException ignored) {
                    } // If there are issues they will be dealt with later
                }
            });

            // Register
            RequestParams params = new RequestParams();
            params.put("name", android.os.Build.MODEL);
            params.put("id", String.valueOf(mSettings.getLong("device_id", -2)));
            params.put("gcm", mGCMID);
            params.put("ask", "true");

            JsonHttpResponseHandler handler = new JsonHttpResponseHandler() {
                @Override
                public void onSuccess(JSONObject response) {
                    try {
                        // Get string
                        String version = response.getString("Version");

                        // Parse response
                        if (version.equals(ConnectionActivity.ACCEPTED_SERVER_VERSION)) {
                            String regStatus = response.getString("Status");

                            if (regStatus.equals("ALLOWED")) {
                                saveServer(actualURL);
                                progress.dismiss();
                                mResponseReady = true;
                            } else if (regStatus.equals("DENIED")) {
                                mEditText_address.setError(getResources().getString(R.string.error_rejected));
                                mEditText_address.requestFocus();
                                progress.dismiss();
                                mResponseReady = true;
                            }
                        } else {
                            mEditText_address
                                    .setError(getResources().getString(R.string.error_outdated_server));
                            mEditText_address.requestFocus();
                            progress.dismiss();
                            mResponseReady = true;
                        }
                    } catch (JSONException e) {
                        mEditText_address.setError(getResources().getString(R.string.error_invalid_response));
                        mEditText_address.requestFocus();
                        progress.dismiss();
                        mResponseReady = true;
                    }
                }

                @Override
                public void onFailure(Throwable e, JSONObject errorResponse) {
                    progress.dismiss();
                    mEditText_address.setError(getResources().getString(R.string.error_could_not_reach_host));
                    mEditText_address.requestFocus();
                    mResponseReady = true;
                }
            };

            mClient.get(url + "/register", params, handler);
            params.remove("ask");

            WaitingTask task = new WaitingTask();

            task.mUrl = url + "/register";
            task.mParams = params;
            task.mHandler = handler;

            task.execute();
        }
    }
}

From source file:de.baumann.hhsmoodle.helper.helper_main.java

public static void onClose(final Activity activity) {
    PreferenceManager.setDefaultValues(activity, R.xml.user_settings, false);
    sharedPref = PreferenceManager.getDefaultSharedPreferences(activity);
    final ProgressDialog progressDialog;

    if (sharedPref.getBoolean("backup_aut", false)) {

        try {//  w  w w  .ja  v  a 2s  .  c om
            helper_security.encryptBackup(activity, "/bookmarks_DB_v01.db");
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            helper_security.encryptBackup(activity, "/courses_DB_v01.db");
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            helper_security.encryptBackup(activity, "/notes_DB_v01.db");
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            helper_security.encryptBackup(activity, "/random_DB_v01.db");
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            helper_security.encryptBackup(activity, "/subject_DB_v01.db");
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            helper_security.encryptBackup(activity, "/schedule_DB_v01.db");
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            helper_security.encryptBackup(activity, "/todo_DB_v01.db");
        } catch (Exception e) {
            e.printStackTrace();
        }

        progressDialog = new ProgressDialog(activity);
        progressDialog.setMessage(activity.getString(R.string.app_close));
        progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progressDialog.show();

        new Handler().postDelayed(new Runnable() {
            public void run() {
                sharedPref.edit().putString("loadURL", "").apply();
                helper_security.encryptDatabases(activity);
                if (progressDialog.isShowing()) {
                    progressDialog.cancel();
                }
                activity.finishAffinity();
            }
        }, 1500);

    } else {
        sharedPref.edit().putString("loadURL", "").apply();
        helper_security.encryptDatabases(activity);
        activity.finishAffinity();
    }
}

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

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

            progressShow = true;/*from w w w. j av a 2s.c o m*/
            final ProgressDialog pd = new ProgressDialog(LoginActivity.this);
            pd.setCanceledOnTouchOutside(false);
            pd.setOnCancelListener(new OnCancelListener() {

                @Override
                public void onCancel(DialogInterface dialog) {
                    progressShow = false;
                }
            });
            pd.setMessage(getString(R.string.Is_landing));
            pd.show();

            final long start = System.currentTimeMillis();
            // sdk??
            EMChatManager.getInstance().login(currentUsername, currentPassword, new EMCallBack() {

                @Override
                public void onSuccess() {

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

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

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

                @Override
                public void onError(final int code, final String message) {
                    if (!progressShow) {
                        return;
                    }
                    runOnUiThread(new Runnable() {
                        public void run() {
                            pd.dismiss();
                            Toast.makeText(getApplicationContext(), getString(R.string.Login_failed) + message,
                                    Toast.LENGTH_SHORT).show();
                        }
                    });
                }
            });

        }
    }
}

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

/**
 * user???//ww w . ja v  a  2  s  . co  m
 */
private void moveToBlacklist(final String username) {
    final ProgressDialog pd = new ProgressDialog(getActivity());
    String st1 = getResources().getString(cn.ucai.superwechat.R.string.Is_moved_into_blacklist);
    final String st2 = getResources().getString(cn.ucai.superwechat.R.string.Move_into_blacklist_success);
    final String st3 = getResources().getString(cn.ucai.superwechat.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);
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st2, Toast.LENGTH_SHORT).show();
                        refresh();
                    }
                });
            } catch (EaseMobException e) {
                e.printStackTrace();
                getActivity().runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(getActivity(), st3, Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    }).start();

}