Skip to content

Commit e00c697

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Fix FieldsBelowInit: Move viewportOffset property above init block (facebook#55358)
Summary: Fixed FieldsBelowInit lint error in ReactSurfaceView.kt. Moved the viewportOffset property declaration above the init block to ensure proper initialization order and satisfy Kotlin best practices for property declarations. changelog: [internal] internal Reviewed By: cortinico Differential Revision: D91732184
1 parent 8d7cebd commit e00c697

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactSurfaceView.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ public class ReactSurfaceView(context: Context?, private val surface: ReactSurfa
4545
private var widthMeasureSpec = 0
4646
private var heightMeasureSpec = 0
4747

48+
private val viewportOffset: Point
49+
get() {
50+
val locationOnScreen = IntArray(2)
51+
getLocationOnScreen(locationOnScreen)
52+
53+
// we need to subtract visibleWindowCoords - to subtract possible window insets, split
54+
// screen or multi window
55+
val visibleWindowFrame = Rect()
56+
getWindowVisibleDisplayFrame(visibleWindowFrame)
57+
locationOnScreen[0] -= visibleWindowFrame.left
58+
locationOnScreen[1] -= visibleWindowFrame.top
59+
return Point(locationOnScreen[0], locationOnScreen[1])
60+
}
61+
4862
init {
4963
if (ReactFeatureFlags.dispatchPointerEvents) {
5064
jsPointerDispatcher = JSPointerDispatcher(this)
@@ -105,20 +119,6 @@ public class ReactSurfaceView(context: Context?, private val surface: ReactSurfa
105119
}
106120
}
107121

108-
private val viewportOffset: Point
109-
get() {
110-
val locationOnScreen = IntArray(2)
111-
getLocationOnScreen(locationOnScreen)
112-
113-
// we need to subtract visibleWindowCoords - to subtract possible window insets, split
114-
// screen or multi window
115-
val visibleWindowFrame = Rect()
116-
getWindowVisibleDisplayFrame(visibleWindowFrame)
117-
locationOnScreen[0] -= visibleWindowFrame.left
118-
locationOnScreen[1] -= visibleWindowFrame.top
119-
return Point(locationOnScreen[0], locationOnScreen[1])
120-
}
121-
122122
override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {
123123
// Override in order to still receive events to onInterceptTouchEvent even when some other
124124
// views disallow that, but propagate it up the tree if possible.

0 commit comments

Comments
 (0)