Skip to content

Commit

Permalink
Use newer constructor for all Gesture Handler events on Android (#2967)
Browse files Browse the repository at this point in the history
## Description

Updates events to use the newer constructor with `surfaceId`.

## Test plan

Check the example app
  • Loading branch information
j-piasecki authored Jun 28, 2024
1 parent 30fd318 commit 1747123
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package com.swmansion.gesturehandler.react
import androidx.core.util.Pools
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.UIManagerHelper
import com.facebook.react.uimanager.events.Event
import com.swmansion.gesturehandler.core.GestureHandler
import com.swmansion.gesturehandler.react.eventbuilders.GestureHandlerEventDataBuilder
Expand All @@ -29,7 +30,8 @@ class RNGestureHandlerEvent private constructor() : Event<RNGestureHandlerEvent>
dataBuilder: GestureHandlerEventDataBuilder<T>,
useNativeAnimatedName: Boolean
) {
super.init(handler.view!!.id)
val view = handler.view!!
super.init(UIManagerHelper.getSurfaceId(view), view.id)
this.dataBuilder = dataBuilder
this.useTopPrefixedName = useNativeAnimatedName
coalescingKey = handler.eventCoalescingKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package com.swmansion.gesturehandler.react
import androidx.core.util.Pools
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.UIManagerHelper
import com.facebook.react.uimanager.events.Event
import com.swmansion.gesturehandler.core.GestureHandler
import com.swmansion.gesturehandler.react.eventbuilders.GestureHandlerEventDataBuilder
Expand All @@ -24,7 +25,8 @@ class RNGestureHandlerStateChangeEvent private constructor() : Event<RNGestureHa
oldState: Int,
dataBuilder: GestureHandlerEventDataBuilder<T>,
) {
super.init(handler.view!!.id)
val view = handler.view!!
super.init(UIManagerHelper.getSurfaceId(view), view.id)
this.dataBuilder = dataBuilder
this.newState = newState
this.oldState = oldState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class RNGestureHandlerTouchEvent private constructor() : Event<RNGestureHandlerT
private var extraData: WritableMap? = null
private var coalescingKey: Short = 0
private fun <T : GestureHandler<T>> init(handler: T) {
super.init(UIManagerHelper.getSurfaceId(handler.view), handler.view!!.id)
val view = handler.view!!
super.init(UIManagerHelper.getSurfaceId(view), view.id)
extraData = createEventData(handler)
coalescingKey = handler.eventCoalescingKey
}
Expand Down

0 comments on commit 1747123

Please sign in to comment.