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