@@ -18,6 +18,7 @@ import com.badoo.ribs.core.modality.BuildContext
18
18
import com.badoo.ribs.core.modality.BuildParams
19
19
import com.badoo.ribs.core.plugin.AndroidLifecycleAware
20
20
import com.badoo.ribs.core.plugin.BackPressHandler
21
+ import com.badoo.ribs.core.plugin.GlobalNodeLifecycleAware
21
22
import com.badoo.ribs.core.plugin.NodeAware
22
23
import com.badoo.ribs.core.plugin.NodeLifecycleAware
23
24
import com.badoo.ribs.core.plugin.Plugin
@@ -100,7 +101,7 @@ open class Node<V : RibView> @VisibleForTesting internal constructor(
100
101
}
101
102
102
103
val plugins: List <Plugin > =
103
- buildContext.defaultPlugins(this ) + plugins + if (this is Plugin ) listOf (this ) else emptyList()
104
+ buildContext.defaultPlugins(this ) + RIBs .globalPlugins + plugins + if (this is Plugin ) listOf (this ) else emptyList()
104
105
105
106
internal open val activationMode: ActivationMode =
106
107
buildContext.activationMode
@@ -136,6 +137,7 @@ open class Node<V : RibView> @VisibleForTesting internal constructor(
136
137
137
138
internal fun onBuildFinished () {
138
139
plugins.filterIsInstance<NodeLifecycleAware >().forEach { it.onBuild() }
140
+ plugins.filterIsInstance<GlobalNodeLifecycleAware >().forEach { it.onBuild(this ) }
139
141
parent?.onChildBuilt(this )
140
142
}
141
143
@@ -148,6 +150,9 @@ open class Node<V : RibView> @VisibleForTesting internal constructor(
148
150
plugins
149
151
.filterIsInstance<NodeLifecycleAware >()
150
152
.forEach { it.onCreate(lifecycleManager.ribLifecycle.lifecycle) }
153
+ plugins
154
+ .filterIsInstance<GlobalNodeLifecycleAware >()
155
+ .forEach { it.onCreate(this , lifecycleManager.ribLifecycle.lifecycle) }
151
156
lifecycleManager.onCreate()
152
157
}
153
158
@@ -218,6 +223,7 @@ open class Node<V : RibView> @VisibleForTesting internal constructor(
218
223
219
224
lifecycleManager.onDestroy()
220
225
plugins.filterIsInstance<NodeLifecycleAware >().forEach { it.onDestroy() }
226
+ plugins.filterIsInstance<GlobalNodeLifecycleAware >().forEach { it.onDestroy(this ) }
221
227
if (! isRecreating) {
222
228
retainedInstanceStore.removeAll(identifier)
223
229
}
@@ -247,6 +253,7 @@ open class Node<V : RibView> @VisibleForTesting internal constructor(
247
253
248
254
internal fun onAttachFinished () {
249
255
plugins.filterIsInstance<NodeLifecycleAware >().forEach { it.onAttach() }
256
+ plugins.filterIsInstance<GlobalNodeLifecycleAware >().forEach { it.onAttach(this ) }
250
257
}
251
258
252
259
open fun onAttachChildNode (child : Node <* >) {
@@ -407,6 +414,8 @@ open class Node<V : RibView> @VisibleForTesting internal constructor(
407
414
override val lifecycle: Lifecycle
408
415
get() = lifecycleManager.lifecycle
409
416
417
+ fun getView () : V ? = view
418
+
410
419
fun <P > plugins (pClass : Class <P >): List <P > =
411
420
plugins.filterIsInstance(pClass)
412
421
0 commit comments