Skip to content

Commit

Permalink
Update app drawer to notify of updates whenever a change was triggered
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuester committed Dec 29, 2023
1 parent aa77aba commit a7d1e47
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 a7d1e47

Please sign in to comment.