From dc78ad1bf2d204f36ab37250e4869118eb9ba602 Mon Sep 17 00:00:00 2001 From: Mason L'Amy <12562266+masonlamy@users.noreply.github.com> Date: Thu, 22 Aug 2024 08:20:05 +0100 Subject: [PATCH] Add nullability checks to RootSheetView (#86) Co-authored-by: Jovanni Lo --- .../com/lodev09/truesheet/core/RootSheetView.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/lodev09/truesheet/core/RootSheetView.kt b/android/src/main/java/com/lodev09/truesheet/core/RootSheetView.kt index 004d251..501cd3e 100644 --- a/android/src/main/java/com/lodev09/truesheet/core/RootSheetView.kt +++ b/android/src/main/java/com/lodev09/truesheet/core/RootSheetView.kt @@ -99,14 +99,14 @@ class RootSheetView(private val context: Context?) : get() = context as ThemedReactContext override fun onInterceptTouchEvent(event: MotionEvent): Boolean { - jSTouchDispatcher.handleTouchEvent(event, eventDispatcher) + eventDispatcher?.let { jSTouchDispatcher.handleTouchEvent(event, it) } jSPointerDispatcher?.handleMotionEvent(event, eventDispatcher, true) return super.onInterceptTouchEvent(event) } @SuppressLint("ClickableViewAccessibility") override fun onTouchEvent(event: MotionEvent): Boolean { - jSTouchDispatcher.handleTouchEvent(event, eventDispatcher) + eventDispatcher?.let { jSTouchDispatcher.handleTouchEvent(event, it) } jSPointerDispatcher?.handleMotionEvent(event, eventDispatcher, false) super.onTouchEvent(event) @@ -127,16 +127,20 @@ class RootSheetView(private val context: Context?) : @Deprecated("Deprecated in Java") override fun onChildStartedNativeGesture(ev: MotionEvent?) { - jSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher) + eventDispatcher?.let { + if (ev != null) { + jSTouchDispatcher.onChildStartedNativeGesture(ev, it) + } + } } override fun onChildStartedNativeGesture(childView: View, ev: MotionEvent) { - jSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher) + eventDispatcher?.let { jSTouchDispatcher.onChildStartedNativeGesture(ev, it) } jSPointerDispatcher?.onChildStartedNativeGesture(childView, ev, eventDispatcher) } override fun onChildEndedNativeGesture(childView: View, ev: MotionEvent) { - jSTouchDispatcher.onChildEndedNativeGesture(ev, eventDispatcher) + eventDispatcher?.let { jSTouchDispatcher.onChildEndedNativeGesture(ev, it) } jSPointerDispatcher?.onChildEndedNativeGesture() }