mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-01-24 21:01:47 +01:00
avoid showing the same contact sources multiple times
This commit is contained in:
parent
c1db2701d8
commit
92288db197
@ -114,16 +114,6 @@ class ViewContactActivity : ContactActivity() {
|
||||
if (contactId != 0 && !wasLookupKeyUsed) {
|
||||
contact = ContactsHelper(this).getContactWithId(contactId, intent.getBooleanExtra(IS_PRIVATE, false))
|
||||
|
||||
if (contact != null) {
|
||||
ContactsHelper(this).getContacts { contacts ->
|
||||
contacts.forEach {
|
||||
if (it.id != contact!!.id && it.getHashToCompare() == contact!!.getHashToCompare()) {
|
||||
addContactSource(it.source)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (contact == null) {
|
||||
if (!wasEditLaunched) {
|
||||
toast(R.string.unknown_error_occurred)
|
||||
@ -212,7 +202,7 @@ class ViewContactActivity : ContactActivity() {
|
||||
setupOrganization()
|
||||
setupWebsites()
|
||||
setupGroups()
|
||||
addContactSource(contact!!.source)
|
||||
addContactSources()
|
||||
}
|
||||
|
||||
private fun editContact() {
|
||||
@ -480,6 +470,22 @@ class ViewContactActivity : ContactActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun addContactSources() {
|
||||
contact_sources_holder.removeAllViews()
|
||||
addContactSource(contact!!.source)
|
||||
ensureBackgroundThread {
|
||||
ContactsHelper(this).getContacts { contacts ->
|
||||
contacts.forEach {
|
||||
if (it.id != contact!!.id && it.getHashToCompare() == contact!!.getHashToCompare()) {
|
||||
runOnUiThread {
|
||||
addContactSource(it.source)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun addContactSource(source: String) {
|
||||
if (showFields and SHOW_CONTACT_SOURCE_FIELD != 0) {
|
||||
layoutInflater.inflate(R.layout.item_view_contact_source, contact_sources_holder, false).apply {
|
||||
|
Loading…
Reference in New Issue
Block a user