Double et simple Click sur une Vue en KOTLIN

L'astuce est d'utiliser une coroutine dans le CoroutineScope  GlobalScope:

Voilà le code:

itemView.setOnClickListener {

   clickCount++

   if (clickCount == 1){

           l1 = GlobalScope.launch(Dispatchers.Main) {

               delay(500L)

               actionSimple(it!!.context!!, it, adapterPosition)

               clickCount=0

           }

       }

   if (clickCount == 2){

       l1!!.cancel()

       actionDouble(it!!.context!!, it, adapterPosition)

       clickCount=0

   }

}