use of com.lingtuan.firefly.contact.vo.PhoneContactVo 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;
}
Aggregations