tweak duplicate contact source adding a bit

This commit is contained in:
tibbi 2019-09-14 22:38:20 +02:00
parent a35e0513be
commit 2dc2fe01df

View File

@ -482,19 +482,29 @@ class ViewContactActivity : ContactActivity() {
private fun checkDuplicateContacts() { private fun checkDuplicateContacts() {
ContactsHelper(this).getDuplicatesOfContact(contact!!, false) { contacts -> ContactsHelper(this).getDuplicatesOfContact(contact!!, false) { contacts ->
val currContactSources = contacts.map { it.source } ensureBackgroundThread {
runOnUiThread { val duplicates = ArrayList<Contact>()
if (currContactSources.toString() != shownContactSources.toString()) { contacts.forEach {
for (i in (contact_sources_holder.childCount - 1) downTo 1) { val duplicate = ContactsHelper(this).getContactWithId(it.id, it.isPrivate())
contact_sources_holder.removeView(contact_sources_holder.getChildAt(i)) if (duplicate != null) {
shownContactSources.clear() duplicates.add(duplicate)
} }
} }
if (shownContactSources.isEmpty()) { val currContactSources = duplicates.map { it.source }
contacts.forEach { runOnUiThread {
addContactSource(it) if (currContactSources.toString() != shownContactSources.toString()) {
shownContactSources.add(it.source) for (i in (contact_sources_holder.childCount - 1) downTo 1) {
contact_sources_holder.removeView(contact_sources_holder.getChildAt(i))
shownContactSources.clear()
}
}
if (shownContactSources.isEmpty()) {
duplicates.forEach {
addContactSource(it)
shownContactSources.add(it.source)
}
} }
} }
} }