From 4e4539b7c1f604b3ba80a270ebae2f493b064eed Mon Sep 17 00:00:00 2001 From: Joshua Kuestersteffen Date: Fri, 29 Dec 2023 18:03:58 -0600 Subject: [PATCH] fix(#187): update app drawer whenever a change was triggered (#194) --- .../sduduzog/slimlauncher/adapters/AppDrawerAdapter.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/sduduzog/slimlauncher/adapters/AppDrawerAdapter.kt b/app/src/main/java/com/sduduzog/slimlauncher/adapters/AppDrawerAdapter.kt index 1557489e..41de137b 100644 --- a/app/src/main/java/com/sduduzog/slimlauncher/adapters/AppDrawerAdapter.kt +++ b/app/src/main/java/com/sduduzog/slimlauncher/adapters/AppDrawerAdapter.kt @@ -80,13 +80,12 @@ class AppDrawerAdapter( return first.startsWith(query, true) and !second.startsWith(query, true); } - @SuppressLint("NotifyDataSetChanged") fun setAppFilter(query: String = "") { val filterQuery = regex.replace(query, "") updateFilteredApps(filterQuery) - notifyDataSetChanged() } + @SuppressLint("NotifyDataSetChanged") private fun updateFilteredApps(filterQuery: String = "") { val showDrawerHeadings = corePreferencesRepo.get().showDrawerHeadings val searchAllApps = corePreferencesRepo.get().searchAllAppsInDrawer && filterQuery != "" @@ -97,7 +96,7 @@ class AppDrawerAdapter( } val includeHeadings = !showDrawerHeadings || filterQuery != "" - filteredApps = when (includeHeadings) { + val updatedApps = when (includeHeadings) { true -> displayableApps .sortedWith { a, b -> when { @@ -122,6 +121,10 @@ class AppDrawerAdapter( ) } } + if (updatedApps != filteredApps) { + filteredApps = updatedApps + notifyDataSetChanged() + } } val searchBoxListener: TextWatcher = object : TextWatcher {