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

View File

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