mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Debounced click for all listener
This commit is contained in:
parent
dddca8ce59
commit
243b6a93f4
@ -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))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user