From c975568e9a773e85f732cd8c94903d7a8f0531a2 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Mon, 21 Oct 2024 12:35:21 +0200 Subject: [PATCH] fix: unexpected behavior in offline audio player fragment --- .../github/libretube/ui/activities/NoInternetActivity.kt | 7 +------ .../github/libretube/ui/fragments/AudioPlayerFragment.kt | 4 ++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/activities/NoInternetActivity.kt b/app/src/main/java/com/github/libretube/ui/activities/NoInternetActivity.kt index d2249468d..df9f7412f 100644 --- a/app/src/main/java/com/github/libretube/ui/activities/NoInternetActivity.kt +++ b/app/src/main/java/com/github/libretube/ui/activities/NoInternetActivity.kt @@ -58,12 +58,7 @@ class NoInternetActivity : BaseActivity() { super.onNewIntent(intent) if (intent.getBooleanExtra(IntentData.openAudioPlayer, false)) { - // attempt to recycle already existing audio player fragment first before creating new one - supportFragmentManager.fragments.filterIsInstance().firstOrNull()?.let { - it.binding.playerMotionLayout.transitionToStart() - return - } - NavigationHelper.startAudioPlayer(this) + NavigationHelper.startAudioPlayer(this, offlinePlayer = true) } } } 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 013f0ed56..8cc3d19eb 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 @@ -298,6 +298,8 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions { * Load the information from a new stream into the UI */ private fun updateStreamInfo(stream: StreamItem? = null) { + val binding = _binding ?: return + val current = stream ?: PlayingQueue.getCurrent() ?: return binding.title.text = current.title @@ -380,6 +382,8 @@ class AudioPlayerFragment : Fragment(), AudioPlayerOptions { private fun updatePlayPauseButton() { playerService?.player?.let { + val binding = _binding ?: return + val iconRes = PlayerHelper.getPlayPauseActionIcon(it) binding.playPause.setIconResource(iconRes) binding.miniPlayerPause.setImageResource(iconRes)