Search in sources :

Example 1 with PhoneContactGroupVo

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

the class AddContactFriendsAdapter method getGroupView.

@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
    HolderGroup h;
    if (convertView == null) {
        h = new HolderGroup();
        convertView = View.inflate(mContext, R.layout.contact_group_item, null);
        h.childCount = (TextView) convertView.findViewById(R.id.contact_group_child_count);
        h.groupName = (TextView) convertView.findViewById(R.id.contact_group_name);
        h.expandIcon = (ImageView) convertView.findViewById(R.id.contact_group_expand_icon);
        convertView.setTag(h);
    } else {
        h = (HolderGroup) convertView.getTag();
    }
    PhoneContactGroupVo vo = mGroupInfoList.get(groupPosition);
    h.childCount.setText(vo.getContactList() != null ? vo.getContactList().size() + "" : "0");
    if (vo.getType() == 0) {
        vo.setGroupName(mContext.getString(R.string.friend_can_invite));
    } else if (vo.getType() == 1) {
        vo.setGroupName(mContext.getString(R.string.friend_can_add));
    } else {
        vo.setGroupName(mContext.getString(R.string.friend_have_add));
    }
    h.groupName.setText(vo.getGroupName());
    if (isExpanded) {
        h.expandIcon.setImageResource(R.drawable.contact_open_tips);
    } else {
        h.expandIcon.setImageResource(R.drawable.contact_close_tips);
    }
    return convertView;
}
Also used : PhoneContactGroupVo(com.lingtuan.firefly.contact.vo.PhoneContactGroupVo)

Example 2 with PhoneContactGroupVo

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

the class FinalUserDataBase method getPhoneContactGroup.

/**
 * get local save three friends information
 *
 * @ param type 1. The mobile phone address book, 2. Sina weibo friends, 3. Tencent weibo friends
 * @ return
 */
public List<PhoneContactGroupVo> getPhoneContactGroup(int type) {
    String sql = "select * from " + TableField.TABLE_CONTACT + " where " + TableField.FIELD_CHAT_TYPE + "=? " + " order by " + TableField.FIELD_FRIEND_RELATION + "," + TableField.FIELD_FRIEND_UNAME;
    Cursor cursor = db.rawQuery(sql, new String[] { String.valueOf(type) });
    List<PhoneContactGroupVo> mGList = new ArrayList<PhoneContactGroupVo>();
    PhoneContactGroupVo gVo = null;
    List<PhoneContactVo> mCList = new ArrayList<PhoneContactVo>();
    PhoneContactVo vo = null;
    int relation = 0;
    while (cursor.moveToNext()) {
        vo = new PhoneContactVo();
        vo.setId(cursor.getString(cursor.getColumnIndex(TableField.FIELD_CHAT_THIRDID)));
        vo.setName(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_UNAME)));
        vo.setNote(cursor.getString(cursor.getColumnIndex(TableField.FIELD_FRIEND_NOTE)));
        vo.setRelation(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_FRIEND_RELATION)));
        vo.setUid(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_FRIEND_UID)));
        vo.setType(cursor.getInt(cursor.getColumnIndex(TableField.FIELD_CHAT_TYPE)));
        if (vo.getRelation() != relation) {
            // 新的组
            gVo = new PhoneContactGroupVo();
            gVo.setContactList(mCList);
            gVo.setType(relation);
            mGList.add(gVo);
            relation = vo.getRelation();
            mCList = new ArrayList<>();
            mCList.add(vo);
        } else {
            mCList.add(vo);
        }
    }
    cursor.close();
    gVo = new PhoneContactGroupVo();
    gVo.setContactList(mCList);
    if (vo != null) {
        gVo.setType(vo.getRelation());
    }
    mGList.add(gVo);
    return mGList;
}
Also used : PhoneContactGroupVo(com.lingtuan.firefly.contact.vo.PhoneContactGroupVo) PhoneContactVo(com.lingtuan.firefly.contact.vo.PhoneContactVo) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor)

Aggregations

PhoneContactGroupVo (com.lingtuan.firefly.contact.vo.PhoneContactGroupVo)2 Cursor (android.database.Cursor)1 PhoneContactVo (com.lingtuan.firefly.contact.vo.PhoneContactVo)1 ArrayList (java.util.ArrayList)1