Skip to content

Commit

Permalink
fix: Use CREATED as default lifecycle state
Browse files Browse the repository at this point in the history
  • Loading branch information
mrousavy committed Mar 18, 2024
1 parent ad746d5 commit 1682bb2
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class CameraSession(private val context: Context, private val callback: Callback
private val mainExecutor = ContextCompat.getMainExecutor(context)

init {
lifecycleRegistry.currentState = Lifecycle.State.STARTED
lifecycleRegistry.currentState = Lifecycle.State.CREATED
lifecycle.addObserver(object : LifecycleEventObserver {
override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
Log.i(TAG, "Camera Lifecycle changed to ${event.targetState}!")
Expand Down Expand Up @@ -431,9 +431,11 @@ class CameraSession(private val context: Context, private val callback: Callback

private fun configureIsActive(config: CameraConfiguration) {
if (config.isActive) {
lifecycleRegistry.currentState = Lifecycle.State.STARTED
lifecycleRegistry.currentState = Lifecycle.State.RESUMED
} else {
lifecycleRegistry.currentState = Lifecycle.State.STARTED
lifecycleRegistry.currentState = Lifecycle.State.CREATED
}
}

Expand Down

0 comments on commit 1682bb2

Please sign in to comment.