delete contacts from all sources at deleting from the main screen
This commit is contained in:
parent
415ef33c09
commit
3d24a84248
|
@ -176,16 +176,23 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||
val positions = getSelectedItemPositions()
|
||||
contactItems.removeAll(contactsToRemove)
|
||||
|
||||
ensureBackgroundThread {
|
||||
ContactsHelper(activity).deleteContacts(contactsToRemove)
|
||||
ContactsHelper(activity).getContacts { allContacts ->
|
||||
ensureBackgroundThread {
|
||||
contactsToRemove.forEach {
|
||||
val contactToRemove = it
|
||||
val duplicates = allContacts.filter { it.id != contactToRemove.id && it.getHashToCompare() == contactToRemove.getHashToCompare() }.toMutableList() as ArrayList<Contact>
|
||||
duplicates.add(contactToRemove)
|
||||
ContactsHelper(activity).deleteContacts(duplicates)
|
||||
}
|
||||
|
||||
activity.runOnUiThread {
|
||||
if (contactItems.isEmpty()) {
|
||||
refreshListener?.refreshContacts(ALL_TABS_MASK)
|
||||
finishActMode()
|
||||
} else {
|
||||
removeSelectedItems(positions)
|
||||
refreshListener?.refreshContacts(CONTACTS_TAB_MASK or FAVORITES_TAB_MASK)
|
||||
activity.runOnUiThread {
|
||||
if (contactItems.isEmpty()) {
|
||||
refreshListener?.refreshContacts(ALL_TABS_MASK)
|
||||
finishActMode()
|
||||
} else {
|
||||
removeSelectedItems(positions)
|
||||
refreshListener?.refreshContacts(CONTACTS_TAB_MASK or FAVORITES_TAB_MASK)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue