Skip to content

Commit 9bb6dab

Browse files
mdvaccameta-codesync[bot]
authored andcommitted
Fix FieldsBelowInit: Reorder properties in ColorAnimatedNode (#55360)
Summary: Pull Request resolved: #55360 Fixed FieldsBelowInit lint errors in ColorAnimatedNode.kt. Moved `color` and `context` computed properties above the init block to follow Kotlin initialization order conventions and prevent potential initialization issues. changelog: [internal] internal Reviewed By: cortinico Differential Revision: D91736974 fbshipit-source-id: 2f4d686af2ed9787c567fdb5de605d95fddcd23b
1 parent 41057d0 commit 9bb6dab

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/ColorAnimatedNode.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ internal class ColorAnimatedNode(
2727
private var nativeColor: ReadableMap? = null
2828
private var nativeColorApplied = false
2929

30-
init {
31-
onUpdateConfig(config)
32-
}
33-
3430
val color: Int
3531
get() {
3632
tryApplyNativeColor()
@@ -45,6 +41,17 @@ internal class ColorAnimatedNode(
4541
return normalize(r, g, b, a)
4642
}
4743

44+
private val context: Context?
45+
get() {
46+
// There are cases where the activity may not exist (such as for VRShell panel apps). In this
47+
// case we will search for a view associated with a PropsAnimatedNode to get the context.
48+
return reactApplicationContext.currentActivity ?: getContextHelper(this)
49+
}
50+
51+
init {
52+
onUpdateConfig(config)
53+
}
54+
4855
override fun onUpdateConfig(config: ReadableMap?) {
4956
if (config != null) {
5057
rNodeId = config.getInt("r")
@@ -84,13 +91,6 @@ internal class ColorAnimatedNode(
8491
nativeColorApplied = true
8592
}
8693

87-
private val context: Context?
88-
get() {
89-
// There are cases where the activity may not exist (such as for VRShell panel apps). In this
90-
// case we will search for a view associated with a PropsAnimatedNode to get the context.
91-
return reactApplicationContext.currentActivity ?: getContextHelper(this)
92-
}
93-
9494
companion object {
9595
private fun getContextHelper(node: AnimatedNode): Context? {
9696
// Search children depth-first until we get to a PropsAnimatedNode, from which we can

0 commit comments

Comments
 (0)