Skip to content

Commit 5d3fbc2

Browse files
committed
Change visibility of RootViewGestureHandler to internal and use the symbol directly
1 parent c26822d commit 5d3fbc2

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import com.facebook.react.views.text.ReactTextView
1515
import com.facebook.react.views.textinput.ReactEditText
1616
import com.facebook.react.views.view.ReactViewGroup
1717
import com.swmansion.gesturehandler.react.RNGestureHandlerButtonViewManager
18+
import com.swmansion.gesturehandler.react.RNGestureHandlerRootHelper
1819
import com.swmansion.gesturehandler.react.events.eventbuilders.NativeGestureHandlerEventDataBuilder
1920
import com.swmansion.gesturehandler.react.isScreenReaderOn
2021

@@ -79,7 +80,10 @@ class NativeViewGestureHandler : GestureHandler() {
7980
}
8081
}
8182
val canBeInterrupted = !disallowInterruption ||
82-
(yieldsToNativeGestures && (handler is NativeViewGestureHandler || handler.tag < 0))
83+
(
84+
yieldsToNativeGestures &&
85+
(handler is NativeViewGestureHandler || handler is RNGestureHandlerRootHelper.RootViewGestureHandler)
86+
)
8387
val otherState = handler.state
8488
return if (state == STATE_ACTIVE && otherState == STATE_ACTIVE && canBeInterrupted) {
8589
// if both handlers are active and the current handler can be interrupted it we return `false`
@@ -336,11 +340,10 @@ class NativeViewGestureHandler : GestureHandler() {
336340
}
337341
}
338342

339-
// recognize alongside every handler besides RootViewGestureHandler, which is a private inner class
340-
// of RNGestureHandlerRootHelper so no explicit type checks, but its tag is always negative
343+
// recognize alongside every handler besides RootViewGestureHandler;
341344
// also if other handler is NativeViewGestureHandler then don't override the default implementation
342345
override fun shouldRecognizeSimultaneously(handler: GestureHandler) =
343-
handler.tag > 0 && handler !is NativeViewGestureHandler
346+
handler !is RNGestureHandlerRootHelper.RootViewGestureHandler && handler !is NativeViewGestureHandler
344347

345348
override fun wantsToHandleEventBeforeActivation() = true
346349

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ class RNGestureHandlerInteractionManager : GestureHandlerInteractionController {
5151
override fun shouldHandlerBeCancelledBy(handler: GestureHandler, otherHandler: GestureHandler): Boolean {
5252
if (otherHandler is NativeViewGestureHandler) {
5353
return otherHandler.disallowInterruption &&
54-
!(otherHandler.yieldsToNativeGestures && (handler is NativeViewGestureHandler || handler.tag < 0))
54+
!(
55+
otherHandler.yieldsToNativeGestures &&
56+
(handler is NativeViewGestureHandler || handler is RNGestureHandlerRootHelper.RootViewGestureHandler)
57+
)
5558
}
5659

5760
if (otherHandler is RNGestureHandlerRootHelper.RootViewGestureHandler) {

0 commit comments

Comments
 (0)