Skip to content

Instantly share code, notes, and snippets.

View neronguyen's full-sized avatar

neronguyen

View GitHub Profile
@neronguyen
neronguyen / ThrottledClickExtension.md
Last active November 4, 2024 03:42
Kotlin Throttled Click Extension for Views

Prevents multiple rapid clicks by disabling the view temporarily after a click, helping avoid unintended repeated actions.

fun View.onThrottledClick(
    throttleDelay: Long = 500L,
    onClick: (View) -> Unit
) {
    setOnClickListener {
        onClick(this)
 isClickable = false