@@ -76,8 +76,7 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
7676 @Suppress(" UNCHECKED_CAST" )
7777 protected fun self (): ConcreteGestureHandlerT = this as ConcreteGestureHandlerT
7878
79- protected inline fun applySelf (block : ConcreteGestureHandlerT .() -> Unit ): ConcreteGestureHandlerT =
80- self().apply { block() }
79+ protected inline fun applySelf (block : ConcreteGestureHandlerT .() -> Unit ): ConcreteGestureHandlerT = self().apply { block() }
8180
8281 // properties set and accessed only by the orchestrator
8382 var activationIndex = 0
@@ -116,8 +115,7 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
116115 return false
117116 }
118117
119- fun setShouldCancelWhenOutside (shouldCancelWhenOutside : Boolean ): ConcreteGestureHandlerT =
120- applySelf { this .shouldCancelWhenOutside = shouldCancelWhenOutside }
118+ fun setShouldCancelWhenOutside (shouldCancelWhenOutside : Boolean ): ConcreteGestureHandlerT = applySelf { this .shouldCancelWhenOutside = shouldCancelWhenOutside }
121119
122120 fun setEnabled (enabled : Boolean ): ConcreteGestureHandlerT = applySelf {
123121 // Don't cancel handler when not changing the value of the isEnabled, executing it always caused
@@ -131,8 +129,7 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
131129 isEnabled = enabled
132130 }
133131
134- fun setManualActivation (manualActivation : Boolean ): ConcreteGestureHandlerT =
135- applySelf { this .manualActivation = manualActivation }
132+ fun setManualActivation (manualActivation : Boolean ): ConcreteGestureHandlerT = applySelf { this .manualActivation = manualActivation }
136133
137134 fun setHitSlop (
138135 leftPad : Float ,
@@ -157,12 +154,9 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
157154 require(! (hitSlopSet(height) && ! hitSlopSet(bottomPad) && ! hitSlopSet(topPad))) { " When height is set one of top or bottom pads need to be defined" }
158155 }
159156
160- fun setHitSlop (padding : Float ): ConcreteGestureHandlerT {
161- return setHitSlop(padding, padding, padding, padding, HIT_SLOP_NONE , HIT_SLOP_NONE )
162- }
157+ fun setHitSlop (padding : Float ): ConcreteGestureHandlerT = setHitSlop(padding, padding, padding, padding, HIT_SLOP_NONE , HIT_SLOP_NONE )
163158
164- fun setInteractionController (controller : GestureHandlerInteractionController ? ): ConcreteGestureHandlerT =
165- applySelf { interactionController = controller }
159+ fun setInteractionController (controller : GestureHandlerInteractionController ? ): ConcreteGestureHandlerT = applySelf { interactionController = controller }
166160
167161 fun setMouseButton (mouseButton : Int ) = apply {
168162 this .mouseButton = mouseButton
@@ -189,13 +183,12 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
189183
190184 protected open fun onPrepare () {}
191185
192- private fun getActivity (context : Context ? ): Activity ? =
193- when (context) {
194- is ReactContext -> context.currentActivity
195- is Activity -> context
196- is ContextWrapper -> getActivity(context.baseContext)
197- else -> null
198- }
186+ private fun getActivity (context : Context ? ): Activity ? = when (context) {
187+ is ReactContext -> context.currentActivity
188+ is Activity -> context
189+ is ContextWrapper -> getActivity(context.baseContext)
190+ else -> null
191+ }
199192
200193 private fun findNextLocalPointerId (): Int {
201194 var localPointerId = 0
@@ -308,7 +301,7 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
308301 event.deviceId,
309302 event.edgeFlags,
310303 event.source,
311- event.flags
304+ event.flags,
312305 )
313306 } catch (e: IllegalArgumentException ) {
314307 throw AdaptEventException (this , event, e)
@@ -322,7 +315,7 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
322315 class AdaptEventException (
323316 handler : GestureHandler <* >,
324317 event : MotionEvent ,
325- e : IllegalArgumentException
318+ e : IllegalArgumentException ,
326319 ) : Exception(
327320 """
328321 handler: ${handler::class .simpleName}
@@ -336,7 +329,7 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
336329 trackedPointers: ${handler.trackedPointerIDs.joinToString(separator = " , " )}
337330 while handling event: $event
338331 """ .trimIndent(),
339- e
332+ e,
340333 )
341334
342335 fun handle (transformedEvent : MotionEvent , sourceEvent : MotionEvent ) {
@@ -570,13 +563,11 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
570563 onStateChange(newState, oldState)
571564 }
572565
573- fun wantEvents (): Boolean {
574- return isEnabled &&
575- state != STATE_FAILED &&
576- state != STATE_CANCELLED &&
577- state != STATE_END &&
578- trackedPointersIDsCount > 0
579- }
566+ fun wantEvents (): Boolean = isEnabled &&
567+ state != STATE_FAILED &&
568+ state != STATE_CANCELLED &&
569+ state != STATE_END &&
570+ trackedPointersIDsCount > 0
580571
581572 open fun shouldRequireToWaitForFailure (handler : GestureHandler <* >): Boolean {
582573 if (handler == = this ) {
@@ -690,9 +681,9 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
690681 }
691682
692683 /*
693- * Returns true if the view this handler is attached to is a descendant of the view the other handler
694- * is attached to and false otherwise.
695- */
684+ * Returns true if the view this handler is attached to is a descendant of the view the other handler
685+ * is attached to and false otherwise.
686+ */
696687 fun isDescendantOf (of : GestureHandler <* >): Boolean {
697688 var view = this .view?.parent as ? View
698689 while (view != null ) {
@@ -767,12 +758,10 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
767758 *
768759 * This method modifies and transforms the received point.
769760 */
770- protected fun transformPoint (point : PointF ): PointF {
771- return orchestrator?.transformPointToViewCoords(this .view, point) ? : run {
772- point.x = Float .NaN
773- point.y = Float .NaN
774- point
775- }
761+ protected fun transformPoint (point : PointF ): PointF = orchestrator?.transformPointToViewCoords(this .view, point) ? : run {
762+ point.x = Float .NaN
763+ point.y = Float .NaN
764+ point
776765 }
777766 fun reset () {
778767 view = null
@@ -865,9 +854,7 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
865854 }
866855
867856 private var nextEventCoalescingKey: Short = 0
868- private fun hitSlopSet (value : Float ): Boolean {
869- return ! java.lang.Float .isNaN(value)
870- }
857+ private fun hitSlopSet (value : Float ): Boolean = ! java.lang.Float .isNaN(value)
871858
872859 fun stateToString (state : Int ): String? {
873860 when (state) {
@@ -887,6 +874,6 @@ open class GestureHandler<ConcreteGestureHandlerT : GestureHandler<ConcreteGestu
887874 var x : Float ,
888875 var y : Float ,
889876 var absoluteX : Float ,
890- var absoluteY : Float
877+ var absoluteY : Float ,
891878 )
892879}
0 commit comments