Skip to content

Commit dc78ad1

Browse files
masonlamylodev09
andauthored
Add nullability checks to RootSheetView (#86)
Co-authored-by: Jovanni Lo <lodev09@gmail.com>
1 parent c4177e6 commit dc78ad1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

android/src/main/java/com/lodev09/truesheet/core/RootSheetView.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ class RootSheetView(private val context: Context?) :
9999
get() = context as ThemedReactContext
100100

101101
override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
102-
jSTouchDispatcher.handleTouchEvent(event, eventDispatcher)
102+
eventDispatcher?.let { jSTouchDispatcher.handleTouchEvent(event, it) }
103103
jSPointerDispatcher?.handleMotionEvent(event, eventDispatcher, true)
104104
return super.onInterceptTouchEvent(event)
105105
}
106106

107107
@SuppressLint("ClickableViewAccessibility")
108108
override fun onTouchEvent(event: MotionEvent): Boolean {
109-
jSTouchDispatcher.handleTouchEvent(event, eventDispatcher)
109+
eventDispatcher?.let { jSTouchDispatcher.handleTouchEvent(event, it) }
110110
jSPointerDispatcher?.handleMotionEvent(event, eventDispatcher, false)
111111
super.onTouchEvent(event)
112112

@@ -127,16 +127,20 @@ class RootSheetView(private val context: Context?) :
127127

128128
@Deprecated("Deprecated in Java")
129129
override fun onChildStartedNativeGesture(ev: MotionEvent?) {
130-
jSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher)
130+
eventDispatcher?.let {
131+
if (ev != null) {
132+
jSTouchDispatcher.onChildStartedNativeGesture(ev, it)
133+
}
134+
}
131135
}
132136

133137
override fun onChildStartedNativeGesture(childView: View, ev: MotionEvent) {
134-
jSTouchDispatcher.onChildStartedNativeGesture(ev, eventDispatcher)
138+
eventDispatcher?.let { jSTouchDispatcher.onChildStartedNativeGesture(ev, it) }
135139
jSPointerDispatcher?.onChildStartedNativeGesture(childView, ev, eventDispatcher)
136140
}
137141

138142
override fun onChildEndedNativeGesture(childView: View, ev: MotionEvent) {
139-
jSTouchDispatcher.onChildEndedNativeGesture(ev, eventDispatcher)
143+
eventDispatcher?.let { jSTouchDispatcher.onChildEndedNativeGesture(ev, it) }
140144
jSPointerDispatcher?.onChildEndedNativeGesture()
141145
}
142146

0 commit comments

Comments
 (0)