Search in sources :

Example 6 with RequestParams

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

the class UserUtils method initUserInfo.

public static void initUserInfo(final Context context, final String telphone, final ImageView img_avar, final TextView txt_name) {
    NetClient netClient = new NetClient(context);
    RequestParams params = new RequestParams();
    params.put("telphone", telphone);
    netClient.post(Constants.getUserInfoURL, params, new BaseJsonRes() {

        @Override
        public void onMySuccess(String data) {
            User user = JSON.parseObject(data, User.class);
            if (user != null) {
                if (user.getUserName() != null) {
                    txt_name.setText(user.getUserName());
                }
                if (user.getHeadUrl() != null) {
                    NetClient.getIconBitmap(img_avar, user.getHeadUrl());
                }
                FinalDb db = FinalDb.create(context, Constants.DB_NAME, false);
                if (db.findById(user.getId(), User.class) != null)
                    db.deleteById(User.class, user.getId());
                db.save(user);
                GloableParams.UserInfos.add(user);
                GloableParams.Users.put(user.getTelephone(), user);
            }
        }

        @Override
        public void onMyFailure() {
        }
    });
}
Also used : NetClient(com.juns.wechat.net.NetClient) User(com.juns.wechat.bean.User) FinalDb(net.tsz.afinal.FinalDb) RequestParams(com.juns.health.net.loopj.android.http.RequestParams) BaseJsonRes(com.juns.wechat.net.BaseJsonRes)

Example 7 with RequestParams

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

the class ChatActivity method initGroupInfo.

private void initGroupInfo() {
    RequestParams params = new RequestParams();
    String userid = UserUtils.getUserID(this);
    params.put("user_id", userid);
    params.put("group_id", toChatUsername);
    netClient.post(Constants.getUserInfoURL, params, new BaseJsonRes() {

        @Override
        public void onMySuccess(String data) {
            GroupInfo group = JSON.parseObject(data, GroupInfo.class);
            // NetClient.getIconBitmap(img_avar, group.getGroup_name());
            if (group != null && group.getGroup_name() != null)
                txt_title.setText(group.getGroup_name());
        }

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

Example 8 with RequestParams

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

the class AddFromContactActivity method initView.

@Override
protected void initView() {
    getLoadingDialog("正在获取联系人").show();
    String str_contact = Utils.getValue(this, Constants.ContactMsg);
    RequestParams params = new RequestParams();
    params.put("userlist", str_contact);
    netClient.post(Constants.getContactFriendURL, params, new BaseJsonRes() {

        @Override
        public void onMySuccess(String data) {
            List<User> UserInfos = JSON.parseArray(data, User.class);
            mlistview.setAdapter(new FromContactAdapter(AddFromContactActivity.this, UserInfos));
            getLoadingDialog("正在获取联系人").dismiss();
        }

        @Override
        public void onMyFailure() {
            // TODO Auto-generated method stub
            getLoadingDialog("正在获取联系人").dismiss();
        }
    });
}
Also used : User(com.juns.wechat.bean.User) FromContactAdapter(com.juns.wechat.adpter.FromContactAdapter) List(java.util.List) RequestParams(com.juns.health.net.loopj.android.http.RequestParams) BaseJsonRes(com.juns.wechat.net.BaseJsonRes)

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