mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 09:56:00 +03:00
Debounced click for all listener
This commit is contained in:
parent
dddca8ce59
commit
243b6a93f4
1 changed files with 6 additions and 1 deletions
|
@ -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 a new issue