fix #647, always fetch contacts the same way, no matter the sorting

This commit is contained in:
tibbi 2021-01-10 12:37:48 +01:00
parent f1aa4e96d7
commit 21ed55cc47
1 changed files with 45 additions and 44 deletions

View File

@ -134,8 +134,9 @@ class ContactsHelper(val context: Context) {
val uri = Data.CONTENT_URI
val projection = getContactProjection()
val selection = "${Data.MIMETYPE} = ? OR ${Data.MIMETYPE} = ?"
val selectionArgs = arrayOf(StructuredName.CONTENT_ITEM_TYPE, CommonDataKinds.Organization.CONTENT_ITEM_TYPE)
arrayOf(CommonDataKinds.Organization.CONTENT_ITEM_TYPE, StructuredName.CONTENT_ITEM_TYPE).forEach { mimetype ->
val selection = "${Data.MIMETYPE} = ?"
val selectionArgs = arrayOf(mimetype)
val sortOrder = getSortString()
context.queryCursor(uri, projection, selection, selectionArgs, sortOrder, true) { cursor ->
@ -151,7 +152,6 @@ class ContactsHelper(val context: Context) {
var middleName = ""
var surname = ""
var suffix = ""
val mimetype = cursor.getStringValue(Data.MIMETYPE)
// ignore names at Organization type contacts
if (mimetype == StructuredName.CONTENT_ITEM_TYPE) {
@ -181,6 +181,7 @@ class ContactsHelper(val context: Context) {
contacts.put(id, contact)
}
}
val phoneNumbers = getPhoneNumbers(null)
var size = phoneNumbers.size()