Skip to content

Commit

Permalink
Fix: clear orientation listener on close
Browse files Browse the repository at this point in the history
  • Loading branch information
ldalzottomp committed Aug 14, 2024
1 parent 00caff0 commit 7a65f47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class CameraSession(internal val context: Context, internal val callback: Callba
override fun close() {
Log.i(TAG, "Closing CameraSession...")
isDestroyed = true
orientationManager.clearListeners()
runOnUiThread {
lifecycleRegistry.currentState = Lifecycle.State.DESTROYED
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,17 @@ class OrientationManager(private val context: Context, private val callback: Cal
}
}

// remove previous listeners if attached
func clearListeners() {
displayManager.unregisterDisplayListener(displayListener)
orientationListener.disable()
}

fun setTargetOutputOrientation(targetOrientation: OutputOrientation) {
Log.i(TAG, "Target Orientation changed $targetOutputOrientation -> $targetOrientation!")
targetOutputOrientation = targetOrientation

// remove previous listeners if attached
displayManager.unregisterDisplayListener(displayListener)
orientationListener.disable()
clearListeners()

when (targetOrientation) {
OutputOrientation.DEVICE -> {
Expand Down

0 comments on commit 7a65f47

Please sign in to comment.