title: GestureListener.onFling kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter e1 - Android
body: <p>I am manage <code>onSwipeRight</code> and <code>onSwipeLeft</code> on <code>recyclerView</code> like bellow:</p>
  
  <pre><code>override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
     super.onViewCreated(view, savedInstanceState)
          val swipeController = SwipeController(this)
          val itemTouchhelper = ItemTouchHelper(swipeController)
          itemTouchhelper.attachToRecyclerView(recycler_view)
  
          recycler_view.setOnTouchListener(object : OnSwipeTouchListener(activity!!) {
              override fun onSwipeLeft() {
                  val intent = Intent(activity, MainActivity::class.java)
                  intent.putExtra("ONE", 1)
                  intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
                  startActivity(intent)
                  activity!!.finish()
              }
  
              override fun onSwipeRight() {
          })
  }
  </code></pre>
  
  <p>And my <code>OnSwipeTouchListener.kt</code>:</p>
  
  <pre><code>open class OnSwipeTouchListener(context: Context) : View.OnTouchListener {
      var context: Context? = context
  
      private val gestureDetector = GestureDetector(context, GestureListener())
  
      fun onTouch(event: MotionEvent): Boolean {
          return gestureDetector.onTouchEvent(event)
      }
  
      private inner class GestureListener : GestureDetector.SimpleOnGestureListener() {
  
          private val SWIPE_THRESHOLD = 100
          private val SWIPE_VELOCITY_THRESHOLD = 100
  
          override fun onDown(e: MotionEvent): Boolean {
              return true
          }
  
          override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
              onTouch(e)
              return true
          }
  
  
          override fun onFling(e1: MotionEvent, e2: MotionEvent, velocityX: Float, velocityY: Float): Boolean {
              val result = false
              try {
                  val diffY = e2.y - e1.y
                  val diffX = e2.x - e1.x
                  if (Math.abs(diffX) &gt; Math.abs(diffY)) {
                      if (Math.abs(diffX) &gt; SWIPE_THRESHOLD &amp;&amp; Math.abs(velocityX) &gt; SWIPE_VELOCITY_THRESHOLD) {
                          if (diffX &gt; 0) {
                              onSwipeRight()
                          } else {
                              onSwipeLeft()
                          }
                      }
                  } else {
                      // onTouch(e);
                  }
              } catch (exception: Exception) {
                  exception.printStackTrace()
              }
  
              return result
          }
      }
  
      @SuppressLint("ClickableViewAccessibility")
      override fun onTouch(v: View, event: MotionEvent): Boolean {
          return gestureDetector.onTouchEvent(event)
      }
  
      open fun onSwipeRight() {}
  
      open fun onSwipeLeft() {}
  }
  </code></pre>
  
  <p>And <code>SwipeController.kt</code>:</p>
  
  <pre><code>internal class SwipeController(private val swipeControllerInter: SwipeControllerInter) : ItemTouchHelper.Callback() {
      private var swipeBack = false
  
      interface SwipeControllerInter {
          fun left()
  
          fun right()
      }
  
      override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int {
          return makeMovementFlags(0, LEFT or RIGHT)
      }
  
      override fun onMove(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean {
          return false
      }
  
      override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
  
      }
  
      override fun convertToAbsoluteDirection(flags: Int, layoutDirection: Int): Int {
          if (swipeBack) {
              swipeBack = false
              return 0
          }
          return super.convertToAbsoluteDirection(flags, layoutDirection)
      }
  
      override fun onChildDraw(c: Canvas,
                               recyclerView: RecyclerView,
                               viewHolder: RecyclerView.ViewHolder,
                               dX: Float, dY: Float,
                               actionState: Int, isCurrentlyActive: Boolean) {
  
          if (actionState == ACTION_STATE_SWIPE) {
              if (dX &gt; 0) {
                  // then swiping right.
                  swipeControllerInter.right()
              } else if (dX &lt; 0) {
                  // then swiping left.
                  swipeControllerInter.left()
              }
              // If dX == 0 then at at start position.
          } else {
              super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive)
          }
  
          if (actionState == ACTION_STATE_SWIPE) {
              setTouchListener(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive)
          }
          super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive)
      }
  
      @SuppressLint("ClickableViewAccessibility")
      private fun setTouchListener(c: Canvas,
                                   recyclerView: RecyclerView,
                                   viewHolder: RecyclerView.ViewHolder,
                                   dX: Float, dY: Float,
                                   actionState: Int, isCurrentlyActive: Boolean) {
  
          recyclerView.setOnTouchListener { v, event -&gt;
              swipeBack = event.action == MotionEvent.ACTION_CANCEL || event.action == MotionEvent.ACTION_UP
              false
          }
      }
  
  }
  </code></pre>
  
  <p>But when I see my <code>fireBase</code> I see bellow <code>crash</code>:</p>
  
  <pre><code>Fatal Exception: java.lang.IllegalArgumentException
  Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter e1
  xx.xx.xx.tools.OnSwipeTouchListener$GestureListener.onFling (OnSwipeTouchListener.kt)
  </code></pre>