Example usage for android.app ProgressDialog show

List of usage examples for android.app ProgressDialog show

Introduction

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

Prototype

public void show() 

Source Link

Document

Start the dialog and display it on screen.

Usage

From source file:com.wenwen.chatuidemo.activity.AddContactActivity.java

/**
 * contact/*from   ww  w.j a  v a2s.c  om*/
 * 
 * @param v
 */
public void searchContact(View v) {
    final String name = editText.getText().toString();
    String saveText = searchBtn.getText().toString();

    if (getString(R.string.button_search).equals(saveText)) {
        toAddUsername = name;
        if (TextUtils.isEmpty(name)) {
            startActivity(new Intent(this, AlertDialog.class).putExtra("msg", "??"));
            return;
        }
        final ProgressDialog pd = new ProgressDialog(AddContactActivity.this);
        pd.setMessage("...");
        RequestParams params = new RequestParams();
        params.put("data", editText.getText().toString().trim());
        params.put("flag", "1");
        HttpClientRequest.post(Urls.FINDUSER, params, 3000, new AsyncHttpResponseHandler() {
            @Override
            public void onStart() {
                // TODO Auto-generated method stub
                super.onStart();
                pd.show();
            }

            @Override
            public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
                // TODO Auto-generated method stub
                try {
                    String res = new String(arg2);
                    DebugLog.i(TAG, "" + res);
                    JSONObject result = new JSONObject(res);
                    switch (Integer.valueOf(result.getString("ret"))) {
                    case -1:
                        Toast.makeText(AddContactActivity.this, "?", Toast.LENGTH_SHORT).show();
                        break;
                    case 1:
                        searchedUserLayout.setVisibility(View.VISIBLE);
                        nameText.setText(toAddUsername);
                        nameText.setText(result.getString("account_name"));
                        myUser = new MyUser();
                        myUser.setAccount_id(result.getString("account_id"));
                        myUser.setAccount_image(result.getString("account_image"));
                        myUser.setAccount_name(result.getString("account_name"));
                        myUser.setAccount_username(result.getString("account_username"));
                        break;
                    case 0:
                        Toast.makeText(AddContactActivity.this, "", Toast.LENGTH_SHORT).show();
                        break;
                    }
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            }

            @Override
            public void onFinish() {
                // TODO Auto-generated method stub
                super.onFinish();
                pd.dismiss();
            }

            @Override
            public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
                // TODO Auto-generated method stub

            }
        });
    }
}

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

/**
 * ??/*w w w.  j a va2 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.slp.rss_api.activity.EditFeedActivity.java

public void onClickOk(View view) {
    // only in insert mode

    final String name = mNameEditText.getText().toString().trim();
    final String urlOrSearch = mUrlEditText.getText().toString().trim();
    if (urlOrSearch.isEmpty()) {
        Toast.makeText(this, R.string.error_feed_error, Toast.LENGTH_SHORT).show();
    }/*from ww  w.j a  va  2  s .c  o  m*/

    if (!urlOrSearch.contains(".") || !urlOrSearch.contains("/") || urlOrSearch.contains(" ")) {
        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 LoaderManager.LoaderCallbacks<ArrayList<HashMap<String, String>>>() {

                    @Override
                    public Loader<ArrayList<HashMap<String, String>>> onCreateLoader(int id, Bundle args) {
                        String encodedSearchText = urlOrSearch;
                        try {
                            encodedSearchText = URLEncoder.encode(urlOrSearch, Constants.UTF8);
                        } catch (UnsupportedEncodingException ignored) {
                        }

                        return new GetFeedSearchResultsLoader(EditFeedActivity.this, encodedSearchText);
                    }

                    @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) {
                                    FeedDataContentProvider.addFeed(EditFeedActivity.this,
                                            data.get(which).get(FEED_SEARCH_URL),
                                            name.isEmpty() ? data.get(which).get(FEED_SEARCH_TITLE) : name,
                                            mRetrieveFulltextCb.isChecked());

                                    setResult(RESULT_OK);
                                    finish();
                                }
                            });
                            builder.show();
                        }
                    }

                    @Override
                    public void onLoaderReset(Loader<ArrayList<HashMap<String, String>>> loader) {
                    }
                });
    } else {
        FeedDataContentProvider.addFeed(EditFeedActivity.this, urlOrSearch, name,
                mRetrieveFulltextCb.isChecked());

        setResult(RESULT_OK);
        finish();
    }
}

From source file:com.wenwen.chatuidemo.activity.RegisterActivity.java

/**
 * /*from w  w  w.  j  a v a 2  s.c om*/
 * 
 * @param view
 */
public void register(View view) {
    final String username = userNameEditText.getText().toString().trim();
    final String pwd = passwordEditText.getText().toString().trim();
    String confirm_pwd = confirmPwdEditText.getText().toString().trim();
    if (TextUtils.isEmpty(username)) {
        Toast.makeText(this, "????", Toast.LENGTH_SHORT).show();
        userNameEditText.requestFocus();
        return;
    } else if (TextUtils.isEmpty(pwd)) {
        Toast.makeText(this, "???", Toast.LENGTH_SHORT).show();
        passwordEditText.requestFocus();
        return;
    } else if (TextUtils.isEmpty(confirm_pwd)) {
        Toast.makeText(this, "???", Toast.LENGTH_SHORT).show();
        confirmPwdEditText.requestFocus();
        return;
    } else if (!pwd.equals(confirm_pwd)) {
        Toast.makeText(this, "????", Toast.LENGTH_SHORT).show();
        return;
    }
    if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(pwd)) {
        final ProgressDialog pd = new ProgressDialog(this);
        pd.setMessage("...");
        RequestParams params = new RequestParams();
        params.put("username", userNameEditText.getText().toString().trim());
        params.put("password", MD5.md5("ys_" + passwordEditText.getText().toString().trim()).toUpperCase());
        params.put("type", "1");
        HttpClientRequest.post(Urls.REG, params, 3000, new AsyncHttpResponseHandler() {
            @Override
            public void onStart() {
                // TODO Auto-generated method stub
                super.onStart();
                pd.show();
            }

            @Override
            public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
                // TODO Auto-generated method stub
                try {
                    String res = new String(arg2);
                    DebugLog.i("res", res);
                    JSONObject result = new JSONObject(res);
                    switch (Integer.valueOf(result.getString("ret"))) {
                    case -1:
                        Toast.makeText(RegisterActivity.this, "?", Toast.LENGTH_SHORT).show();
                        break;
                    case 1:
                        Toast.makeText(RegisterActivity.this, "?", Toast.LENGTH_SHORT).show();
                        DemoApplication.getInstance().setUserName(userNameEditText.getText().toString().trim());
                        DemoApplication.getInstance().setUserUid(result.getString("uid"));
                        Intent intent = new Intent(RegisterActivity.this, PersonalData.class);
                        startActivity(intent);
                        finish();
                        break;
                    case 0:
                    case -2:
                    case -9:
                        Toast.makeText(RegisterActivity.this, "", Toast.LENGTH_SHORT).show();
                        break;
                    default:
                        break;
                    }
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }

            @Override
            public void onFinish() {
                // TODO Auto-generated method stub
                super.onFinish();
                pd.dismiss();
            }

            @Override
            public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {

            }
        });

    }
}

From source file:net.gerosyab.dailylog.activity.MainActivity.java

private void exportCategory(final long id) {

    //?? ? ?? csv  
    //? ?? ?? /*from  w  w  w.  j av  a  2s.c  om*/
    // ? ?  ? ? 
    Category category = categories.get((int) id);

    ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progressDialog.setTitle("Exporting data [" + category.getName() + "]");
    progressDialog.show();

    String filename = category.getName() + "" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())
            + ".data";
    FileOutputStream outputStream = null;
    File resultFilePath = null;
    File resultFile = null;
    CSVWriter cw = null;

    try {
        resultFile = new File(context.getCacheDir(), filename);

        outputStream = new FileOutputStream(resultFile.getAbsolutePath());
        //            cw = new CSVWriter(new OutputStreamWriter(outputStream, "UTF-8"),'\t', '"');
        cw = new CSVWriter(new OutputStreamWriter(outputStream, "UTF-8"), ',', '"');

        // Export Data
        String[] metaDataStr = { "Version:" + AppDatabase.VERSION, "Name:" + category.getName(),
                "Unit:" + category.getUnit(), "Type:" + category.getRecordType(),
                "DefaultValue:" + category.getDefaultValue(),
                "Columns:date(yyyy-MM-dd 24HH:mm:ss)/value(boolean|numeric|string)" };
        cw.writeNext(metaDataStr);

        List<Record> records = category.getRecordsOrderByDateAscending(realm);
        for (Record record : records) {
            String value = null;
            if (category.getRecordType() == StaticData.RECORD_TYPE_BOOLEAN) {
                value = "true";
            } else if (category.getRecordType() == StaticData.RECORD_TYPE_NUMBER) {
                value = "" + record.getNumber();
            } else if (category.getRecordType() == StaticData.RECORD_TYPE_MEMO) {
                value = record.getString();
            }
            String[] s = { record.getDateString(StaticData.fmtForBackup), value };
            cw.writeNext(s);
        }

        cw.close();
        outputStream.close();

        progressDialog.dismiss();

        Uri fileUri = FileProvider.getUriForFile(context, "net.gerosyab.dailylog.fileprovider", resultFile);

        Intent shareIntent = new Intent();
        shareIntent.setAction(Intent.ACTION_SEND);
        shareIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
        shareIntent.setType("text/plain");

        startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to)));

    } catch (UnsupportedEncodingException e) {
        Log.e("DailyLog", e.getMessage());
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        Log.e("DailyLog", e.getMessage());
        e.printStackTrace();
    } catch (Exception e) {
        Log.e("DailyLog", e.getMessage());
        e.printStackTrace();
    } finally {
        progressDialog.dismiss();
    }
}

From source file:com.imalu.alyou.activity.LoginActivity.java

/**
 * /*from  w  ww  . j  a  v a2  s.c o m*/
 * 
 * @param view
 */
public void login(View view) {
    if (!CommonUtils.isNetWorkConnected(this)) {
        Toast.makeText(this, R.string.network_isnot_available, Toast.LENGTH_SHORT).show();
        return;
    }

    final String username = usernameEditText.getText().toString();
    final String password = passwordEditText.getText().toString();
    //AlUApplication.currentUserNick = usernameEditText.getText().toString();

    if (!TextUtils.isEmpty(username) && !TextUtils.isEmpty(password)) {

        progressShow = true;
        final ProgressDialog pd = new ProgressDialog(LoginActivity.this);
        pd.setCanceledOnTouchOutside(false);
        pd.setOnCancelListener(new OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
                progressShow = false;
            }
        });
        pd.setMessage("...");
        pd.show();

        LoginRequest loginReq = new LoginRequest();
        loginReq.setUsername(username);
        loginReq.setPassword(password);

        NetManager.execute(NetManager.LOGIN_REQUEST_OPERATION, loginReq, new JsonHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, JSONObject response) {

                try {

                    pd.dismiss();
                    Log.e("login_check", " response:" + response.toString());

                    UserInfo userInfo = new UserInfo();
                    userInfo.setJsonObject(response);

                    AlUApplication.getMyInfo().setPhoneNum(username);
                    AlUApplication.getMyInfo().setPassword(password);
                    AlUApplication.getMyInfo().setHxname(userInfo.getHXName());
                    AlUApplication.getMyInfo().setId(userInfo.getID());
                    AlUApplication.getMyInfo().setUsername(userInfo.getUserName());
                    AlUApplication.getMyInfo().setKey(userInfo.getKey());
                    AlUApplication.getMyInfo().setJifen(userInfo.getJifen());
                    AlUApplication.getMyInfo().setAge(userInfo.getAge());
                    AlUApplication.getMyInfo().setLocus(userInfo.getLocus());
                    AlUApplication.getMyInfo().setRealname(userInfo.getRealName());
                    AlUApplication.getMyInfo().setSex(userInfo.getSex());
                    AlUApplication.getMyInfo().setSocietykey(userInfo.getSocietyKey());
                    AlUApplication.getMyInfo().setJiarugonghuikey(userInfo.getJiaruGonghuiKey());
                    AlUApplication.getMyInfo().setSocietyName(userInfo.getSocietyName());

                    PersonalInfoResponse personal = new PersonalInfoResponse();
                    personal.setJsonObject(response);
                    AlUApplication.getUserfans().setId(personal.getId());
                    AlUApplication.getUserfans().setJifen(personal.getJifen());
                    AlUApplication.getUserfans().setUserName(personal.getUserName());
                    AlUApplication.getUserfans().setSocietyName(personal.getSocietyName());

                    // ?????
                    AlUApplication.getInstance().setUserName(username);
                    AlUApplication.getInstance().setPassword(password);

                    User user = new User();
                    user.setId((long) userInfo.getID());
                    user.setUsername(username);
                    user.setPassword(password);
                    user.setChatuser(userInfo.getHXName());
                    saveUserToDB(user);

                    /*
                    runOnUiThread(new Runnable() {
                       public void run() {
                          pd.setMessage("...");
                       }
                    });
                    */

                    EMChatManager.getInstance().login(userInfo.getHXName(), userInfo.getHXPwd(),
                            new EMCallBack() {

                                @Override
                                public void onSuccess() {
                                    EMChatManager.getInstance().loadAllConversations();
                                }

                                @Override
                                public void onProgress(int progress, String status) {
                                    // TODO Auto-generated method stub
                                }

                                @Override
                                public void onError(int code, String message) {
                                    // TODO Auto-generated method stub
                                }
                            });

                    // ** ?logout??
                    // ** manually load all local groups and
                    // conversations in case we are auto login
                    //EMGroupManager.getInstance().loadAllGroups();

                    // demo??????username??
                    /*List<String> usernames = EMContactManager.getInstance().getContactUserNames();
                    EMLog.d("roster", "contacts size: " + usernames.size());
                            
                    for (String username : usernames) {
                       User user = new User();
                       user.setUsername(username);
                       setUserHearder(username, user);
                       userlist.put(username, user);
                    }*/
                    /*Map<String, User> userlist = new HashMap<String, User>();
                    // user""
                    User newFriends = new User();
                    newFriends.setUsername(Constant.NEW_FRIENDS_USERNAME);
                    newFriends.setNick("");
                    newFriends.setHeader("");
                    userlist.put(Constant.NEW_FRIENDS_USERNAME, newFriends);
                    // "?"
                    User groupUser = new User();
                    groupUser.setUsername(Constant.GROUP_USERNAME);
                    groupUser.setNick("?");
                    groupUser.setHeader("");
                    userlist.put(Constant.GROUP_USERNAME, groupUser);*/

                    // 
                    //AlUApplication.getInstance().setContactList(userlist);
                    // db
                    //UserDao dao = new UserDao(LoginActivity.this);
                    //List<User> users = new ArrayList<User>(userlist.values());
                    //dao.saveContactList(users);

                    // ??(??groupidgroupname????members),sdkdb
                    //EMGroupManager.getInstance().getGroupsFromServer();*/
                } catch (Exception e) {
                    e.printStackTrace();
                }
                //?nickname ios?nick
                //boolean updatenick = EMChatManager.getInstance().updateCurrentUserNick(AlUApplication.currentUserNick);
                //if (!updatenick) {
                //   EMLog.e("LoginActivity", "update current user nick fail");
                //}

                //if (!LoginActivity.this.isFinishing())
                //pd.dismiss();
                // ?
                startActivity(new Intent(LoginActivity.this, MainActivity.class));
                finish();
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, final String responseString,
                    Throwable throwable) {
                if (!progressShow) {
                    return;
                }
                pd.dismiss();
                runOnUiThread(new Runnable() {
                    public void run() {
                        //pd.dismiss();
                        //Toast.makeText(getApplicationContext(), ": " + responseString, 0).show();

                    }
                });
            }
        });
    }
}

From source file:net.fred.feedex.activity.EditFeedActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        finish();// w ww. jav a2  s .c om
        return true;
    case R.id.menu_validate: // only in insert mode
        final String name = mNameEditText.getText().toString().trim();
        final String urlOrSearch = mUrlEditText.getText().toString().trim();
        if (urlOrSearch.isEmpty()) {
            UiUtils.showMessage(EditFeedActivity.this, R.string.error_feed_error);
        }

        if (!urlOrSearch.contains(".") || !urlOrSearch.contains("/") || urlOrSearch.contains(" ")) {
            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 LoaderManager.LoaderCallbacks<ArrayList<HashMap<String, String>>>() {

                        @Override
                        public Loader<ArrayList<HashMap<String, String>>> onCreateLoader(int id, Bundle args) {
                            String encodedSearchText = urlOrSearch;
                            try {
                                encodedSearchText = URLEncoder.encode(urlOrSearch, Constants.UTF8);
                            } catch (UnsupportedEncodingException ignored) {
                            }

                            return new GetFeedSearchResultsLoader(EditFeedActivity.this, encodedSearchText);
                        }

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

                            if (data == null) {
                                UiUtils.showMessage(EditFeedActivity.this, R.string.error);
                            } else if (data.isEmpty()) {
                                UiUtils.showMessage(EditFeedActivity.this, R.string.no_result);
                            } 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) {
                                        FeedDataContentProvider.addFeed(EditFeedActivity.this,
                                                data.get(which).get(FEED_SEARCH_URL),
                                                name.isEmpty() ? data.get(which).get(FEED_SEARCH_TITLE) : name,
                                                mRetrieveFulltextCb.isChecked());

                                        setResult(RESULT_OK);
                                        finish();
                                    }
                                });
                                builder.show();
                            }
                        }

                        @Override
                        public void onLoaderReset(Loader<ArrayList<HashMap<String, String>>> loader) {
                        }
                    });
        } else {
            FeedDataContentProvider.addFeed(EditFeedActivity.this, urlOrSearch, name,
                    mRetrieveFulltextCb.isChecked());

            setResult(RESULT_OK);
            finish();
        }
        return true;
    case R.id.menu_add_filter: {
        final View dialogView = getLayoutInflater().inflate(R.layout.dialog_filter_edit, null);

        new AlertDialog.Builder(this) //
                .setTitle(R.string.filter_add_title) //
                .setView(dialogView) //
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        String filterText = ((EditText) dialogView.findViewById(R.id.filterText)).getText()
                                .toString();
                        if (filterText.length() != 0) {
                            String feedId = getIntent().getData().getLastPathSegment();

                            ContentValues values = new ContentValues();
                            values.put(FilterColumns.FILTER_TEXT, filterText);
                            values.put(FilterColumns.IS_REGEX,
                                    ((CheckBox) dialogView.findViewById(R.id.regexCheckBox)).isChecked());
                            values.put(FilterColumns.IS_APPLIED_TO_TITLE,
                                    ((RadioButton) dialogView.findViewById(R.id.applyTitleRadio)).isChecked());
                            values.put(FilterColumns.IS_ACCEPT_RULE,
                                    ((RadioButton) dialogView.findViewById(R.id.acceptRadio)).isChecked());

                            ContentResolver cr = getContentResolver();
                            cr.insert(FilterColumns.FILTERS_FOR_FEED_CONTENT_URI(feedId), values);
                        }
                    }
                }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                    }
                }).show();
        return true;
    }
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.wenwen.chatuidemo.activity.AddContactActivity.java

/**
 * contact/*  w w  w.ja  v  a2 s .  co m*/
 * 
 * @param view
 */
public void addContact(View view) {
    if (DemoApplication.getInstance().getUserName().equals(nameText.getText().toString())) {
        startActivity(new Intent(this, AlertDialog.class).putExtra("msg", "?"));
        return;
    }
    final ProgressDialog pd = new ProgressDialog(AddContactActivity.this);
    pd.setMessage("...");
    RequestParams params = new RequestParams();
    DebugLog.i(TAG, "uid" + DemoApplication.getInstance().getUserUid());
    params.put("fromuid", DemoApplication.getInstance().getUserUid());
    params.put("touid", myUser.getAccount_id());
    params.put("flag", "1");
    HttpClientRequest.post(Urls.FRIENDSSET, params, 3000, new AsyncHttpResponseHandler() {
        @Override
        public void onStart() {
            // TODO Auto-generated method stub
            super.onStart();
            pd.show();
        }

        @Override
        public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
            // TODO Auto-generated method stub
            try {
                String res = new String(arg2);
                DebugLog.i(TAG, "" + res);
                JSONObject result = new JSONObject(res);
                switch (Integer.valueOf(result.getString("ret"))) {
                case 0:
                    Toast.makeText(AddContactActivity.this, "", Toast.LENGTH_SHORT).show();
                    break;
                case 1:
                    Toast.makeText(AddContactActivity.this, "?", Toast.LENGTH_SHORT).show();
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("myuser", myUser);
                    Intent data = new Intent();
                    data.putExtras(bundle);
                    setResult(Activity.RESULT_OK, data); // ???
                    finish();
                    break;
                case -2:
                    Toast.makeText(AddContactActivity.this, "??", Toast.LENGTH_SHORT).show();
                    break;
                default:
                    break;

                }
            } catch (NumberFormatException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }

        @Override
        public void onFinish() {
            // TODO Auto-generated method stub
            super.onFinish();
            pd.dismiss();
        }

        @Override
        public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
            // TODO Auto-generated method stub

        }
    });
}

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

private void userinfo(String accessToken) {
    final ProgressDialog pd = new ProgressDialog(this);
    pd.setMessage("?...");
    pd.show();

    mAuthorization.getUserInfo(accessToken, new UserInfoListener() {

        @Override//  www .  j a  v a2  s.co m
        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: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  av  a 2 s.  co  m*/
                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();
}