Loading app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt +6 −7 Original line number Original line Diff line number Diff line Loading @@ -132,7 +132,6 @@ class SearchFragment : authObjects.observe(viewLifecycleOwner) { authObjects.observe(viewLifecycleOwner) { val currentQuery = searchView?.query?.toString() ?: "" val currentQuery = searchView?.query?.toString() ?: "" if (it == null || shouldIgnore(it, currentQuery)) { if (it == null || shouldIgnore(it, currentQuery)) { showData() return@observe return@observe } } Loading Loading @@ -176,6 +175,8 @@ class SearchFragment : searchViewModel.searchResult.observe(viewLifecycleOwner) { searchViewModel.searchResult.observe(viewLifecycleOwner) { if (it.data?.first.isNullOrEmpty() && it.data?.second == false) { if (it.data?.first.isNullOrEmpty() && it.data?.second == false) { noAppsFoundLayout?.visibility = View.VISIBLE noAppsFoundLayout?.visibility = View.VISIBLE } else if (searchViewModel.shouldIgnoreResults()) { return@observe } else { } else { listAdapter?.let { adapter -> listAdapter?.let { adapter -> observeDownloadList(adapter) observeDownloadList(adapter) Loading Loading @@ -367,13 +368,13 @@ class SearchFragment : } } override fun showLoadingUI() { override fun showLoadingUI() { binding.shimmerLayout.startShimmer() shimmerLayout?.visibility = View.VISIBLE binding.shimmerLayout.visibility = View.VISIBLE shimmerLayout?.startShimmer() } } override fun stopLoadingUI() { override fun stopLoadingUI() { binding.shimmerLayout.stopShimmer() shimmerLayout?.stopShimmer() binding.shimmerLayout.visibility = View.GONE shimmerLayout?.visibility = View.GONE } } private fun updateProgressOfInstallingApps(downloadProgress: DownloadProgress) { private fun updateProgressOfInstallingApps(downloadProgress: DownloadProgress) { Loading Loading @@ -440,8 +441,6 @@ class SearchFragment : view?.requestFocus() view?.requestFocus() searchHintLayout?.visibility = View.GONE searchHintLayout?.visibility = View.GONE shimmerLayout?.visibility = View.VISIBLE noAppsFoundLayout?.visibility = View.GONE /* /* * Set the search text and call for network result. * Set the search text and call for network result. */ */ Loading app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt +9 −0 Original line number Original line Diff line number Diff line Loading @@ -319,4 +319,13 @@ class SearchViewModel @Inject constructor( loadMore(searchText, autoTriggered = true) 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() } } } } app/src/main/res/layout/fragment_search.xml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -95,7 +95,7 @@ <include <include android:id="@+id/noAppsFoundLayout" android:id="@+id/noAppsFoundLayout" android:visibility="invisible" android:visibility="gone" tools:visibility="gone" tools:visibility="gone" layout="@layout/layout_no_apps_found" /> layout="@layout/layout_no_apps_found" /> Loading Loading
app/src/main/java/foundation/e/apps/ui/search/SearchFragment.kt +6 −7 Original line number Original line Diff line number Diff line Loading @@ -132,7 +132,6 @@ class SearchFragment : authObjects.observe(viewLifecycleOwner) { authObjects.observe(viewLifecycleOwner) { val currentQuery = searchView?.query?.toString() ?: "" val currentQuery = searchView?.query?.toString() ?: "" if (it == null || shouldIgnore(it, currentQuery)) { if (it == null || shouldIgnore(it, currentQuery)) { showData() return@observe return@observe } } Loading Loading @@ -176,6 +175,8 @@ class SearchFragment : searchViewModel.searchResult.observe(viewLifecycleOwner) { searchViewModel.searchResult.observe(viewLifecycleOwner) { if (it.data?.first.isNullOrEmpty() && it.data?.second == false) { if (it.data?.first.isNullOrEmpty() && it.data?.second == false) { noAppsFoundLayout?.visibility = View.VISIBLE noAppsFoundLayout?.visibility = View.VISIBLE } else if (searchViewModel.shouldIgnoreResults()) { return@observe } else { } else { listAdapter?.let { adapter -> listAdapter?.let { adapter -> observeDownloadList(adapter) observeDownloadList(adapter) Loading Loading @@ -367,13 +368,13 @@ class SearchFragment : } } override fun showLoadingUI() { override fun showLoadingUI() { binding.shimmerLayout.startShimmer() shimmerLayout?.visibility = View.VISIBLE binding.shimmerLayout.visibility = View.VISIBLE shimmerLayout?.startShimmer() } } override fun stopLoadingUI() { override fun stopLoadingUI() { binding.shimmerLayout.stopShimmer() shimmerLayout?.stopShimmer() binding.shimmerLayout.visibility = View.GONE shimmerLayout?.visibility = View.GONE } } private fun updateProgressOfInstallingApps(downloadProgress: DownloadProgress) { private fun updateProgressOfInstallingApps(downloadProgress: DownloadProgress) { Loading Loading @@ -440,8 +441,6 @@ class SearchFragment : view?.requestFocus() view?.requestFocus() searchHintLayout?.visibility = View.GONE searchHintLayout?.visibility = View.GONE shimmerLayout?.visibility = View.VISIBLE noAppsFoundLayout?.visibility = View.GONE /* /* * Set the search text and call for network result. * Set the search text and call for network result. */ */ Loading
app/src/main/java/foundation/e/apps/ui/search/SearchViewModel.kt +9 −0 Original line number Original line Diff line number Diff line Loading @@ -319,4 +319,13 @@ class SearchViewModel @Inject constructor( loadMore(searchText, autoTriggered = true) 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() } } } }
app/src/main/res/layout/fragment_search.xml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -95,7 +95,7 @@ <include <include android:id="@+id/noAppsFoundLayout" android:id="@+id/noAppsFoundLayout" android:visibility="invisible" android:visibility="gone" tools:visibility="gone" tools:visibility="gone" layout="@layout/layout_no_apps_found" /> layout="@layout/layout_no_apps_found" /> Loading