Skip to content

Instantly share code, notes, and snippets.

@mayowa-egbewunmi
Last active July 31, 2022 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mayowa-egbewunmi/ff4399f113e8ae4487784994fd061cbb to your computer and use it in GitHub Desktop.
Save mayowa-egbewunmi/ff4399f113e8ae4487784994fd061cbb to your computer and use it in GitHub Desktop.
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