Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: clear orientation listener on close #3139

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
mrousavy marked this conversation as resolved.
Show resolved Hide resolved
fun clearListeners() {
mrousavy marked this conversation as resolved.
Show resolved Hide resolved
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
Loading