From 3e56ddf7d6de4609dfeb2780803431e58701696b Mon Sep 17 00:00:00 2001 From: Mohsen Mirhoseini Date: Fri, 16 Feb 2024 13:58:16 +0100 Subject: [PATCH] Add closeOnDestory and closeOnStop to PiP example **What** - Adding `closeOnDestory` and `closeOnStop` to the PiP example app **Why** - Customer needs to know how to do it Signed-off-by: Mohsen Mirhoseini --- .../example/pictureinpicture/MainActivity.kt | 12 +++++++++++ .../app/src/main/res/layout/activity_main.xml | 20 +++++++++++++++++-- .../app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/picture_in_picture/app/src/main/java/com/firework/example/pictureinpicture/MainActivity.kt b/picture_in_picture/app/src/main/java/com/firework/example/pictureinpicture/MainActivity.kt index 1d01ce4..8a2840d 100644 --- a/picture_in_picture/app/src/main/java/com/firework/example/pictureinpicture/MainActivity.kt +++ b/picture_in_picture/app/src/main/java/com/firework/example/pictureinpicture/MainActivity.kt @@ -89,7 +89,19 @@ class MainActivity : AppCompatActivity() { } } + override fun onStop() { + Log.i(TAG, "onStop - isFinishing: $isFinishing") + if (binding.closePipOnStop.isChecked && isFinishing) { + FireworkSdk.closePip() + } + super.onStop() + } + override fun onDestroy() { + Log.i(TAG, "onDestroy") + if (binding.closePipOnDestroy.isChecked) { + FireworkSdk.closePip() + } binding.fwVideoFeedView.destroy() super.onDestroy() } diff --git a/picture_in_picture/app/src/main/res/layout/activity_main.xml b/picture_in_picture/app/src/main/res/layout/activity_main.xml index c9d9e8e..dfd1dde 100644 --- a/picture_in_picture/app/src/main/res/layout/activity_main.xml +++ b/picture_in_picture/app/src/main/res/layout/activity_main.xml @@ -26,15 +26,31 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/close_pip_mode" - app:layout_constraintBottom_toTopOf="@id/details" + app:layout_constraintBottom_toTopOf="@id/closePipOnStop" app:layout_constraintTop_toBottomOf="@id/enterPip" /> + + + + + app:layout_constraintTop_toBottomOf="@id/closePipOnDestroy" /> diff --git a/picture_in_picture/app/src/main/res/values/strings.xml b/picture_in_picture/app/src/main/res/values/strings.xml index 0287828..0ff7010 100644 --- a/picture_in_picture/app/src/main/res/values/strings.xml +++ b/picture_in_picture/app/src/main/res/values/strings.xml @@ -7,4 +7,6 @@ Enter PiP mode in 5 sec Close PiP mode + Close PiP mode onStop + Close PiP mode onDestroy