From 243b6a93f42f57606a35aeba99c891e3557a9817 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 31 May 2021 15:44:32 +0200 Subject: [PATCH] Debounced click for all listener --- vector/src/main/java/im/vector/app/core/epoxy/Listener.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/core/epoxy/Listener.kt b/vector/src/main/java/im/vector/app/core/epoxy/Listener.kt index b4fee0c810..178fb0b48c 100644 --- a/vector/src/main/java/im/vector/app/core/epoxy/Listener.kt +++ b/vector/src/main/java/im/vector/app/core/epoxy/Listener.kt @@ -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)) + } }