From a7d76f379f1e190c0deaddbb783d63ac953fd1df Mon Sep 17 00:00:00 2001 From: Hanson Ho Date: Fri, 26 Jul 2024 16:30:14 -0700 Subject: [PATCH] Make ActivityLifecycleListener extend ActivityLifecycleCallacks with no-op defaults (#1124) ## Goal Make the listener implement `ActivityLifecycleCallbacks` with default no-op implementations so we can observe more lifecycle events. --- .../lifecycle/ActivityLifecycleListener.kt | 41 ++++++++----------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/embrace-android-core/src/main/kotlin/io/embrace/android/embracesdk/internal/session/lifecycle/ActivityLifecycleListener.kt b/embrace-android-core/src/main/kotlin/io/embrace/android/embracesdk/internal/session/lifecycle/ActivityLifecycleListener.kt index 0f4ce5da97..52d8d668ab 100644 --- a/embrace-android-core/src/main/kotlin/io/embrace/android/embracesdk/internal/session/lifecycle/ActivityLifecycleListener.kt +++ b/embrace-android-core/src/main/kotlin/io/embrace/android/embracesdk/internal/session/lifecycle/ActivityLifecycleListener.kt @@ -1,32 +1,25 @@ package io.embrace.android.embracesdk.internal.session.lifecycle import android.app.Activity +import android.app.Application.ActivityLifecycleCallbacks import android.os.Bundle /** - * Listener implemented by observers of the [ActivityLifecycleTracker]. + * Implementation of [ActivityLifecycleCallbacks] with no-op defaults */ -public interface ActivityLifecycleListener { - - /** - * Triggered when an activity is opened. - * - * @param activity details of the activity - */ - public fun onActivityStarted(activity: Activity) {} - - /** - * Triggered when an activity is closed. - * - * @param activity details of the activity - */ - public fun onActivityStopped(activity: Activity) {} - - /** - * Triggered when an activity is created. - * - * @param activity the activity - * @param bundle the bundle - */ - public fun onActivityCreated(activity: Activity, bundle: Bundle?) {} +public interface ActivityLifecycleListener : ActivityLifecycleCallbacks { + + public override fun onActivityCreated(activity: Activity, bundle: Bundle?) {} + + public override fun onActivityStarted(activity: Activity) {} + + public override fun onActivityResumed(activity: Activity) {} + + public override fun onActivityPaused(activity: Activity) {} + + public override fun onActivityStopped(activity: Activity) {} + + public override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {} + + public override fun onActivityDestroyed(activity: Activity) {} }