Search in sources :

Example 41 with UserBaseVo

use of com.lingtuan.firefly.vo.UserBaseVo in project SmartMesh_Android by SmartMeshFoundation.

the class ContactAddAdapter method requestAgree.

/**
 * Agree to add buddy
 */
private void requestAgree(final Holder h, final ChatMsg msg) {
    if (msg.isOffLineMsg()) {
        if (listener != null) {
            boolean successed = listener.addFriendConfim(msg.getUserId());
            if (successed) {
                FinalUserDataBase.getInstance().updateChatEventAgree(msg.getUserId(), true, msg.getType());
                UserBaseVo vo = new UserBaseVo();
                vo.setFriendLog(1);
                vo.setThumb(msg.getUserImage());
                vo.setLocalId(msg.getUserId());
                vo.setUsername(msg.getUsername());
                vo.setGender(msg.getGender() + "");
                vo.setOffLine(true);
                FinalUserDataBase.getInstance().saveFriendUserBase(vo);
                msg.setAgree(true);
                notifyDataSetChanged();
            } else {
                h.agreeBtn.setEnabled(true);
                if (Utils.isConnectNet(mContext)) {
                    NetRequestImpl.getInstance().addFriendAgree(msg.getUserId(), new RequestListener() {

                        @Override
                        public void start() {
                        }

                        @Override
                        public void success(JSONObject response) {
                            try {
                                MyToast.showToast(mContext, response.optString("msg"));
                                FinalUserDataBase.getInstance().updateChatEventAgree(msg.getUserId(), true, msg.getType());
                                msg.setAgree(true);
                                Constants.isRefresh = true;
                                notifyDataSetChanged();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }

                        @Override
                        public void error(int errorCode, String errorMsg) {
                            try {
                                if (1211122 == errorCode) {
                                    FinalUserDataBase.getInstance().updateChatEventAgree(msg.getUserId(), true, msg.getType());
                                    msg.setAgree(true);
                                } else {
                                    MyToast.showToast(mContext, errorMsg);
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            notifyDataSetChanged();
                        }
                    });
                }
            }
        }
    } else {
        NetRequestImpl.getInstance().addFriendAgree(msg.getUserId(), new RequestListener() {

            @Override
            public void start() {
            }

            @Override
            public void success(JSONObject response) {
                try {
                    MyToast.showToast(mContext, response.optString("msg"));
                    FinalUserDataBase.getInstance().updateChatEventAgree(msg.getUserId(), true, msg.getType());
                    msg.setAgree(true);
                    Constants.isRefresh = true;
                    notifyDataSetChanged();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void error(int errorCode, String errorMsg) {
                try {
                    if (1211121 == errorCode) {
                        FinalUserDataBase.getInstance().updateChatEventAgree(msg.getUserId(), true, msg.getType());
                        msg.setAgree(true);
                    } else {
                        MyToast.showToast(mContext, errorMsg);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                notifyDataSetChanged();
            }
        });
    }
}
Also used : RequestListener(com.lingtuan.firefly.listener.RequestListener) JSONObject(org.json.JSONObject) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 42 with UserBaseVo

use of com.lingtuan.firefly.vo.UserBaseVo in project SmartMesh_Android by SmartMeshFoundation.

the class ContactSearchNickAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    Holder h;
    if (convertView == null) {
        h = new Holder();
        convertView = View.inflate(mContext, R.layout.contact_search_nick_item, null);
        h.mAvatar = (ImageView) convertView.findViewById(R.id.invite_avatar);
        h.nickName = (TextView) convertView.findViewById(R.id.nearby_nickname);
        convertView.setTag(h);
    } else {
        h = (Holder) convertView.getTag();
    }
    UserBaseVo vo = friendList.get(position);
    h.nickName.setText(vo.getShowName());
    NextApplication.displayCircleImage(h.mAvatar, vo.getThumb());
    return convertView;
}
Also used : UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 43 with UserBaseVo

use of com.lingtuan.firefly.vo.UserBaseVo in project SmartMesh_Android by SmartMeshFoundation.

the class ChatAdapter method showCardMsg.

/**
 * Display and operation business card message
 * @param h ViewHolder
 * @param msg message
 */
private void showCardMsg(Holder h, final ChatMsg msg) {
    h.shopImage.setText(msg.getThirdName(), h.shopImage, msg.getThirdImage());
    // h.shopAddress.setText(msg.getCardSign());
    h.shopAddress.setText(mContext.getString(R.string.chatting_card_hint));
    h.shopName.setText(msg.getThirdName());
    h.leftLinear.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            UserBaseVo vo = new UserBaseVo();
            vo.setUsername(msg.getThirdName());
            vo.setLocalId(msg.getThirdId());
            vo.setThumb(msg.getThirdImage());
            vo.setGender(msg.getThirdGender());
            vo.setFriendLog(msg.getFriendLog());
            intentPeopleDetailUI(vo);
        }
    });
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) CharAvatarView(com.lingtuan.firefly.custom.CharAvatarView) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 44 with UserBaseVo

use of com.lingtuan.firefly.vo.UserBaseVo in project SmartMesh_Android by SmartMeshFoundation.

the class SelectGroupMemberListAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    Holder h = null;
    if (convertView == null) {
        h = new Holder();
        convertView = View.inflate(mContext, R.layout.contact_child_item, null);
        h.mAvatar = (ImageView) convertView.findViewById(R.id.invite_avatar);
        h.mNickname = (TextView) convertView.findViewById(R.id.nearby_nickname);
        h.mLinear = (LinearLayout) convertView.findViewById(R.id.linear);
        convertView.setTag(h);
    } else {
        h = (Holder) convertView.getTag();
    }
    UserBaseVo vo = mList.get(position);
    NextApplication.displayCircleImage(h.mAvatar, vo.getThumb());
    h.mNickname.setText(vo.getShowName());
    h.mLinear.setVisibility(View.GONE);
    return convertView;
}
Also used : UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 45 with UserBaseVo

use of com.lingtuan.firefly.vo.UserBaseVo in project SmartMesh_Android by SmartMeshFoundation.

the class DiscussionGroupsVo method parse.

public DiscussionGroupsVo parse(JSONObject obj, boolean withOutMe) {
    if (obj == null) {
        return null;
    }
    setCid(obj.optInt("cid"));
    setName(obj.optString("name"));
    setMask(obj.optInt("mask"));
    setMaxNum(obj.optInt("max_num"));
    List<UserBaseVo> mList = new ArrayList<UserBaseVo>();
    UserBaseVo vo;
    JSONArray array = obj.optJSONArray("members");
    for (int i = 0; i < array.length(); i++) {
        vo = new UserBaseVo().parse(array.optJSONObject(i));
        if (vo != null) {
            if (withOutMe) {
                // Is your own
                if (vo.getLocalId().equals(NextApplication.myInfo.getLocalId())) {
                    withOutMe = false;
                    continue;
                }
            }
            mList.add(vo);
        }
    }
    setMembers(mList);
    return this;
}
Also used : ArrayList(java.util.ArrayList) JSONArray(org.json.JSONArray) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Aggregations

UserBaseVo (com.lingtuan.firefly.vo.UserBaseVo)53 ArrayList (java.util.ArrayList)13 ChatMsg (com.lingtuan.firefly.vo.ChatMsg)9 Cursor (android.database.Cursor)7 View (android.view.View)7 ListView (android.widget.ListView)7 TextView (android.widget.TextView)7 Intent (android.content.Intent)6 ImageView (android.widget.ImageView)6 JSONObject (org.json.JSONObject)6 Bundle (android.os.Bundle)5 AdapterView (android.widget.AdapterView)5 OnClickListener (android.view.View.OnClickListener)4 HorizontalScrollView (android.widget.HorizontalScrollView)4 DiscussionGroupsVo (com.lingtuan.firefly.contact.vo.DiscussionGroupsVo)4 NewContactVO (com.lingtuan.firefly.contact.vo.NewContactVO)4 RequestListener (com.lingtuan.firefly.listener.RequestListener)4 Handler (android.os.Handler)3 Editable (android.text.Editable)3 LinearLayout (android.widget.LinearLayout)3