From f45e1aad24249e2d2f0a47e95ce52eb690983a62 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 28 Jul 2022 17:09:42 +0200 Subject: [PATCH] fix search behavior --- .../com/github/libretube/fragments/SearchFragment.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt b/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt index 4012ee830..0e6049259 100644 --- a/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/SearchFragment.kt @@ -66,7 +66,7 @@ class SearchFragment : Fragment() { binding.clearSearchImageView.setOnClickListener { binding.autoCompleteTextView.text.clear() - binding.historyRecycler.visibility = View.GONE + binding.historyRecycler.adapter = null showHistory() } @@ -129,7 +129,7 @@ class SearchFragment : Fragment() { } override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { - if (s!! != "") { + if (s.toString() != "") { binding.searchRecycler.adapter = null binding.searchRecycler.viewTreeObserver @@ -144,14 +144,15 @@ class SearchFragment : Fragment() { override fun afterTextChanged(s: Editable?) { if (s!!.isEmpty()) { + binding.historyRecycler.adapter = null showHistory() } } }) binding.autoCompleteTextView.setOnEditorActionListener( - OnEditorActionListener { _, actionId, _ -> - if (actionId == EditorInfo.IME_ACTION_SEARCH) { - view?.let { context?.hideKeyboard(it) } + OnEditorActionListener { textView, actionId, _ -> + if (actionId == EditorInfo.IME_ACTION_SEARCH && textView.text.toString() != "") { + view.let { context?.hideKeyboard(it) } binding.searchRecycler.visibility = VISIBLE binding.historyRecycler.visibility = GONE fetchSearch(binding.autoCompleteTextView.text.toString())