Merge pull request #5725 from Bnyro/master

fix: poor subscriptions filter options menu performance
This commit is contained in:
Bnyro 2024-03-11 18:50:31 +01:00 committed by GitHub
commit 57449dc3eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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<RadioButton>(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