adding a helper function for retrieving contact duplicates
This commit is contained in:
parent
dcd546b7cb
commit
797df0a2d7
2 changed files with 12 additions and 7 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue