Search in sources :

Example 6 with BaseJsonRes

use of com.juns.wechat.net.BaseJsonRes 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 BaseJsonRes

use of com.juns.wechat.net.BaseJsonRes 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 BaseJsonRes

use of com.juns.wechat.net.BaseJsonRes in project wechat by motianhuo.

the class UpdateService method initUserList.

// 获取好友列表和订阅号
private void initUserList() {
    GloableParams.UserInfos = db.findAll(User.class);
    netClient.post(Constants.getUserInfoURL, null, new BaseJsonRes() {

        @Override
        public void onMySuccess(String data) {
            List<User> new_users = JSON.parseArray(data, User.class);
            for (User user : new_users) {
                if (user.getUserName() == null) {
                    user.setUserName("WX" + user.getTelephone());
                    new_users.remove(user);
                    new_users.add(user);
                }
                if (db.findById(user.getId(), User.class) != null)
                    db.deleteById(User.class, user.getId());
                db.save(user);
                GloableParams.Users.put(user.getTelephone(), user);
            }
            sendBrodcast("UserList");
        }

        @Override
        public void onMyFailure() {
        // initUserList();
        }
    });
}
Also used : User(com.juns.wechat.bean.User) List(java.util.List) BaseJsonRes(com.juns.wechat.net.BaseJsonRes)

Example 9 with BaseJsonRes

use of com.juns.wechat.net.BaseJsonRes 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

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