Search in sources :

Example 1 with RequestParams

use of com.juns.health.net.loopj.android.http.RequestParams in project wechat by motianhuo.

the class AddGroupChatActivity method addServieGroup.

private void addServieGroup(final String groupId, final String groupName, String manber, String owner_id) {
    RequestParams params = new RequestParams();
    params.put("group_id", groupId);
    params.put("group_name", groupName);
    params.put("owner_id", owner_id);
    params.put("members", manber);
    params.put("description", "");
    params.put("image_path", "");
    netClient.post(Constants.newGroupURL, params, new BaseJsonRes() {

        @Override
        public void onMySuccess(String data) {
            Intent intent = new Intent(AddGroupChatActivity.this, ChatActivity.class);
            intent.putExtra(Constants.NAME, groupName);
            intent.putExtra(Constants.TYPE, ChatActivity.CHATTYPE_GROUP);
            intent.putExtra(Constants.GROUP_ID, groupId);
            startActivity(intent);
            getLoadingDialog("正在创建群聊...").dismiss();
            finish();
        }

        @Override
        public void onMyFailure() {
        }
    });
}
Also used : ChatActivity(com.juns.wechat.chat.ChatActivity) Intent(android.content.Intent) RequestParams(com.juns.health.net.loopj.android.http.RequestParams) BaseJsonRes(com.juns.wechat.net.BaseJsonRes)

Example 2 with RequestParams

use of com.juns.health.net.loopj.android.http.RequestParams in project wechat by motianhuo.

the class EditUserNameActivity method setUserMsg.

private void setUserMsg() {
    String telphone = Utils.getValue(EditUserNameActivity.this, Constants.NAME);
    String name = edit_name.getText().toString();
    if (TextUtils.isEmpty(name)) {
        Utils.showLongToast(EditUserNameActivity.this, "请填写您的昵称! ");
        return;
    }
    RequestParams params = new RequestParams();
    params.put("username", name);
    params.put("telphone", telphone);
    getLoadingDialog("正在加载...  ").show();
    netClient.post(Constants.UpdateInfoURL, params, new BaseJsonRes() {

        @Override
        public void onMySuccess(String data) {
            Utils.putValue(EditUserNameActivity.this, Constants.UserInfo, data);
            getLoadingDialog("正在加载").dismiss();
            Intent intent = new Intent(EditUserNameActivity.this, MainActivity.class);
            startActivity(intent);
            overridePendingTransition(R.anim.push_up_in, R.anim.push_up_out);
            finish();
        }

        @Override
        public void onMyFailure() {
            getLoadingDialog("正在登录").dismiss();
        }
    });
}
Also used : Intent(android.content.Intent) MainActivity(com.juns.wechat.MainActivity) RequestParams(com.juns.health.net.loopj.android.http.RequestParams) BaseJsonRes(com.juns.wechat.net.BaseJsonRes)

Example 3 with RequestParams

use of com.juns.health.net.loopj.android.http.RequestParams in project wechat by motianhuo.

the class LoginActivity method getLogin.

private void getLogin(final String userName, final String password) {
    if (!TextUtils.isEmpty(userName) && !TextUtils.isEmpty(password)) {
        RequestParams params = new RequestParams();
        params.put("username", userName);
        params.put("password", DES.md5Pwd(password));
        getLoadingDialog("正在登录...  ").show();
        netClient.post(Constants.Login_URL, params, new BaseJsonRes() {

            @Override
            public void onMySuccess(String data) {
                Utils.putValue(LoginActivity.this, Constants.UserInfo, data);
                Utils.putBooleanValue(LoginActivity.this, Constants.LoginState, true);
                Utils.putValue(LoginActivity.this, Constants.NAME, userName);
                Utils.putValue(LoginActivity.this, Constants.PWD, DES.md5Pwd(password));
                getChatserive(userName, DES.md5Pwd(password));
            }

            @Override
            public void onMyFailure() {
                getLoadingDialog("正在登录").dismiss();
            }
        });
    } else {
        Utils.showLongToast(LoginActivity.this, "请填写账号或密码!");
    }
}
Also used : RequestParams(com.juns.health.net.loopj.android.http.RequestParams) BaseJsonRes(com.juns.wechat.net.BaseJsonRes)

Example 4 with RequestParams

use of com.juns.health.net.loopj.android.http.RequestParams in project wechat by motianhuo.

the class RegisterActivity method getRegister.

private void getRegister() {
    final String name = et_usertel.getText().toString();
    final String pwd = et_password.getText().toString();
    String code = et_code.getText().toString();
    if (!Utils.isMobileNO(name)) {
        Utils.showLongToast(RegisterActivity.this, "请使用手机号码注册账户! ");
        return;
    }
    if (TextUtils.isEmpty(code)) {
        Utils.showLongToast(RegisterActivity.this, "请填写手机号码,并获取验证码!");
        return;
    }
    if (TextUtils.isEmpty(name) || TextUtils.isEmpty(pwd) || TextUtils.isEmpty(code)) {
        Utils.showLongToast(RegisterActivity.this, "请填写核心信息!");
        return;
    }
    getLoadingDialog("正在注册...  ").show();
    btn_register.setEnabled(false);
    btn_send.setEnabled(false);
    RequestParams params = new RequestParams();
    params.put("username", name);
    params.put("password", DES.md5Pwd(pwd));
    // params.put("checkCode", code);
    netClient.post(Constants.RegistURL, params, new BaseJsonRes() {

        @Override
        public void onMySuccess(String data) {
            Utils.putValue(RegisterActivity.this, Constants.UserInfo, data);
            Utils.putValue(RegisterActivity.this, Constants.NAME, name);
            Utils.putValue(RegisterActivity.this, Constants.PWD, DES.md5Pwd(pwd));
            Utils.putBooleanValue(RegisterActivity.this, Constants.LoginState, true);
            getChatserive(name, DES.md5Pwd(pwd));
        }

        @Override
        public void onMyFailure() {
            getLoadingDialog("").dismiss();
            btn_register.setEnabled(true);
            btn_send.setEnabled(true);
        }
    });
}
Also used : RequestParams(com.juns.health.net.loopj.android.http.RequestParams) BaseJsonRes(com.juns.wechat.net.BaseJsonRes)

Example 5 with RequestParams

use of com.juns.health.net.loopj.android.http.RequestParams in project wechat by motianhuo.

the class RegisterActivity method getCode.

private void getCode() {
    String phone = et_usertel.getText().toString();
    RequestParams params = new RequestParams();
    params.put("telephone", phone);
    params.put("codeType", "1");
    netClient.post(Constants.SendCodeURL, params, new JsonHttpResponseHandler() {

        @Override
        public void onSuccess(JSONObject response) {
            super.onSuccess(response);
            try {
                String result = response.getString("result");
                System.out.println("返回的值" + response);
                if (result == null) {
                    Utils.showLongToast(App.getInstance(), Constants.NET_ERROR);
                } else if (result.equals("Y")) {
                    String str = response.getString("value");
                    Utils.showLongToast(App.getInstance(), str);
                } else {
                    String str = response.getString("value");
                    Utils.showLongToast(App.getInstance(), str);
                    mc.cancel();
                    btn_send.setEnabled(true);
                    btn_send.setText("发送验证码");
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    });
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) JsonHttpResponseHandler(com.juns.health.net.loopj.android.http.JsonHttpResponseHandler) RequestParams(com.juns.health.net.loopj.android.http.RequestParams)

Aggregations

RequestParams (com.juns.health.net.loopj.android.http.RequestParams)8 BaseJsonRes (com.juns.wechat.net.BaseJsonRes)7 Intent (android.content.Intent)2 User (com.juns.wechat.bean.User)2 JsonHttpResponseHandler (com.juns.health.net.loopj.android.http.JsonHttpResponseHandler)1 MainActivity (com.juns.wechat.MainActivity)1 FromContactAdapter (com.juns.wechat.adpter.FromContactAdapter)1 GroupInfo (com.juns.wechat.bean.GroupInfo)1 ChatActivity (com.juns.wechat.chat.ChatActivity)1 NetClient (com.juns.wechat.net.NetClient)1 List (java.util.List)1 FinalDb (net.tsz.afinal.FinalDb)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1