Skip to content

Commit 2f0d5ad

Browse files
committed
styling
1 parent 5741a1b commit 2f0d5ad

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
1313
private val reactContext: ThemedReactContext
1414
get() = context as ThemedReactContext
1515
private var handlersToAttach: List<Int>? = null
16-
private var nativeHandlers: MutableSet<Int> = mutableSetOf()
16+
private var attachedNativeHandlers: MutableSet<Int> = mutableSetOf()
1717
private var attachedHandlers: MutableSet<Int> = mutableSetOf()
1818
private var moduleId: Int = -1
1919

@@ -40,6 +40,7 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
4040
private fun shouldAttachGestureToChildView(tag: Int): Boolean {
4141
val registry = RNGestureHandlerModule.registries[moduleId]
4242
?: throw Exception("Tried to access a non-existent registry")
43+
4344
return registry.getHandler(tag)?.wantsToAttachDirectlyToView() ?: false
4445
}
4546

@@ -69,22 +70,23 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
6970
for (tag in newHandlers) {
7071
changes[tag] = if (changes.containsKey(tag)) GestureHandlerMutation.Keep else GestureHandlerMutation.Attach
7172
}
73+
7274
for (entry in changes) {
7375
val tag = entry.key
7476

7577
if (entry.value == GestureHandlerMutation.Attach) {
7678
// It might happen that `attachHandlers` will be called before children are added into view hierarchy. In that case we cannot
7779
// attach `NativeViewGestureHandlers` here and we have to do it in `addView` method.
7880
if (shouldAttachGestureToChildView(tag)) {
79-
nativeHandlers.add(tag)
81+
attachedNativeHandlers.add(tag)
8082
} else {
8183
registry.attachHandlerToView(tag, this.id, GestureHandler.ACTION_TYPE_NATIVE_DETECTOR)
8284

8385
attachedHandlers.add(tag)
8486
}
8587
} else if (entry.value == GestureHandlerMutation.Detach) {
8688
registry.detachHandler(tag)
87-
nativeHandlers.remove(tag)
89+
attachedNativeHandlers.remove(tag)
8890
attachedHandlers.remove(tag)
8991
}
9092
}
@@ -101,7 +103,7 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
101103
val registry = RNGestureHandlerModule.registries[moduleId]
102104
?: throw Exception("Tried to access a non-existent registry")
103105

104-
for (tag in nativeHandlers) {
106+
for (tag in attachedNativeHandlers) {
105107
registry.attachHandlerToView(tag, childId, GestureHandler.ACTION_TYPE_NATIVE_DETECTOR)
106108

107109
attachedHandlers.add(tag)
@@ -112,7 +114,7 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
112114
val registry = RNGestureHandlerModule.registries[moduleId]
113115
?: throw Exception("Tried to access a non-existent registry")
114116

115-
for (tag in nativeHandlers) {
117+
for (tag in attachedNativeHandlers) {
116118
registry.detachHandler(tag)
117119
attachedHandlers.remove(tag)
118120
}

0 commit comments

Comments
 (0)