From 4e32d694528591ef78eeaf20fcf6ef0ba8ce67b1 Mon Sep 17 00:00:00 2001 From: Mabuchi Nyirenda <79569415+BuchiNy@users.noreply.github.com> Date: Wed, 21 May 2025 12:08:26 +0200 Subject: [PATCH] search filter changed to All when users clears texts and starts again --- .../ui/fragments/GlobalSearchFragment.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/java/org/apphatchery/gatbreferenceguide/ui/fragments/GlobalSearchFragment.kt b/app/src/main/java/org/apphatchery/gatbreferenceguide/ui/fragments/GlobalSearchFragment.kt index d7029a9..5738e8a 100644 --- a/app/src/main/java/org/apphatchery/gatbreferenceguide/ui/fragments/GlobalSearchFragment.kt +++ b/app/src/main/java/org/apphatchery/gatbreferenceguide/ui/fragments/GlobalSearchFragment.kt @@ -432,6 +432,12 @@ class GlobalSearchFragment : BaseFragment(R.layout.fragment_global_search) { searchJob?.cancel() val trimmedText = text.trim() viewModel.searchQuery.value = text + + if(trimmedText.isBlank()){ + currentTab = 0 + bind.tabLayout.getTabAt(0)?.select() + } + with(bind.searchItemCount) { visibility = if (trimmedText.isBlank()) View.GONE else View.VISIBLE } @@ -445,6 +451,10 @@ class GlobalSearchFragment : BaseFragment(R.layout.fragment_global_search) { suggestedContent.visibility = if (isBlank) View.VISIBLE else View.GONE tabLayout.visibility = if (isBlank) View.GONE else View.VISIBLE tabLayoutContainer.visibility = if (isBlank) View.GONE else View.VISIBLE + + if(isBlank){ + recyclerview.scrollToPosition(0) + } } }