From 42d07b5942e91c14a71bffc74b521618aff63f5e Mon Sep 17 00:00:00 2001 From: andreykovalev Date: Fri, 1 Sep 2023 13:34:39 +0100 Subject: [PATCH 1/4] Expose AndroidLifecycle for Android targets + create a helper function --- .../com/bumble/appyx/navigation/platform/LifecycleExt.kt | 6 ++++++ .../appyx/navigation/platform/PlatformLifecycleRegistry.kt | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleExt.kt diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleExt.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleExt.kt new file mode 100644 index 000000000..f764d7cd4 --- /dev/null +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleExt.kt @@ -0,0 +1,6 @@ +package com.bumble.appyx.navigation.platform + +import com.bumble.appyx.navigation.node.Node + +val Node.androidLifecycle: androidx.lifecycle.Lifecycle + get() = (lifecycle as PlatformLifecycleRegistry).androidLifecycleRegistry diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt index 04af120ac..70b5660ec 100644 --- a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/PlatformLifecycleRegistry.kt @@ -17,7 +17,7 @@ actual class PlatformLifecycleRegistry( androidx.lifecycle.LifecycleEventObserver { private var lifecycleOwner: LifecycleOwner? = androidOwner - private val androidLifecycleRegistry = LifecycleRegistry(androidOwner) + val androidLifecycleRegistry = LifecycleRegistry(androidOwner) private val managedDefaultLifecycleObservers: MutableList = ArrayList() From 92013a373ec10f5d03f91b3f6355138a40436900 Mon Sep 17 00:00:00 2001 From: andreykovalev Date: Fri, 1 Sep 2023 13:37:07 +0100 Subject: [PATCH 2/4] Update CHANGELOG.md --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52541fc8f..33a6e878a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,9 @@ ## Pending changes -- +### Fixed + +- [#579](https://github.com/bumble-tech/appyx/pull/579) – Expose AndroidLifecycle in PlatformLifecycleRegistry for Android ## 2.0.0-alpha04 From 9322a3b5d6323a76302febeaebe6e6124ca9f206 Mon Sep 17 00:00:00 2001 From: andreykovalev Date: Fri, 1 Sep 2023 14:32:18 +0100 Subject: [PATCH 3/4] Move androidLifecycle to NodeExt.kt --- .../navigation/{platform/LifecycleExt.kt => node/NodeExt.kt} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/{platform/LifecycleExt.kt => node/NodeExt.kt} (55%) diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleExt.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/node/NodeExt.kt similarity index 55% rename from appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleExt.kt rename to appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/node/NodeExt.kt index f764d7cd4..74acff9bc 100644 --- a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/platform/LifecycleExt.kt +++ b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/node/NodeExt.kt @@ -1,6 +1,6 @@ -package com.bumble.appyx.navigation.platform +package com.bumble.appyx.navigation.node -import com.bumble.appyx.navigation.node.Node +import com.bumble.appyx.navigation.platform.PlatformLifecycleRegistry val Node.androidLifecycle: androidx.lifecycle.Lifecycle get() = (lifecycle as PlatformLifecycleRegistry).androidLifecycleRegistry From 0b0381bb8ffe6ae6aedaba20a68947eb9771818c Mon Sep 17 00:00:00 2001 From: andreykovalev Date: Fri, 1 Sep 2023 15:07:11 +0100 Subject: [PATCH 4/4] Rename file to avoid duplication --- .../appyx/navigation/node/{NodeExt.kt => AndroidNodeExt.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/node/{NodeExt.kt => AndroidNodeExt.kt} (100%) diff --git a/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/node/NodeExt.kt b/appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/node/AndroidNodeExt.kt similarity index 100% rename from appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/node/NodeExt.kt rename to appyx-navigation/common/src/androidMain/kotlin/com/bumble/appyx/navigation/node/AndroidNodeExt.kt