Search in sources :

Example 46 with UserBaseVo

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

the class GroupMemberAvatarVo method getUserBaseVo.

/**
 * The vo only thumb DiscussGroupImageView use with gender
 */
public UserBaseVo getUserBaseVo() {
    UserBaseVo vo = new UserBaseVo();
    vo.setThumb(image);
    vo.setGender(gender + "");
    return vo;
}
Also used : UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 47 with UserBaseVo

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

the class FinalUserDataBase method getFriendUserBaseAll.

/**
 * Get all the friends
 *
 * @return
 */
public List<UserBaseVo> getFriendUserBaseAll() {
    List<UserBaseVo> list = new ArrayList<UserBaseVo>();
    String sql = "select * from " + TableField.TABLE_FRIEND + " order by " + TableField.FIELD_FRIEND_UID;
    Cursor cursor = db.rawQuery(sql, null);
    UserBaseVo vo;
    while (cursor.moveToNext()) {
        vo = new UserBaseVo();
        vo.setAge(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_AGE)));
        vo.setDistance(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_DISTANCE)));
        vo.setGender(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_GENDER)));
        vo.setLogintime(cursor.getLong(cursor.getColumnIndex(TableField.FIELD_FRIEND_LOGINTIME)));
        vo.setNote(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_NOTE)));
        vo.setPic(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_PIC)));
        vo.setSightml(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_SIGHTML)));
        vo.setThumb(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_THUMB)));
        vo.setLocalId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UID)));
        vo.setUsername(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UNAME)));
        vo.setOffLine(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA3)) == 1 ? true : false);
        vo.setAddress(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA7)));
        list.add(vo);
    }
    /*add your self*/
    UserBaseVo voMe = new UserBaseVo();
    voMe.setFriendLog(-1);
    voMe.setGender(NextApplication.myInfo.getGender());
    voMe.setPic(NextApplication.myInfo.getPic());
    voMe.setSightml(NextApplication.myInfo.getSightml());
    voMe.setThumb(NextApplication.myInfo.getThumb());
    voMe.setLocalId(NextApplication.myInfo.getLocalId());
    voMe.setUsername(NextApplication.myInfo.getShowName());
    list.add(voMe);
    cursor.close();
    return list;
}
Also used : ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 48 with UserBaseVo

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

the class FinalUserDataBase method getChatMsgEventList.

/**
 *My chat history record contains information system information
 *
 * @return
 */
public List<ChatMsg> getChatMsgEventList() {
    List<ChatMsg> list = new ArrayList<ChatMsg>();
    if (db != null) {
        String sql = "select * from " + TableField.TABLE_CHAT_EVENT + /*" where "  +TableField.FIELD_RESERVED_DATA7 + " is not 1*/
        " order by " + TableField.FIELD_CHAT_MSGTIME + " desc ";
        Cursor cursor = db.rawQuery(sql, null);
        ChatMsg msg;
        int total = 0;
        int unFriendTotle = 0;
        while (cursor.moveToNext()) {
            msg = new ChatMsg();
            msg.setId(cursor.getInt(cursor.getColumnIndex(TableField._ID)));
            msg.setContent(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_BODY)));
            msg.setGender(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_FRIEND_GENDER)));
            msg.setMsgTime(cursor.getLong(cursor.getColumnIndex(TableField.FIELD_CHAT_MSGTIME)));
            msg.setType(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_TYPE)));
            msg.setUserId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UID)));
            msg.setUserImage(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_PIC)));
            msg.setUsername(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UNAME)));
            msg.setChatId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_ID)));
            msg.setHidden(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_HIDDEN)) == 1 ? true : false);
            msg.setUnread(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_UNREAD)));
            msg.setSystem(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_SYSTEM)) == 1 ? true : false);
            msg.setDismissGroup(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_DISMISSGROUP)) == 1 ? true : false);
            msg.setKickGroup(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_KICKGROUP)) == 1 ? true : false);
            msg.setMessageId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA1)));
            msg.setShareFriendName(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA2)));
            msg.setModifyType(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA3)));
            msg.setFriendLog(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA5)));
            msg.setGroupMask(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA6)) == 1 ? true : false);
            msg.setAtGroupMe(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA8)));
            msg.setGroupImage(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_GROUP_IMAGE)));
            msg.setMsgTypeInt(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_OBJECT)));
            msg.setCreateName(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_CREATENAME)));
            msg.setVip_type(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA12)));
            msg.setVip_level(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA13)));
            msg.setIs_vip(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA14)) == 1);
            msg.setTop(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA15)) == 1);
            msg.setRemoteSource(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA18)));
            msg.setInviteType(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA19)));
            msg.setInviteSource(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA20)));
            msg.setMoney(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA9)));
            msg.setMode(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA11)));
            msg.setNoticeType(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA26)));
            if (msg.isTop()) {
                msg.setTopTime(cursor.getLong(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA16)));
            }
            if (msg.getChatId().startsWith("group")) {
                msg.setGroup(true);
                try {
                    List<GroupMemberAvatarVo> lists = new ArrayList<>();
                    GroupMemberAvatarVo vo;
                    String[] split = msg.getUserImage().split("#");
                    for (int i = 0; i < split.length; i++) {
                        vo = new GroupMemberAvatarVo();
                        String[] splitVo = split[i].split("___");
                        int gender = 2;
                        try {
                            gender = Integer.parseInt(splitVo[1]);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        String image = "";
                        try {
                            image = splitVo[0];
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        vo.setGender(gender);
                        vo.setImage(image);
                        lists.add(vo);
                    }
                    msg.setMemberAvatarList(lists);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (!msg.isHidden()) {
                list.add(msg);
                if (msg.getChatId().equals("system-0") || msg.getChatId().equals("system-1") || msg.getChatId().equals("system-3") || msg.getChatId().equals("system-4") || msg.getChatId().equals("system-5")) {
                    total += msg.getUnread();
                } else if (!msg.getGroupMask()) {
                    total += msg.getUnread();
                }
            } else {
                if (!msg.isSystem() && !msg.getGroupMask()) {
                    unFriendTotle += msg.getUnread();
                }
            }
            if (!msg.isGroup() && msg.getMsgTypeInt() != 3 && !TextUtils.isEmpty(msg.getChatId()) && !TextUtils.equals("everyone", msg.getChatId()) && !msg.getChatId().startsWith("system")) {
                UserBaseVo baseVo = FinalUserDataBase.getInstance().getUserBaseVoByUid(msg.getChatId());
                if (baseVo != null && !TextUtils.isEmpty(baseVo.getShowName())) {
                    msg.setUsername(baseVo.getShowName());
                }
            }
        }
        try {
            map.put("totalunread", total);
        } catch (Exception e) {
            e.printStackTrace();
        }
        cursor.close();
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) ChatMsg(com.lingtuan.firefly.vo.ChatMsg) GroupMemberAvatarVo(com.lingtuan.firefly.contact.vo.GroupMemberAvatarVo) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 49 with UserBaseVo

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

the class FinalUserDataBase method getChatMsgListByChatId.

/**
 * Access to chat
 *
 * @param chatId Chat with who
 * @param limit  From which to take
 * @param count  Article take how much
 * @return
 */
public List<ChatMsg> getChatMsgListByChatId(String chatId, int limit, int count) {
    String sql = "select * from " + TableField.TABLE_CHAT + " where " + TableField.FIELD_CHAT_ID + "=? " + /*and " + TableField.FIELD_RESERVED_DATA7 + "!=1*/
    " order by " + TableField._ID + " desc " + " limit " + limit + "," + count;
    String sql1 = "select * from (" + sql + ") order by " + TableField._ID;
    Cursor cursor = db.rawQuery(sql1, new String[] { chatId });
    List<ChatMsg> list = new ArrayList<ChatMsg>();
    ChatMsg msg;
    while (cursor.moveToNext()) {
        msg = new ChatMsg();
        msg.setId(cursor.getInt(cursor.getColumnIndex(TableField._ID)));
        msg.setContent(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_BODY)));
        msg.setGender(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_FRIEND_GENDER)));
        msg.setMsgTime(cursor.getLong(cursor.getColumnIndex(TableField.FIELD_CHAT_MSGTIME)));
        msg.setType(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_TYPE)));
        msg.setUserId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UID)));
        msg.setUserImage(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_PIC)));
        msg.setRealname(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UNAME)));
        msg.setUnread(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_UNREAD)));
        msg.setUsername(msg.getRealname());
        msg.setChatId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_ID)));
        msg.setSend(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_ISSEND)));
        msg.setGroupImage(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_GROUP_IMAGE)));
        msg.setMsgTypeInt(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_OBJECT)));
        msg.setCover(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_COVER)));
        msg.setSecond(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_SECOND)));
        msg.setLon(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_LON)));
        msg.setLat(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_LAT)));
        msg.setThirdName(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_THIRDNAME)));
        msg.setThirdImage(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_THIRDIMAGE)));
        msg.setThirdId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_THIRDID)));
        msg.setShopAddress(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_SHOPADDRESS)));
        msg.setCardSign(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_CARDSIGN)));
        msg.setLocalUrl(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_LOCALURL)));
        msg.setShowTime(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_SHOWTIME)) == 1 ? true : false);
        msg.setMessageId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA1)));
        msg.setThirdGender(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA2)));
        msg.setDatingSOSId(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA3)));
        msg.setFriendLog(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA4)));
        msg.setInviteType(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA5)));
        msg.setOffLineMsg(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA7)) == 1 ? true : false);
        msg.setNumber(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA6)));
        msg.setShareUrl(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA8)));
        msg.setShareTitle(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA9)));
        msg.setShareThumb(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA10)));
        msg.setRedpacketId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA11)));
        msg.setCreateName(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA12)));
        msg.setSource(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA13)));
        msg.setRemoteSource(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA14)));
        msg.setCreateTime(cursor.getLong(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA15)));
        msg.setUsersource(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA16)));
        msg.setUserfrom(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA17)));
        if (!TextUtils.isEmpty(msg.getUserId())) {
            UserBaseVo baseVo = FinalUserDataBase.getInstance().getUserBaseVoByUid(msg.getUserId());
            if (baseVo != null && !TextUtils.isEmpty(baseVo.getShowName())) {
                msg.setUsername(baseVo.getShowName());
            }
        }
        list.add(msg);
    }
    cursor.close();
    return list;
}
Also used : ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) ChatMsg(com.lingtuan.firefly.vo.ChatMsg) UserBaseVo(com.lingtuan.firefly.vo.UserBaseVo)

Example 50 with UserBaseVo

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

the class FinalUserDataBase method getUserBaseVoByUid.

/**
 * To obtain a single friend
 *
 * @return
 */
public UserBaseVo getUserBaseVoByUid(String uid) {
    String sql = "select * from " + TableField.TABLE_FRIEND + " where " + TableField.FIELD_FRIEND_UID + "=? " + " order by " + TableField.FIELD_FRIEND_UID;
    Cursor cursor = db.rawQuery(sql, new String[] { uid });
    UserBaseVo vo = null;
    if (cursor.moveToNext()) {
        vo = new UserBaseVo();
        vo.setAge(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_AGE)));
        vo.setDistance(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_DISTANCE)));
        vo.setGender(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_GENDER)));
        vo.setLogintime(cursor.getLong(cursor.getColumnIndex(TableField.FIELD_FRIEND_LOGINTIME)));
        vo.setNote(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_NOTE)));
        vo.setPic(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_PIC)));
        vo.setSightml(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_SIGHTML)));
        vo.setThumb(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_THUMB)));
        vo.setLocalId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UID)));
        vo.setUsername(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UNAME)));
        vo.setAddress(cursor.getString(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA7)));
        vo.setOffLine(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_RESERVED_DATA3)) == 1 ? true : false);
        ;
    }
    cursor.close();
    return vo;
}
Also used : Cursor(android.database.Cursor) 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