Skip to content

Commit

Permalink
Add closeOnDestory and closeOnStop to PiP example
Browse files Browse the repository at this point in the history
**What**
- Adding `closeOnDestory` and `closeOnStop` to the PiP example app

**Why**
- Customer needs to know how to do it

Signed-off-by: Mohsen Mirhoseini <[email protected]>
  • Loading branch information
Mohsen Mirhoseini committed Feb 16, 2024
1 parent fc4c2e5 commit 3e56ddf
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
20 changes: 18 additions & 2 deletions picture_in_picture/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

<CheckBox
android:id="@+id/closePipOnStop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/close_pip_on_stop"
app:layout_constraintBottom_toTopOf="@id/closePipOnDestroy"
app:layout_constraintTop_toBottomOf="@id/closePip" />

<CheckBox
android:id="@+id/closePipOnDestroy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/close_pip_on_destroy"
app:layout_constraintBottom_toTopOf="@id/details"
app:layout_constraintTop_toBottomOf="@id/closePipOnStop" />

<include
android:id="@+id/details"
layout="@layout/details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/closePip" />
app:layout_constraintTop_toBottomOf="@id/closePipOnDestroy" />

</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 2 additions & 0 deletions picture_in_picture/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@

<string name="enter_pip_mode">Enter PiP mode in 5 sec</string>
<string name="close_pip_mode">Close PiP mode</string>
<string name="close_pip_on_stop">Close PiP mode onStop</string>
<string name="close_pip_on_destroy">Close PiP mode onDestroy</string>
</resources>

0 comments on commit 3e56ddf

Please sign in to comment.