mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-02-18 12:30:38 +01:00
adding a helper function for retrieving contact duplicates
This commit is contained in:
parent
dcd546b7cb
commit
797df0a2d7
@ -477,14 +477,10 @@ class ViewContactActivity : ContactActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addContactSource(contact!!)
|
addContactSource(contact!!)
|
||||||
ensureBackgroundThread {
|
ContactsHelper(this).getDuplicatesOfContact(contact!!) { contacts ->
|
||||||
ContactsHelper(this).getContacts { contacts ->
|
runOnUiThread {
|
||||||
contacts.forEach {
|
contacts.forEach {
|
||||||
if (it.id != contact!!.id && it.getHashToCompare() == contact!!.getHashToCompare()) {
|
addContactSource(it)
|
||||||
runOnUiThread {
|
|
||||||
addContactSource(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1561,4 +1561,13 @@ class ContactsHelper(val context: Context) {
|
|||||||
context.showErrorToast(e)
|
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…
x
Reference in New Issue
Block a user