From 02ae08a7098a41b5c2552c8dc80884a60391bc75 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Mon, 11 Mar 2024 18:47:01 +0100 Subject: [PATCH] fix: poor subscriptions filter options menu performance --- .../ui/sheets/FilterSortBottomSheet.kt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/sheets/FilterSortBottomSheet.kt b/app/src/main/java/com/github/libretube/ui/sheets/FilterSortBottomSheet.kt index 59c3dd863..d25ee59e0 100644 --- a/app/src/main/java/com/github/libretube/ui/sheets/FilterSortBottomSheet.kt +++ b/app/src/main/java/com/github/libretube/ui/sheets/FilterSortBottomSheet.kt @@ -40,9 +40,10 @@ class FilterSortBottomSheet : ExpandedBottomSheet() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { addSortOptions() + setInitialFiltersState() + observeSortChanges() observeHideWatchedChanges() - setInitialFiltersState() observeFiltersChanges() } @@ -66,6 +67,13 @@ class FilterSortBottomSheet : ExpandedBottomSheet() { } } + private fun setInitialFiltersState() { + binding.filterVideos.isChecked = ContentFilter.VIDEOS.isEnabled + binding.filterShorts.isChecked = ContentFilter.SHORTS.isEnabled + binding.filterLivestreams.isChecked = ContentFilter.LIVESTREAMS.isEnabled + binding.hideWatchedCheckbox.isChecked = hideWatched + } + private fun observeSortChanges() { binding.sortRadioGroup.setOnCheckedChangeListener { group, checkedId -> val index = group.findViewById(checkedId).tag as Int @@ -81,13 +89,6 @@ class FilterSortBottomSheet : ExpandedBottomSheet() { } } - private fun setInitialFiltersState() { - binding.filterVideos.isChecked = ContentFilter.VIDEOS.isEnabled - binding.filterShorts.isChecked = ContentFilter.SHORTS.isEnabled - binding.filterLivestreams.isChecked = ContentFilter.LIVESTREAMS.isEnabled - binding.hideWatchedCheckbox.isChecked = hideWatched - } - private fun observeFiltersChanges() { binding.filters.setOnCheckedStateChangeListener { _, _ -> ContentFilter.VIDEOS.isEnabled = binding.filterVideos.isChecked