From 641025fa2df5e90d475243dce503946fe5affba3 Mon Sep 17 00:00:00 2001 From: LagradOst <11805592+LagradOst@users.noreply.github.com> Date: Sun, 10 Apr 2022 00:05:42 +0200 Subject: [PATCH] fixed pip exit --- .../cloudstream3/ui/player/AbstractPlayerFragment.kt | 9 +++++++-- .../lagradost/cloudstream3/ui/player/FullScreenPlayer.kt | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/AbstractPlayerFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/AbstractPlayerFragment.kt index 3e53bccd..fff4b8ff 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/AbstractPlayerFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/AbstractPlayerFragment.kt @@ -92,6 +92,10 @@ abstract class AbstractPlayerFragment( throw NotImplementedError() } + open fun exitedPipMode() { + throw NotImplementedError() + } + private fun keepScreenOn(on: Boolean) { if (on) { activity?.window?.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) @@ -160,7 +164,7 @@ abstract class AbstractPlayerFragment( isInPIPMode = isInPictureInPictureMode if (isInPictureInPictureMode) { // Hide the full-screen UI (controls, etc.) while in picture-in-picture mode. - player_holder.alpha = 0f + player_holder?.alpha = 0f pipReceiver = object : BroadcastReceiver() { override fun onReceive( context: Context, @@ -188,7 +192,8 @@ abstract class AbstractPlayerFragment( updateIsPlaying(Pair(isPlayingValue, isPlayingValue)) } else { // Restore the full-screen UI. - player_holder.alpha = 1f + player_holder?.alpha = 1f + exitedPipMode() pipReceiver?.let { activity?.unregisterReceiver(it) } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt index a3545861..b3fad151 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt @@ -146,6 +146,10 @@ open class FullScreenPlayer : AbstractPlayerFragment() { return rawY > statusHeight && rawX < screenWidth //- navHeight } + override fun exitedPipMode() { + animateLayoutChanges() + } + private fun animateLayoutChanges() { if (isShowing) { updateUIVisibility()