mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
at deleting a contact delete all duplicates too
This commit is contained in:
@ -477,7 +477,7 @@ class ViewContactActivity : ContactActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addContactSource(contact!!)
|
addContactSource(contact!!)
|
||||||
ContactsHelper(this).getDuplicatesOfContact(contact!!) { contacts ->
|
ContactsHelper(this).getDuplicatesOfContact(contact!!, false) { contacts ->
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
contacts.forEach {
|
contacts.forEach {
|
||||||
addContactSource(it)
|
addContactSource(it)
|
||||||
|
@ -1524,13 +1524,9 @@ class ContactsHelper(val context: Context) {
|
|||||||
LocalContactsHelper(context).toggleFavorites(localContacts, addToFavorites)
|
LocalContactsHelper(context).toggleFavorites(localContacts, addToFavorites)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteContact(contact: Contact) {
|
fun deleteContact(originalContact: Contact) {
|
||||||
ensureBackgroundThread {
|
getDuplicatesOfContact(originalContact, true) { contacts ->
|
||||||
if (contact.isPrivate()) {
|
deleteContacts(contacts)
|
||||||
context.contactsDB.deleteContactId(contact.id)
|
|
||||||
} else {
|
|
||||||
deleteContacts(arrayListOf(contact))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1562,10 +1558,13 @@ class ContactsHelper(val context: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getDuplicatesOfContact(contact: Contact, callback: (ArrayList<Contact>) -> Unit) {
|
fun getDuplicatesOfContact(contact: Contact, addOriginal: Boolean, callback: (ArrayList<Contact>) -> Unit) {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
getContacts { contacts ->
|
getContacts { contacts ->
|
||||||
val duplicates = contacts.filter { it.id != contact.id && it.getHashToCompare() == contact.getHashToCompare() }.toMutableList() as ArrayList<Contact>
|
val duplicates = contacts.filter { it.id != contact.id && it.getHashToCompare() == contact.getHashToCompare() }.toMutableList() as ArrayList<Contact>
|
||||||
|
if (addOriginal) {
|
||||||
|
duplicates.add(contact)
|
||||||
|
}
|
||||||
callback(duplicates)
|
callback(duplicates)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user