mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-02-17 03:51:03 +01:00
properly show the placeholders if all contacts are removed
This commit is contained in:
parent
4184abff80
commit
bc0b4a9622
@ -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)
|
||||
}
|
||||
|
||||
override fun refreshItems() {
|
||||
override fun refreshContacts() {
|
||||
contacts_fragment.initContacts()
|
||||
}
|
||||
|
||||
override fun refreshFavorites() {
|
||||
|
@ -115,8 +115,14 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList<Co
|
||||
contactsToRemove.add(contactItems[it])
|
||||
}
|
||||
contactItems.removeAll(contactsToRemove)
|
||||
|
||||
ContactsHelper(activity).deleteContacts(contactsToRemove)
|
||||
removeSelectedItems()
|
||||
if (contactItems.isEmpty()) {
|
||||
listener?.refreshContacts()
|
||||
finishActMode()
|
||||
} else {
|
||||
removeSelectedItems()
|
||||
}
|
||||
}
|
||||
|
||||
private fun removeFavorites() {
|
||||
@ -133,7 +139,12 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList<Co
|
||||
val favoriteIDsToRemove = HashSet<String>()
|
||||
favoritesToRemove.mapTo(favoriteIDsToRemove, { it.id.toString() })
|
||||
activity.config.removeFavorites(favoriteIDsToRemove)
|
||||
removeSelectedItems()
|
||||
if (contactItems.isEmpty()) {
|
||||
listener?.refreshFavorites()
|
||||
finishActMode()
|
||||
} else {
|
||||
removeSelectedItems()
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
var activity: MainActivity? = null
|
||||
var lastHashCode = 0
|
||||
lateinit var config: Config
|
||||
|
||||
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 {
|
||||
setupContacts(contacts)
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.simplemobiletools.interfaces
|
||||
|
||||
interface RefreshContactsListener {
|
||||
fun refreshItems()
|
||||
fun refreshContacts()
|
||||
|
||||
fun refreshFavorites()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user