From cc7a2ba7693cb6c45cafd14f642a10e4c6ada42c Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Thu, 18 Apr 2024 21:32:06 +0530 Subject: [PATCH 1/2] ignore empty results --- .../java/foundation/e/apps/ui/search/SearchFragment.kt | 2 ++ .../java/foundation/e/apps/ui/search/SearchViewModel.kt | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt b/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt index 45aaa7cfd..89d12c359 100644 --- a/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt @@ -176,6 +176,8 @@ class SearchFragment : searchViewModel.searchResult.observe(viewLifecycleOwner) { if (it.data?.first.isNullOrEmpty() && it.data?.second == false) { noAppsFoundLayout?.visibility = View.VISIBLE + } else if (searchViewModel.shouldIgnoreResults()) { + return@observe } else { listAdapter?.let { adapter -> observeDownloadList(adapter) diff --git a/app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt b/app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt index 2f8e171c0..9d89d8f31 100644 --- a/app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt +++ b/app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt @@ -319,4 +319,13 @@ class SearchViewModel @Inject constructor( loadMore(searchText, autoTriggered = true) } } + + fun shouldIgnoreResults(): Boolean { + val appsList = _searchResult.value?.data?.first + + if (appsList.isNullOrEmpty()) return true + + val appPackageNames = appsList.map { it.package_name } + return appPackageNames.all { it.isBlank() } + } } -- GitLab From 0aefc009dc5d8bdb4eecfdd1e40dffd977b6e740 Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Fri, 19 Apr 2024 00:32:05 +0530 Subject: [PATCH 2/2] fix loading ui glitch --- .../foundation/e/apps/ui/search/SearchFragment.kt | 11 ++++------- app/src/main/res/layout/fragment_search.xml | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt b/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt index 89d12c359..0554904c4 100644 --- a/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt +++ b/app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt @@ -132,7 +132,6 @@ class SearchFragment : authObjects.observe(viewLifecycleOwner) { val currentQuery = searchView?.query?.toString() ?: "" if (it == null || shouldIgnore(it, currentQuery)) { - showData() return@observe } @@ -369,13 +368,13 @@ class SearchFragment : } override fun showLoadingUI() { - binding.shimmerLayout.startShimmer() - binding.shimmerLayout.visibility = View.VISIBLE + shimmerLayout?.visibility = View.VISIBLE + shimmerLayout?.startShimmer() } override fun stopLoadingUI() { - binding.shimmerLayout.stopShimmer() - binding.shimmerLayout.visibility = View.GONE + shimmerLayout?.stopShimmer() + shimmerLayout?.visibility = View.GONE } private fun updateProgressOfInstallingApps(downloadProgress: DownloadProgress) { @@ -442,8 +441,6 @@ class SearchFragment : view?.requestFocus() searchHintLayout?.visibility = View.GONE - shimmerLayout?.visibility = View.VISIBLE - noAppsFoundLayout?.visibility = View.GONE /* * Set the search text and call for network result. */ diff --git a/app/src/main/res/layout/fragment_search.xml b/app/src/main/res/layout/fragment_search.xml index 49dc21378..c0aa781eb 100644 --- a/app/src/main/res/layout/fragment_search.xml +++ b/app/src/main/res/layout/fragment_search.xml @@ -95,7 +95,7 @@ -- GitLab