Debounced click for all listener

This commit is contained in:
Benoit Marty 2021-05-31 15:44:32 +02:00
parent dddca8ce59
commit 243b6a93f4

View File

@ -17,6 +17,7 @@
package im.vector.app.core.epoxy
import android.view.View
import im.vector.app.core.utils.DebouncedClickListener
/**
* View.OnClickListener lambda
@ -24,5 +25,9 @@ import android.view.View
typealias ClickListener = (View) -> Unit
fun View.onClick(listener: ClickListener?) {
setOnClickListener { listener?.invoke(it) }
if (listener == null) {
setOnClickListener(null)
} else {
setOnClickListener(DebouncedClickListener(listener))
}
}