File tree Expand file tree Collapse file tree 3 files changed +43
-10
lines changed
appnav/src/main/kotlin/io/element/android/appnav
libraries/architecture/src/main/kotlin/io/element/android/libraries/architecture Expand file tree Collapse file tree 3 files changed +43
-10
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,6 @@ import android.os.Parcelable
2020import androidx.compose.runtime.Composable
2121import androidx.compose.ui.Modifier
2222import com.bumble.appyx.core.composable.Children
23- import com.bumble.appyx.core.lifecycle.subscribe
2423import com.bumble.appyx.core.modality.BuildContext
2524import com.bumble.appyx.core.node.Node
2625import com.bumble.appyx.core.plugin.Plugin
@@ -35,7 +34,6 @@ import io.element.android.libraries.architecture.BackstackNode
3534import io.element.android.libraries.architecture.animation.rememberDefaultTransitionHandler
3635import io.element.android.libraries.di.AppScope
3736import kotlinx.parcelize.Parcelize
38- import timber.log.Timber
3937
4038@ContributesNode(AppScope ::class )
4139class NotLoggedInFlowNode @AssistedInject constructor(
@@ -51,13 +49,6 @@ class NotLoggedInFlowNode @AssistedInject constructor(
5149 buildContext = buildContext,
5250 plugins = plugins,
5351) {
54- init {
55- lifecycle.subscribe(
56- onCreate = { Timber .v(" OnCreate" ) },
57- onDestroy = { Timber .v(" OnDestroy" ) }
58- )
59- }
60-
6152 sealed interface NavTarget : Parcelable {
6253 @Parcelize
6354 object OnBoarding : NavTarget
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ package io.element.android.libraries.architecture
1919import androidx.compose.runtime.Stable
2020import com.bumble.appyx.core.children.ChildEntry
2121import com.bumble.appyx.core.modality.BuildContext
22+ import com.bumble.appyx.core.node.Node
2223import com.bumble.appyx.core.node.ParentNode
2324import com.bumble.appyx.core.plugin.Plugin
2425import com.bumble.appyx.navmodel.backstack.BackStack
@@ -39,4 +40,15 @@ abstract class BackstackNode<NavTarget : Any>(
3940 buildContext = buildContext,
4041 plugins = plugins,
4142 childKeepMode = childKeepMode,
42- )
43+ ) {
44+ override fun onBuilt () {
45+ super .onBuilt()
46+ lifecycle.logLifecycle(this ::class .java.simpleName)
47+ whenChildAttached<Node > { _, child ->
48+ // BackstackNode will be logged by their parent.
49+ if (child !is BackstackNode <* >) {
50+ child.lifecycle.logLifecycle(child::class .java.simpleName)
51+ }
52+ }
53+ }
54+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2023 New Vector Ltd
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ package io.element.android.libraries.architecture
18+
19+ import androidx.lifecycle.Lifecycle
20+ import com.bumble.appyx.core.lifecycle.subscribe
21+ import timber.log.Timber
22+
23+ fun Lifecycle.logLifecycle (name : String ) {
24+ subscribe(
25+ onCreate = { Timber .tag(" Lifecycle" ).d(" onCreate $name " ) },
26+ onPause = { Timber .tag(" Lifecycle" ).d(" onPause $name " ) },
27+ onResume = { Timber .tag(" Lifecycle" ).d(" onResume $name " ) },
28+ onDestroy = { Timber .tag(" Lifecycle" ).d(" onDestroy $name " ) },
29+ )
30+ }
You can’t perform that action at this time.
0 commit comments