mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
properly show the placeholders if all contacts are removed
This commit is contained in:
@ -186,7 +186,8 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||||||
startAboutActivity(R.string.app_name, LICENSE_KOTLIN or LICENSE_MULTISELECT or LICENSE_JODA or LICENSE_GLIDE, BuildConfig.VERSION_NAME)
|
startAboutActivity(R.string.app_name, LICENSE_KOTLIN or LICENSE_MULTISELECT or LICENSE_JODA or LICENSE_GLIDE, BuildConfig.VERSION_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun refreshItems() {
|
override fun refreshContacts() {
|
||||||
|
contacts_fragment.initContacts()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun refreshFavorites() {
|
override fun refreshFavorites() {
|
||||||
|
@ -115,8 +115,14 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList<Co
|
|||||||
contactsToRemove.add(contactItems[it])
|
contactsToRemove.add(contactItems[it])
|
||||||
}
|
}
|
||||||
contactItems.removeAll(contactsToRemove)
|
contactItems.removeAll(contactsToRemove)
|
||||||
|
|
||||||
ContactsHelper(activity).deleteContacts(contactsToRemove)
|
ContactsHelper(activity).deleteContacts(contactsToRemove)
|
||||||
removeSelectedItems()
|
if (contactItems.isEmpty()) {
|
||||||
|
listener?.refreshContacts()
|
||||||
|
finishActMode()
|
||||||
|
} else {
|
||||||
|
removeSelectedItems()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun removeFavorites() {
|
private fun removeFavorites() {
|
||||||
@ -133,7 +139,12 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList<Co
|
|||||||
val favoriteIDsToRemove = HashSet<String>()
|
val favoriteIDsToRemove = HashSet<String>()
|
||||||
favoritesToRemove.mapTo(favoriteIDsToRemove, { it.id.toString() })
|
favoritesToRemove.mapTo(favoriteIDsToRemove, { it.id.toString() })
|
||||||
activity.config.removeFavorites(favoriteIDsToRemove)
|
activity.config.removeFavorites(favoriteIDsToRemove)
|
||||||
removeSelectedItems()
|
if (contactItems.isEmpty()) {
|
||||||
|
listener?.refreshFavorites()
|
||||||
|
finishActMode()
|
||||||
|
} else {
|
||||||
|
removeSelectedItems()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addToFavorites() {
|
private fun addToFavorites() {
|
||||||
|
@ -24,6 +24,7 @@ import kotlinx.android.synthetic.main.fragment_layout.view.*
|
|||||||
|
|
||||||
abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) : CoordinatorLayout(context, attributeSet) {
|
abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) : CoordinatorLayout(context, attributeSet) {
|
||||||
var activity: MainActivity? = null
|
var activity: MainActivity? = null
|
||||||
|
var lastHashCode = 0
|
||||||
lateinit var config: Config
|
lateinit var config: Config
|
||||||
|
|
||||||
fun setupFragment(activity: MainActivity) {
|
fun setupFragment(activity: MainActivity) {
|
||||||
@ -101,7 +102,8 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contacts.hashCode() != (fragment_list.adapter as? ContactsAdapter)?.contactItems?.hashCode()) {
|
if (contacts.hashCode() != lastHashCode) {
|
||||||
|
lastHashCode = contacts.hashCode()
|
||||||
activity!!.runOnUiThread {
|
activity!!.runOnUiThread {
|
||||||
setupContacts(contacts)
|
setupContacts(contacts)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.simplemobiletools.interfaces
|
package com.simplemobiletools.interfaces
|
||||||
|
|
||||||
interface RefreshContactsListener {
|
interface RefreshContactsListener {
|
||||||
fun refreshItems()
|
fun refreshContacts()
|
||||||
|
|
||||||
fun refreshFavorites()
|
fun refreshFavorites()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user