@@ -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 nativeHandlersToAttach : MutableSet <Int > = mutableSetOf ()
16
+ private var nativeHandlers : MutableSet <Int > = mutableSetOf ()
17
17
private var attachedHandlers: MutableSet <Int > = mutableSetOf ()
18
18
private var moduleId: Int = - 1
19
19
@@ -40,7 +40,6 @@ 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
-
44
43
return registry.getHandler(tag)?.wantsToAttachDirectlyToView() ? : false
45
44
}
46
45
@@ -77,14 +76,15 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
77
76
// It might happen that `attachHandlers` will be called before children are added into view hierarchy. In that case we cannot
78
77
// attach `NativeViewGestureHandlers` here and we have to do it in `addView` method.
79
78
if (shouldAttachGestureToChildView(tag)) {
80
- nativeHandlersToAttach .add(tag)
79
+ nativeHandlers .add(tag)
81
80
} else {
82
81
registry.attachHandlerToView(tag, this .id, GestureHandler .ACTION_TYPE_NATIVE_DETECTOR )
83
82
84
83
attachedHandlers.add(tag)
85
84
}
86
85
} else if (entry.value == GestureHandlerMutation .Detach ) {
87
86
registry.detachHandler(tag)
87
+ nativeHandlers.remove(tag)
88
88
attachedHandlers.remove(tag)
89
89
}
90
90
}
@@ -101,24 +101,20 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) {
101
101
val registry = RNGestureHandlerModule .registries[moduleId]
102
102
? : throw Exception (" Tried to access a non-existent registry" )
103
103
104
- for (tag in nativeHandlersToAttach ) {
104
+ for (tag in nativeHandlers ) {
105
105
registry.attachHandlerToView(tag, childId, GestureHandler .ACTION_TYPE_NATIVE_DETECTOR )
106
106
107
107
attachedHandlers.add(tag)
108
108
}
109
-
110
- nativeHandlersToAttach.clear()
111
109
}
112
110
113
111
private fun detachNativeGestureHandlers () {
114
112
val registry = RNGestureHandlerModule .registries[moduleId]
115
113
? : throw Exception (" Tried to access a non-existent registry" )
116
114
117
- for (tag in attachedHandlers) {
118
- if (shouldAttachGestureToChildView(tag)) {
119
- registry.detachHandler(tag)
120
- attachedHandlers.remove(tag)
121
- }
115
+ for (tag in nativeHandlers) {
116
+ registry.detachHandler(tag)
117
+ attachedHandlers.remove(tag)
122
118
}
123
119
}
124
120
0 commit comments