title: How to implement onClick, onLongClick and onTouch to one View
body: <p>I have a View (it's ViewHolder in RecyclerView but I think it wouldn't make any difference) which implements <code>onClick()</code>, <code>onLongClick()</code>, and <code>onTouch()</code>. The problem I faced is that <code>longClick</code> is never executed. I read about it in other questions but I can't figure out how to do it and when exactly I should return <code>true</code> \ <code>false</code> in <code>onTouch()</code>. Here is my code;</p>
  <p><strong>Function <code>bind()</code> in ViewHolder class which implements <code>View.OnTouchListener</code>:</strong></p>
  <pre><code>binding.background.setOnClickListener {
      Log.d(&quot;Click&quot;)
  }
  
  binding.background.setOnLongClickListener {
      Log.d(&quot;Long Click&quot;)
  }
  
  binding.background.setOnTouchListener(this) // here I see warning &quot;Custom view `ConstraintLayout` has setOnTouchListener called on it but does not override performClick&quot;
  </code></pre>
  <p><strong>Override onTouch()</strong></p>
  <pre><code>override fun onTouch(v: View?, event: MotionEvent?): Boolean
  {
      return when (event!!.action)
      {
          MotionEvent.ACTION_DOWN -&gt;
          {
              x1 = event.x
              true
          }
              MotionEvent.ACTION_UP -&gt;
          {
              x2 = event.x
              return if (abs(x2 - x1) &gt; MIN_DISTANCE)
              {
                  Log.d(&quot;Was swiped&quot;)
                  true
              }
              else
              {
                  Log.d(&quot;Wasn't swiped&quot;)
                  v?.performClick()
                  false
              }
          }
          else -&gt; false
      }
  }
  </code></pre>
  <p>This function just detects slide on the view. What should I change in <code>onTouch()</code> to make <code>longClick</code> working? Also, is there any simpler way to detect slide on the RecyclerView item?</p>