Skip to content

Commit f1f09bc

Browse files
authored
[Android] Remove getChildInDrawingOrderAtIndex (#4156)
## Summary - Remove the `getChildInDrawingOrderAtIndex` abstraction from `ViewConfigurationHelper` and its implementation in `RNViewConfigurationHelper` - Inline `viewGroup.getChildAt(i)` at the two call sites (`GestureHandlerOrchestrator` and `HoverGestureHandler`) - `ReactViewGroup.getZIndexMappedChildIndex` is a legacy architecture API that has been a no-op (returns its input unchanged) and has been removed in facebook/react-native#56717 ## Test plan - Android build via `cd apps/basic-example && yarn android`
1 parent 5505329 commit f1f09bc

4 files changed

Lines changed: 2 additions & 14 deletions

File tree

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ class GestureHandlerOrchestrator(
624624

625625
val childrenCount = viewGroup.childCount
626626
for (i in childrenCount - 1 downTo 0) {
627-
val child = viewConfigHelper.getChildInDrawingOrderAtIndex(viewGroup, i)
627+
val child = viewGroup.getChildAt(i)
628628
if (canReceiveEvents(child)) {
629629
val childPoint = tempPoint
630630
transformPointToChildViewCoords(coords[0], coords[1], viewGroup, child, childPoint)

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/HoverGestureHandler.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import android.view.MotionEvent
77
import android.view.View
88
import android.view.ViewGroup
99
import com.swmansion.gesturehandler.react.RNGestureHandlerRootHelper
10-
import com.swmansion.gesturehandler.react.RNViewConfigurationHelper
1110
import com.swmansion.gesturehandler.react.events.eventbuilders.HoverGestureHandlerEventDataBuilder
1211

1312
class HoverGestureHandler : GestureHandler() {
@@ -44,7 +43,7 @@ class HoverGestureHandler : GestureHandler() {
4443

4544
if (rootView is ViewGroup) {
4645
for (i in 0 until rootView.childCount) {
47-
val child = viewConfigHelper.getChildInDrawingOrderAtIndex(rootView, i)
46+
val child = rootView.getChildAt(i)
4847
return isViewDisplayedOverAnother(view, other, child) ?: continue
4948
}
5049
}
@@ -145,8 +144,4 @@ class HoverGestureHandler : GestureHandler() {
145144

146145
override fun createEventBuilder(handler: HoverGestureHandler) = HoverGestureHandlerEventDataBuilder(handler)
147146
}
148-
149-
companion object {
150-
private val viewConfigHelper = RNViewConfigurationHelper()
151-
}
152147
}

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/ViewConfigurationHelper.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ import android.view.ViewGroup
55

66
interface ViewConfigurationHelper {
77
fun getPointerEventsConfigForView(view: View): PointerEventsConfig
8-
fun getChildInDrawingOrderAtIndex(parent: ViewGroup, index: Int): View
98
fun isViewClippingChildren(view: ViewGroup): Boolean
109
}

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ class RNViewConfigurationHelper : ViewConfigurationHelper {
3838
}
3939
}
4040

41-
override fun getChildInDrawingOrderAtIndex(parent: ViewGroup, index: Int): View = if (parent is ReactViewGroup) {
42-
parent.getChildAt(parent.getZIndexMappedChildIndex(index))
43-
} else {
44-
parent.getChildAt(index)
45-
}
46-
4741
override fun isViewClippingChildren(view: ViewGroup) = when {
4842
view.clipChildren -> true
4943
view is ReactScrollView -> view.overflow != "visible"

0 commit comments

Comments
 (0)