@@ -13,7 +13,7 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
13
13
private val reactContext: ThemedReactContext
14
14
get() = context as ThemedReactContext
15
15
private var handlersToAttach: List <Int >? = null
16
- private var nativeHandlers : MutableSet <Int > = mutableSetOf ()
16
+ private var attachedNativeHandlers : MutableSet <Int > = mutableSetOf ()
17
17
private var attachedHandlers: MutableSet <Int > = mutableSetOf ()
18
18
private var moduleId: Int = - 1
19
19
@@ -40,6 +40,7 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
40
40
private fun shouldAttachGestureToChildView (tag : Int ): Boolean {
41
41
val registry = RNGestureHandlerModule .registries[moduleId]
42
42
? : throw Exception (" Tried to access a non-existent registry" )
43
+
43
44
return registry.getHandler(tag)?.wantsToAttachDirectlyToView() ? : false
44
45
}
45
46
@@ -69,22 +70,23 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
69
70
for (tag in newHandlers) {
70
71
changes[tag] = if (changes.containsKey(tag)) GestureHandlerMutation .Keep else GestureHandlerMutation .Attach
71
72
}
73
+
72
74
for (entry in changes) {
73
75
val tag = entry.key
74
76
75
77
if (entry.value == GestureHandlerMutation .Attach ) {
76
78
// It might happen that `attachHandlers` will be called before children are added into view hierarchy. In that case we cannot
77
79
// attach `NativeViewGestureHandlers` here and we have to do it in `addView` method.
78
80
if (shouldAttachGestureToChildView(tag)) {
79
- nativeHandlers .add(tag)
81
+ attachedNativeHandlers .add(tag)
80
82
} else {
81
83
registry.attachHandlerToView(tag, this .id, GestureHandler .ACTION_TYPE_NATIVE_DETECTOR )
82
84
83
85
attachedHandlers.add(tag)
84
86
}
85
87
} else if (entry.value == GestureHandlerMutation .Detach ) {
86
88
registry.detachHandler(tag)
87
- nativeHandlers .remove(tag)
89
+ attachedNativeHandlers .remove(tag)
88
90
attachedHandlers.remove(tag)
89
91
}
90
92
}
@@ -101,7 +103,7 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
101
103
val registry = RNGestureHandlerModule .registries[moduleId]
102
104
? : throw Exception (" Tried to access a non-existent registry" )
103
105
104
- for (tag in nativeHandlers ) {
106
+ for (tag in attachedNativeHandlers ) {
105
107
registry.attachHandlerToView(tag, childId, GestureHandler .ACTION_TYPE_NATIVE_DETECTOR )
106
108
107
109
attachedHandlers.add(tag)
@@ -112,7 +114,7 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
112
114
val registry = RNGestureHandlerModule .registries[moduleId]
113
115
? : throw Exception (" Tried to access a non-existent registry" )
114
116
115
- for (tag in nativeHandlers ) {
117
+ for (tag in attachedNativeHandlers ) {
116
118
registry.detachHandler(tag)
117
119
attachedHandlers.remove(tag)
118
120
}
0 commit comments