Skip to content

Instantly share code, notes, and snippets.

@GiuseppeGiacoppo
Last active February 19, 2022 12:13
Show Gist options
  • Save GiuseppeGiacoppo/ca693159a8c7ccf4fda6efbed9ffaf8a to your computer and use it in GitHub Desktop.
Save GiuseppeGiacoppo/ca693159a8c7ccf4fda6efbed9ffaf8a to your computer and use it in GitHub Desktop.
interface AnalyticsDelegate {
fun registerAnalytics(lifecycle: Lifecycle)
}
class AnalyticsDelegateImpl: AnalyticsDelegate, DefaultLifecycleObserver {
override fun registerAnalytics(lifecycle: Lifecycle) {
lifecycle.addObserver(this)
}
override fun onStart(owner: LifecycleOwner) {
traceEvent("Activity started")
}
override fun onStop(owner: LifecycleOwner) {
traceEvent("Activity stopped")
}
private fun traceEvent(event: String) {
//MyAnalytics.newEvent(event)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment