Skip to content

Commit 355a82f

Browse files
authored
Recycle obtained MotionEvents on Android (#2523)
## Description Adds recycling for `MotionEvents` after they've been used. Closes #2517 ## Test plan Tested on the Example app
1 parent 86d6cef commit 355a82f

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ class NativeViewGestureHandler : GestureHandler<NativeViewGestureHandler>() {
120120
action = MotionEvent.ACTION_CANCEL
121121
}
122122
view!!.onTouchEvent(event)
123+
event.recycle()
123124
}
124125

125126
override fun onReset() {

android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
7676
if (rootView is RootView) {
7777
rootView.onChildStartedNativeGesture(event)
7878
}
79+
event.recycle()
7980
}
8081
}
8182

0 commit comments

Comments
 (0)