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 45aaa7cfdf8de3af5d41cbe4daf85310d81f59e2..0554904c4e03dd781039287504f177679e98e98e 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 } @@ -176,6 +175,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) @@ -367,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) { @@ -440,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/java/foundation/e/apps/ui/search/SearchViewModel.kt b/app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt index 2f8e171c0115a9870ce97478fda7819a0cc56fdd..9d89d8f31ae6f51d828cf8944ea1dbac5b991ac6 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() } + } } diff --git a/app/src/main/res/layout/fragment_search.xml b/app/src/main/res/layout/fragment_search.xml index 49dc21378d9a0d4a6f6fdae8de472590c4a26412..c0aa781ebd8950237a62802260ab142f380baa28 100644 --- a/app/src/main/res/layout/fragment_search.xml +++ b/app/src/main/res/layout/fragment_search.xml @@ -95,7 +95,7 @@