mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
add back button to search
This commit is contained in:
parent
30cec4ab7c
commit
308060cea6
@ -214,7 +214,6 @@ class MainActivity : BaseActivity() {
|
||||
// stuff for the search in the topBar
|
||||
val searchItem = menu.findItem(R.id.action_search)
|
||||
searchView = searchItem.actionView as SearchView
|
||||
searchView.maxWidth = Integer.MAX_VALUE
|
||||
|
||||
val searchViewModel = ViewModelProvider(this)[SearchViewModel::class.java]
|
||||
|
||||
@ -245,6 +244,22 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
})
|
||||
|
||||
searchItem.setOnActionExpandListener(
|
||||
object : MenuItem.OnActionExpandListener {
|
||||
override fun onMenuItemActionExpand(p0: MenuItem?): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onMenuItemActionCollapse(p0: MenuItem?): Boolean {
|
||||
val currentFragmentId = navController.currentDestination?.id
|
||||
if (currentFragmentId == R.id.searchFragment || currentFragmentId == R.id.searchResultFragment) {
|
||||
onBackPressed()
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
searchView.setOnCloseListener {
|
||||
if (navController.currentDestination?.id == R.id.searchFragment) {
|
||||
searchViewModel.setQuery(null)
|
||||
|
@ -8,7 +8,7 @@
|
||||
android:icon="@drawable/ic_search"
|
||||
android:title="@string/search_hint"
|
||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||
app:showAsAction="ifRoom" />
|
||||
app:showAsAction="ifRoom|collapseActionView" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
|
Loading…
Reference in New Issue
Block a user