remove the favorite item if needed at removing a contact
This commit is contained in:
parent
bc0b4a9622
commit
ad46e83284
|
@ -3,7 +3,6 @@ package com.simplemobiletools.contacts.activities
|
|||
import android.content.Intent
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
|
@ -188,6 +187,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||
|
||||
override fun refreshContacts() {
|
||||
contacts_fragment.initContacts()
|
||||
favorites_fragment.initContacts()
|
||||
}
|
||||
|
||||
override fun refreshFavorites() {
|
||||
|
|
|
@ -122,6 +122,7 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList<Co
|
|||
finishActMode()
|
||||
} else {
|
||||
removeSelectedItems()
|
||||
listener?.refreshFavorites()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -518,6 +518,7 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
|||
|
||||
fun deleteContacts(contacts: ArrayList<Contact>) {
|
||||
try {
|
||||
val contactIDs = HashSet<String>()
|
||||
val operations = ArrayList<ContentProviderOperation>()
|
||||
val selection = "${ContactsContract.Data.RAW_CONTACT_ID} = ?"
|
||||
contacts.forEach {
|
||||
|
@ -526,9 +527,11 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
|||
withSelection(selection, selectionArgs)
|
||||
operations.add(this.build())
|
||||
}
|
||||
contactIDs.add(it.id.toString())
|
||||
}
|
||||
|
||||
activity.contentResolver.applyBatch(ContactsContract.AUTHORITY, operations)
|
||||
activity.config.removeFavorites(contactIDs)
|
||||
} catch (e: Exception) {
|
||||
activity.showErrorToast(e)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue