Skip to content

Commit

Permalink
fix(#187): update app drawer whenever a change was triggered (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuester authored Dec 30, 2023
1 parent aa77aba commit 4e4539b
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 != ""
Expand All @@ -97,7 +96,7 @@ class AppDrawerAdapter(
}

val includeHeadings = !showDrawerHeadings || filterQuery != ""
filteredApps = when (includeHeadings) {
val updatedApps = when (includeHeadings) {
true -> displayableApps
.sortedWith { a, b ->
when {
Expand All @@ -122,6 +121,10 @@ class AppDrawerAdapter(
)
}
}
if (updatedApps != filteredApps) {
filteredApps = updatedApps
notifyDataSetChanged()
}
}

val searchBoxListener: TextWatcher = object : TextWatcher {
Expand Down

0 comments on commit 4e4539b

Please sign in to comment.