In my RecyclerView I need to implement a long touch listener for trigger some logic when a user press on a item of the list.
I code in Kotlin.

First, to do that I create this interface

```
    interface TouchListener {
    fun onLongTouch(view: View, position: Int)
    }

```

Then I implement the RecyclerView.OnItemTouchListener

```
class RecyclerTouchListener(context: Context, recycleView: RecyclerView , private val touchListener: TouchListener?) : RecyclerView.OnItemTouchListener {
    private var gestureDetector: GestureDetectorCompat? = null

    init {
        gestureDetector = GestureDetectorCompat(context, object : SimpleOnGestureListener() {
            override fun onDown(event: MotionEvent): Boolean {
                //this code is never reached
                Log.i("Gestures", "onDown !")
                return true
            }

            override fun onLongPress(e: MotionEvent?) {
                //this code is never reached
                Log.i("Gestures", "onLongPress !")
                val child = if (e != null) recycleView.findChildViewUnder(e.x, e.y) else return
                touchListener?.onLongTouch(child, recycleView.getChildAdapterPosition(child))
            }
        })
    }

    override fun onInterceptTouchEvent(rv: RecyclerView?, e: MotionEvent?): Boolean {
        return false
    }

    //mandatory implementations
    override fun onTouchEvent(rv: RecyclerView?, e: MotionEvent?) {}
    override fun onRequestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {}
}

```

Here is my RecyclerView's Adapter

```
class TaskAdapter(tasks: MutableList<Task> = ArrayList()) : RecyclerView.Adapter<TaskAdapter.TaskViewHolder>() {

    var tasks: MutableList<Task> = tasks
        set(value) {
            field = value
            notifyDataSetChanged()
        }

    override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): TaskViewHolder {
        val context = parent?.context
        val view = LayoutInflater.from(context)?.inflate(R.layout.list_item_task, parent, false)
        return TaskViewHolder(view)
    }

    override fun getItemCount(): Int {
        return tasks.size
    }

    override fun onBindViewHolder(holder: TaskViewHolder?, position: Int) {
        holder?.bindTask(tasks[position])
    }

    fun addTask(task: Task) {
        tasks.add(task)
        notifyDataSetChanged()
    }

    fun removeTask(task: Task) {
        tasks.remove(task)
        notifyDataSetChanged()
    }

    inner class TaskViewHolder(view: View?) : RecyclerView.ViewHolder(view) {
        private val descriptionTextView = view?.findViewById(R.id.task_description) as TextView
        private val completedCheckBox = view?.findViewById(R.id.task_completed) as CheckBox

        fun bindTask(task: Task) {
            descriptionTextView.text = task.description
            completedCheckBox.isChecked = task.completed

            completedCheckBox.setOnCheckedChangeListener { _, isChecked ->
                tasks[adapterPosition].completed = isChecked
            }
        }
    }
}

```

So now in my MainActivity I call the `recyclerView.addOnItemTouchListener()` to set my custom RecyclerTouchListener and implement my own TouchListener interface.

```
 class MainActivity : AppCompatActivity() {

    private var adapter: TaskAdapter? = TaskAdapter()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val recyclerView = findViewById<RecyclerView>(R.id.task_list)
        recyclerView.layoutManager = LinearLayoutManager(this)
        recyclerView.addOnItemTouchListener(RecyclerTouchListener(this, recyclerView, object : TouchListener {
            override fun onLongTouch(view: View, position: Int) {
                //again this code is never reached
                Log.i("Gestures", "onLongPress !")
                Toast.makeText(this@MainActivity, "Long touch on position        :"+position,
                        Toast.LENGTH_SHORT).show()
            }
        }))
        recyclerView.adapter = adapter
    }

```

The problem is this code compile and run perfectly but the long press listener is never triggered. And I'm totally stuck on it. Where i'm wrong?