show Search on all tabs

This commit is contained in:
tibbi 2020-11-04 15:57:30 +01:00
parent d88ea06a35
commit e500e02131
5 changed files with 22 additions and 4 deletions

View File

@ -101,8 +101,6 @@ class MainActivity : SimpleActivity() {
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu, menu)
menu.findItem(R.id.search).isVisible = viewpager.currentItem == 0
setupSearch(menu)
updateMenuItemColors(menu)
return true

View File

@ -153,12 +153,12 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
})
}
fun onSearchClosed() {
override fun onSearchClosed() {
(fragment_list.adapter as? ContactsAdapter)?.updateItems(allContacts)
setupLetterFastscroller(allContacts)
}
fun onSearchQueryChanged(text: String) {
override fun onSearchQueryChanged(text: String) {
val contacts = allContacts.filter {
it.name.contains(text, true) || it.doesContainPhoneNumber(text)
}.toMutableList() as ArrayList<SimpleContact>

View File

@ -111,4 +111,12 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
}
})
}
override fun onSearchClosed() {
}
override fun onSearchQueryChanged(text: String) {
}
}

View File

@ -34,4 +34,8 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
abstract fun textColorChanged(color: Int)
abstract fun primaryColorChanged(color: Int)
abstract fun onSearchClosed()
abstract fun onSearchQueryChanged(text: String)
}

View File

@ -109,4 +109,12 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
}
}
}
override fun onSearchClosed() {
}
override fun onSearchQueryChanged(text: String) {
}
}