From 07d925bda0d0772e35ffb9e96f42522e5ee0a612 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Mon, 20 May 2024 16:21:34 +0200 Subject: [PATCH] fix: use correct fragment manager for result callbacks --- .../ui/fragments/AudioPlayerFragment.kt | 4 ++-- .../ui/fragments/SubscriptionsFragment.kt | 23 ++++++++----------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt index 61007db9d6..6849feca4b 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/AudioPlayerFragment.kt @@ -170,7 +170,7 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions { ) } - requireActivity().supportFragmentManager.setFragmentResultListener( + childFragmentManager.setFragmentResultListener( ChaptersBottomSheet.SEEK_TO_POSITION_REQUEST_KEY, viewLifecycleOwner ) { _, bundle -> @@ -187,7 +187,7 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions { IntentData.duration to playerService.player?.duration?.div(1000) ) } - .show(requireActivity().supportFragmentManager) + .show(childFragmentManager) } binding.miniPlayerClose.setOnClickListener { diff --git a/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt index dba5c6d155..08b60b0027 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/SubscriptionsFragment.kt @@ -231,19 +231,14 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment() { private fun setupSortAndFilter() { binding.filterSort.setOnClickListener { - val activityCompat = context as AppCompatActivity - val fragManager = activityCompat - .supportFragmentManager - .apply { - setFragmentResultListener( - FILTER_SORT_REQUEST_KEY, - activityCompat - ) { _, resultBundle -> - selectedSortOrder = resultBundle.getInt(IntentData.sortOptions) - hideWatched = resultBundle.getBoolean(IntentData.hideWatched) - showFeed() - } - } + childFragmentManager.setFragmentResultListener( + FILTER_SORT_REQUEST_KEY, + viewLifecycleOwner + ) { _, resultBundle -> + selectedSortOrder = resultBundle.getInt(IntentData.sortOptions) + hideWatched = resultBundle.getBoolean(IntentData.hideWatched) + showFeed() + } FilterSortBottomSheet() .apply { @@ -252,7 +247,7 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment() { IntentData.hideWatched to hideWatched ) } - .show(fragManager) + .show(childFragmentManager) } }