@Override public List<DBUser> findByFriendGroup(DBFriendGroup friendGroup) { db = getTransactionDB(); Cursor cursor = db.rawQuery( "SELECT " + DBColumns.FRIEND_STATE_USER_ACCOUNT + " FROM " + DBColumns.FRIEND_STATE_TABLE_NAME + " WHERE " + DBColumns.FRIEND_STATE_FRIEND_GROUP_ACCOUNT + "=?", new String[] {friendGroup.getAccount()}); int i = 0; String[] us = new String[cursor.getCount()]; while (cursor.moveToNext()) { us[i++] = cursor.getString(0); } cursor.close(); List<DBUser> users = new ArrayList<DBUser>(); for (int j = 0; j < us.length; j++) { users.add(userDao.findByAccount(us[j])); } return users; }
@Override public List<DBFriendGroupMapping> findMappingByFriendGroup(DBFriendGroup friendGroup) { // friendgroup中分组中包含的user,及user状态 db = getTransactionDB(); Cursor cursor = db.rawQuery( "SELECT * FROM " + DBColumns.FRIEND_STATE_TABLE_NAME + " WHERE " + DBColumns.FRIEND_STATE_FRIEND_GROUP_ACCOUNT + "=?", new String[] {friendGroup.getAccount()}); List<DBFriendGroupMapping> mappings = new ArrayList<DBFriendGroupMapping>(); while (cursor.moveToNext()) { String userAccount = cursor.getString(cursor.getColumnIndex(DBColumns.FRIEND_STATE_USER_ACCOUNT)); DBUser user = userDao.findByAccount(userAccount); mappings.add(DBObjectHelper.getDB3FriendGroupMapping(user, friendGroup, cursor)); } cursor.close(); return mappings; }