mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
tweak duplicate contact source adding a bit
This commit is contained in:
parent
a35e0513be
commit
2dc2fe01df
@ -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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user