From dbad01e1fc1087a3c0b1766ae976f2553e33a287 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 16 Mar 2018 23:47:57 +0100 Subject: [PATCH] ignore the default and Favorites group --- .../simplemobiletools/contacts/helpers/ContactsHelper.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt index 0b3a19c4..2690ce52 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt @@ -341,7 +341,7 @@ class ContactsHelper(val activity: BaseSimpleActivity) { groups.put(id, ArrayList()) } - val groupTitle = storedGroups.firstOrNull { it.id == newRowId }?.title ?: "" + val groupTitle = storedGroups.firstOrNull { it.id == newRowId }?.title ?: continue val group = Group(newRowId, groupTitle) groups[id]!!.add(group) } while (cursor.moveToNext()) @@ -363,9 +363,12 @@ class ContactsHelper(val activity: BaseSimpleActivity) { ContactsContract.Groups.TITLE ) + val selection = "${ContactsContract.Groups.AUTO_ADD} = ? AND ${ContactsContract.Groups.FAVORITES} = ?" + val selectionArgs = arrayOf("0", "0") + var cursor: Cursor? = null try { - cursor = activity.contentResolver.query(uri, projection, null, null, null) + cursor = activity.contentResolver.query(uri, projection, selection, selectionArgs, null) if (cursor?.moveToFirst() == true) { do { val id = cursor.getIntValue(ContactsContract.Groups._ID)