adding a helper function for retrieving contact duplicates

This commit is contained in:
tibbi 2019-09-11 22:49:19 +02:00
parent dcd546b7cb
commit 797df0a2d7
2 changed files with 12 additions and 7 deletions

View file

@ -477,14 +477,10 @@ class ViewContactActivity : ContactActivity() {
}
addContactSource(contact!!)
ensureBackgroundThread {
ContactsHelper(this).getContacts { contacts ->
ContactsHelper(this).getDuplicatesOfContact(contact!!) { contacts ->
runOnUiThread {
contacts.forEach {
if (it.id != contact!!.id && it.getHashToCompare() == contact!!.getHashToCompare()) {
runOnUiThread {
addContactSource(it)
}
}
addContactSource(it)
}
}
}

View file

@ -1561,4 +1561,13 @@ class ContactsHelper(val context: Context) {
context.showErrorToast(e)
}
}
fun getDuplicatesOfContact(contact: Contact, callback: (ArrayList<Contact>) -> Unit) {
ensureBackgroundThread {
getContacts { contacts ->
val duplicates = contacts.filter { it.id != contact.id && it.getHashToCompare() == contact.getHashToCompare() }.toMutableList() as ArrayList<Contact>
callback(duplicates)
}
}
}
}