Last active
July 31, 2022 17:40
-
-
Save mayowa-egbewunmi/ff4399f113e8ae4487784994fd061cbb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class VideoCaptureManager private constructor(private val builder: Builder) : LifecycleEventObserver { | |
init { | |
getLifecycle().addObserver(this) | |
} | |
... | |
class Builder(val context: Context) { | |
var lifecycleOwner: LifecycleOwner? = null | |
private set | |
fun registerLifecycleOwner(source: LifecycleOwner): Builder { | |
this.lifecycleOwner = source | |
return this | |
} | |
fun create(): VideoCaptureManager { | |
requireNotNull(lifecycleOwner) { "Lifecycle owner is not set" } | |
return VideoCaptureManager(this) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment