fix: wrong back order when new fragment opened from audio/video player

This commit is contained in:
Bnyro 2025-01-08 15:07:13 +01:00
parent 5d1d7474e2
commit daf22c499a
2 changed files with 14 additions and 0 deletions

View File

@ -262,6 +262,13 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions {
setOnBackPressed(onBackPressedCallback)
viewModel.isMiniPlayerVisible.observe(viewLifecycleOwner) { isMiniPlayerVisible ->
// re-add the callback on top of the back pressed dispatcher listeners stack,
// so that it's the first one to become called while the full player is visible
if (!isMiniPlayerVisible) {
onBackPressedCallback.remove()
setOnBackPressed(onBackPressedCallback)
}
// if the player is minimized, the fragment behind the player should handle the event
onBackPressedCallback.isEnabled = isMiniPlayerVisible != true
}

View File

@ -486,6 +486,13 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
setOnBackPressed(onBackPressedCallback)
commonPlayerViewModel.isMiniPlayerVisible.observe(viewLifecycleOwner) { isMiniPlayerVisible ->
// re-add the callback on top of the back pressed dispatcher listeners stack,
// so that it's the first one to become called while the full player is visible
if (!isMiniPlayerVisible) {
onBackPressedCallback.remove()
setOnBackPressed(onBackPressedCallback)
}
// if the player is minimized, the fragment behind the player should handle the event
onBackPressedCallback.isEnabled = isMiniPlayerVisible != true
}