优化发现筛选逻辑
This commit is contained in:
@@ -74,6 +74,7 @@ class ExploreFragment() : VMBaseFragment<ExploreViewModel>(R.layout.fragment_exp
|
|||||||
private val groups = linkedSetOf<String>()
|
private val groups = linkedSetOf<String>()
|
||||||
private var exploreFlowJob: Job? = null
|
private var exploreFlowJob: Job? = null
|
||||||
private var groupsMenu: SubMenu? = null
|
private var groupsMenu: SubMenu? = null
|
||||||
|
private var currentSearchKey: String? = null
|
||||||
|
|
||||||
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
setSupportToolbar(binding.topBar)
|
setSupportToolbar(binding.topBar)
|
||||||
@@ -89,8 +90,8 @@ class ExploreFragment() : VMBaseFragment<ExploreViewModel>(R.layout.fragment_exp
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initSearchView() {
|
private fun initSearchView() {
|
||||||
|
searchView.setupWithSearchBar(searchBar)
|
||||||
searchView.hint = getString(R.string.screen_find)
|
searchView.hint = getString(R.string.screen_find)
|
||||||
|
|
||||||
searchBar.setOnClickListener {
|
searchBar.setOnClickListener {
|
||||||
searchView.show()
|
searchView.show()
|
||||||
if (searchView.text.isEmpty()) {
|
if (searchView.text.isEmpty()) {
|
||||||
@@ -98,6 +99,12 @@ class ExploreFragment() : VMBaseFragment<ExploreViewModel>(R.layout.fragment_exp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
searchView.addTransitionListener { _, _, newState ->
|
||||||
|
if (newState == SearchView.TransitionState.HIDDEN) {
|
||||||
|
searchBar.setText(searchView.text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
searchView.editText.setOnEditorActionListener { _, actionId, _ ->
|
searchView.editText.setOnEditorActionListener { _, actionId, _ ->
|
||||||
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
||||||
val query = searchView.text.toString()
|
val query = searchView.text.toString()
|
||||||
@@ -114,7 +121,6 @@ class ExploreFragment() : VMBaseFragment<ExploreViewModel>(R.layout.fragment_exp
|
|||||||
searchView.editText.doAfterTextChanged { editable ->
|
searchView.editText.doAfterTextChanged { editable ->
|
||||||
editable?.let {
|
editable?.let {
|
||||||
upExploreData(it.toString())
|
upExploreData(it.toString())
|
||||||
|
|
||||||
if (it.isEmpty()) {
|
if (it.isEmpty()) {
|
||||||
searchBar.hint = getString(R.string.screen_find)
|
searchBar.hint = getString(R.string.screen_find)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user