[Android] Force collapsing the search view when leaving the activity
Nicolas Pomepuy
git at videolan.org
Tue Apr 5 09:25:45 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Apr 5 09:26:42 2022 +0200| [875b886f081a6f9fd2b68765618db69d0b660d03] | committer: Nicolas Pomepuy
Force collapsing the search view when leaving the activity
Fixes #2448
> https://code.videolan.org/videolan/vlc-android/commit/875b886f081a6f9fd2b68765618db69d0b660d03
---
.../vlc-android/src/org/videolan/vlc/gui/ContentActivity.kt | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/ContentActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/ContentActivity.kt
index ebdacecb3..6a0ea4142 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/ContentActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/ContentActivity.kt
@@ -50,6 +50,7 @@ import org.videolan.vlc.interfaces.Filterable
open class ContentActivity : AudioPlayerContainerActivity(), SearchView.OnQueryTextListener, MenuItem.OnActionExpandListener {
private lateinit var searchView: SearchView
+ private lateinit var searchItem: MenuItem
private var showRenderers = !AndroidDevices.isChromeBook && !RendererDelegate.renderers.value.isNullOrEmpty()
private val searchHiddenMenuItem = ArrayList<MenuItem>()
open fun hideRenderers() = false
@@ -77,6 +78,11 @@ open class ContentActivity : AudioPlayerContainerActivity(), SearchView.OnQueryT
UiTools.setOnDragListener(this)
}
+ override fun onPause() {
+ super.onPause()
+ searchItem.collapseActionView()
+ }
+
override fun onCreateOptionsMenu(menu: Menu): Boolean {
val current = currentFragment
super.onCreateOptionsMenu(menu)
@@ -88,7 +94,7 @@ open class ContentActivity : AudioPlayerContainerActivity(), SearchView.OnQueryT
}
if (current is Filterable) {
val filterable = current as Filterable?
- val searchItem = menu.findItem(R.id.ml_menu_filter)
+ searchItem = menu.findItem(R.id.ml_menu_filter)
searchView = searchItem.actionView as SearchView
searchView.queryHint = getString(R.string.search_in_list_hint)
searchView.setOnQueryTextListener(this)
More information about the Android
mailing list