properly update view visibility after closing search
This commit is contained in:
parent
fd775bf050
commit
9ab6f9d7df
|
@ -186,10 +186,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||
}
|
||||
|
||||
private fun setupContactsFavoritesAdapter(contacts: ArrayList<Contact>) {
|
||||
fragment_placeholder_2.beVisibleIf(contacts.isEmpty())
|
||||
fragment_placeholder.beVisibleIf(contacts.isEmpty())
|
||||
fragment_list.beVisibleIf(contacts.isNotEmpty())
|
||||
|
||||
setupViewVisibility(contacts)
|
||||
val currAdapter = fragment_list.adapter
|
||||
if (currAdapter == null || forceListRedraw) {
|
||||
forceListRedraw = false
|
||||
|
@ -271,6 +268,8 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||
|
||||
fun onSearchClosed() {
|
||||
(fragment_list.adapter as? ContactsAdapter)?.updateItems(contactsIgnoringSearch)
|
||||
setupViewVisibility(contactsIgnoringSearch)
|
||||
|
||||
if (this is FavoritesFragment) {
|
||||
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())
|
||||
}
|
||||
|
||||
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 placeholderClicked()
|
||||
|
|
Loading…
Reference in New Issue