Fixed the searchView being collapsed after searching through it
Now they have their state synced with viewModel to allow continuity
This commit is contained in:
parent
7e5f2822ae
commit
b77c590910
@ -25,8 +25,22 @@ class MagiskHideFragment : MagiskFragment<HideViewModel, FragmentMagiskHideBindi
|
|||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
inflater.inflate(R.menu.menu_magiskhide, menu)
|
inflater.inflate(R.menu.menu_magiskhide, menu)
|
||||||
menu.apply {
|
menu.apply {
|
||||||
(findItem(R.id.app_search).actionView as? SearchView)
|
val query = viewModel.query.value
|
||||||
?.setOnQueryTextListener(this@MagiskHideFragment)
|
val searchItem = menu.findItem(R.id.app_search)
|
||||||
|
val searchView = searchItem.actionView as? SearchView
|
||||||
|
|
||||||
|
searchView?.run {
|
||||||
|
setOnQueryTextListener(this@MagiskHideFragment)
|
||||||
|
setQuery(query, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query.isNotBlank()) {
|
||||||
|
searchItem.expandActionView()
|
||||||
|
searchView?.isIconified = false
|
||||||
|
} else {
|
||||||
|
searchItem.collapseActionView()
|
||||||
|
searchView?.isIconified = true
|
||||||
|
}
|
||||||
|
|
||||||
val showSystem = Config.showSystemApp
|
val showSystem = Config.showSystemApp
|
||||||
|
|
||||||
|
@ -43,8 +43,23 @@ class ReposFragment : MagiskFragment<ModuleViewModel, FragmentReposBinding>(),
|
|||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
inflater.inflate(R.menu.menu_repo, menu)
|
inflater.inflate(R.menu.menu_repo, menu)
|
||||||
(menu.findItem(R.id.repo_search).actionView as? SearchView)
|
|
||||||
?.setOnQueryTextListener(this)
|
val query = viewModel.query.value
|
||||||
|
val searchItem = menu.findItem(R.id.repo_search)
|
||||||
|
val searchView = searchItem.actionView as? SearchView
|
||||||
|
|
||||||
|
searchView?.run {
|
||||||
|
setOnQueryTextListener(this@ReposFragment)
|
||||||
|
setQuery(query, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query.isNotBlank()) {
|
||||||
|
searchItem.expandActionView()
|
||||||
|
searchView?.isIconified = false
|
||||||
|
} else {
|
||||||
|
searchItem.collapseActionView()
|
||||||
|
searchView?.isIconified = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
Loading…
Reference in New Issue
Block a user