properly update view visibility after closing search

This commit is contained in:
tibbi 2018-08-12 19:26:55 +02:00
parent fd775bf050
commit 9ab6f9d7df
1 changed files with 9 additions and 4 deletions

View File

@ -186,10 +186,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
} }
private fun setupContactsFavoritesAdapter(contacts: ArrayList<Contact>) { private fun setupContactsFavoritesAdapter(contacts: ArrayList<Contact>) {
fragment_placeholder_2.beVisibleIf(contacts.isEmpty()) setupViewVisibility(contacts)
fragment_placeholder.beVisibleIf(contacts.isEmpty())
fragment_list.beVisibleIf(contacts.isNotEmpty())
val currAdapter = fragment_list.adapter val currAdapter = fragment_list.adapter
if (currAdapter == null || forceListRedraw) { if (currAdapter == null || forceListRedraw) {
forceListRedraw = false forceListRedraw = false
@ -271,6 +268,8 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
fun onSearchClosed() { fun onSearchClosed() {
(fragment_list.adapter as? ContactsAdapter)?.updateItems(contactsIgnoringSearch) (fragment_list.adapter as? ContactsAdapter)?.updateItems(contactsIgnoringSearch)
setupViewVisibility(contactsIgnoringSearch)
if (this is FavoritesFragment) { if (this is FavoritesFragment) {
fragment_placeholder.text = activity?.getString(R.string.no_favorites) fragment_placeholder.text = activity?.getString(R.string.no_favorites)
} }
@ -283,6 +282,12 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
fragment_placeholder_2.setTextColor(context.getAdjustedPrimaryColor()) fragment_placeholder_2.setTextColor(context.getAdjustedPrimaryColor())
} }
private fun setupViewVisibility(contacts: ArrayList<Contact>) {
fragment_placeholder_2.beVisibleIf(contacts.isEmpty())
fragment_placeholder.beVisibleIf(contacts.isEmpty())
fragment_list.beVisibleIf(contacts.isNotEmpty())
}
abstract fun fabClicked() abstract fun fabClicked()
abstract fun placeholderClicked() abstract fun placeholderClicked()