mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-01-07 18:10:31 +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
|
// stuff for the search in the topBar
|
||||||
val searchItem = menu.findItem(R.id.action_search)
|
val searchItem = menu.findItem(R.id.action_search)
|
||||||
searchView = searchItem.actionView as SearchView
|
searchView = searchItem.actionView as SearchView
|
||||||
searchView.maxWidth = Integer.MAX_VALUE
|
|
||||||
|
|
||||||
val searchViewModel = ViewModelProvider(this)[SearchViewModel::class.java]
|
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 {
|
searchView.setOnCloseListener {
|
||||||
if (navController.currentDestination?.id == R.id.searchFragment) {
|
if (navController.currentDestination?.id == R.id.searchFragment) {
|
||||||
searchViewModel.setQuery(null)
|
searchViewModel.setQuery(null)
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
android:icon="@drawable/ic_search"
|
android:icon="@drawable/ic_search"
|
||||||
android:title="@string/search_hint"
|
android:title="@string/search_hint"
|
||||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||||
app:showAsAction="ifRoom" />
|
app:showAsAction="ifRoom|collapseActionView" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_settings"
|
android:id="@+id/action_settings"
|
||||||
|
Loading…
Reference in New Issue
Block a user