From dffca7823cdc88ba6a2dc43e00d28c3cee7c8885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Tue, 18 Jul 2023 08:32:10 +0200 Subject: [PATCH] Add no items found placeholder when searching --- .../launcher/fragments/AllAppsFragment.kt | 6 ++++++ app/src/main/res/layout/all_apps_fragment.xml | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/fragments/AllAppsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/fragments/AllAppsFragment.kt index 3178413..816c940 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/fragments/AllAppsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/fragments/AllAppsFragment.kt @@ -182,9 +182,15 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment search_bar.onSearchTextChangedListener = { (all_apps_grid.adapter as? LaunchersAdapter)?.updateSearchQuery(it) + showNoResultsPlaceholderIfNeeded() } } + private fun showNoResultsPlaceholderIfNeeded() { + val itemCount = all_apps_grid.adapter?.itemCount + no_results_placeholder.beVisibleIf(itemCount != null && itemCount == 0) + } + override fun onAppLauncherLongPressed(x: Float, y: Float, appLauncher: AppLauncher) { val gridItem = HomeScreenGridItem( null, diff --git a/app/src/main/res/layout/all_apps_fragment.xml b/app/src/main/res/layout/all_apps_fragment.xml index 61aa62a..7368361 100644 --- a/app/src/main/res/layout/all_apps_fragment.xml +++ b/app/src/main/res/layout/all_apps_fragment.xml @@ -26,4 +26,21 @@ app:spanCount="@integer/portrait_column_count" /> + + +