Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address compilation warnings #2597

Merged
merged 16 commits into from
Mar 12, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -835,15 +835,15 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
private lateinit var pointerProps: Array<PointerProperties?>
private lateinit var pointerCoords: Array<PointerCoords?>
private fun initPointerProps(size: Int) {
var size = size
var pointerPropsSize = size
if (!Companion::pointerProps.isInitialized) {
pointerProps = arrayOfNulls(MAX_POINTERS_COUNT)
pointerCoords = arrayOfNulls(MAX_POINTERS_COUNT)
}
while (size > 0 && pointerProps[size - 1] == null) {
pointerProps[size - 1] = PointerProperties()
pointerCoords[size - 1] = PointerCoords()
size--
while (pointerPropsSize > 0 && pointerProps[pointerPropsSize - 1] == null) {
pointerProps[pointerPropsSize - 1] = PointerProperties()
pointerCoords[pointerPropsSize - 1] = PointerCoords()
pointerPropsSize--
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import com.facebook.react.ReactRootView

@Deprecated(message = "Use <GestureHandlerRootView /> component instead. Check gesture handler installation instructions in documentation for more information.")
class RNGestureHandlerEnabledRootView : ReactRootView {
constructor(context: Context?) : super(context) {}
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {}
constructor(context: Context?) : super(context)
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)

init {
throw UnsupportedOperationException("Your application is configured to use RNGestureHandlerEnabledRootView which is no longer supported. You can see how to migrate to <GestureHandlerRootView /> here: https://docs.swmansion.com/react-native-gesture-handler/docs/guides/migrating-off-rnghenabledroot")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
action = MotionEvent.ACTION_CANCEL
}
if (rootView is RootView) {
rootView.onChildStartedNativeGesture(event)
rootView.onChildStartedNativeGesture(this.view, event)
m-bert marked this conversation as resolved.
Show resolved Hide resolved
}
event.recycle()
}
}

@Suppress("UNUSED_PARAMETER", "COMMENT_IN_SUPPRESSION")
// This parameter may be useful in the future
m-bert marked this conversation as resolved.
Show resolved Hide resolved
fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {
// If this method gets called it means that some native view is attempting to grab lock for
// touch event delivery. In that case we cancel all gesture recognizers
Expand Down Expand Up @@ -116,6 +118,8 @@ class RNGestureHandlerRootHelper(private val context: ReactContext, wrappedView:
}

/*package*/
@Suppress("UNUSED_PARAMETER", "COMMENT_IN_SUPPRESSION")
// We want to keep order of parameters, so instead of removing viewTag we suppress the warning
fun handleSetJSResponder(viewTag: Int, blockNativeResponder: Boolean) {
if (blockNativeResponder) {
UiThreadUtil.runOnUiThread { tryCancelAllHandlers() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ 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.facebook.react.uimanager.events.RCTEventEmitter
import com.swmansion.gesturehandler.core.GestureHandler

class RNGestureHandlerTouchEvent private constructor() : Event<RNGestureHandlerTouchEvent>() {
private var extraData: WritableMap? = null
private var coalescingKey: Short = 0
private fun <T : GestureHandler<T>> init(handler: T) {
super.init(handler.view!!.id)
super.init(UIManagerHelper.getSurfaceId(handler.view), handler.view!!.id)
extraData = createEventData(handler)
coalescingKey = handler.eventCoalescingKey
}
Expand All @@ -26,10 +26,7 @@ class RNGestureHandlerTouchEvent private constructor() : Event<RNGestureHandlerT
override fun canCoalesce() = true

override fun getCoalescingKey() = coalescingKey

override fun dispatch(rctEventEmitter: RCTEventEmitter) {
rctEventEmitter.receiveEvent(viewTag, EVENT_NAME, extraData)
}
override fun getEventData(): WritableMap? = extraData

companion object {
const val EVENT_UNDETERMINED = 0
Expand All @@ -47,7 +44,7 @@ class RNGestureHandlerTouchEvent private constructor() : Event<RNGestureHandlerT
init(handler)
}

fun <T : GestureHandler<T>> createEventData(handler: T,): WritableMap = Arguments.createMap().apply {
fun <T : GestureHandler<T>> createEventData(handler: T): WritableMap = Arguments.createMap().apply {
putInt("handlerTag", handler.tag)
putInt("state", handler.state)
putInt("numberOfTouches", handler.trackedPointersCount)
Expand Down
Loading