Skip to content

Instantly share code, notes, and snippets.

@peterclemenko
Created July 17, 2015 21:17
Show Gist options
  • Save peterclemenko/00f1e617cc00742ec9c7 to your computer and use it in GitHub Desktop.
Save peterclemenko/00f1e617cc00742ec9c7 to your computer and use it in GitHub Desktop.
private ChatGroups getChatGroups(GenericSqliteHelper helper) {
// SQLiteDatabase db = helper.getReadableDatabase();
final ChatGroups groups = new ChatGroups();
RecordVisitor visitor = new RecordVisitor() {
@Override
public long cursor(Cursor cursor) {
String key = cursor.getString(0);
String mids = cursor.getString(2);
String names = cursor.getString(3);
String[] ms = mids.split(";");
String[] ns = names.split(",");
for (int i = 0; i < ms.length; i++) {
String id = ms[i].trim();
String name = ns[i].trim();
groups.addPeerToGroup(key, new Contact(id, name, name, null));
}
if (Cfg.DEBUG) {
Check.log(TAG + " (getChatGroups) %s", key);
}
return 0;
}
};
helper.traverseRecords(M.e("chatroom"), visitor);
return groups;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment