mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-23 09:56:00 +03:00
Log filtered out click
This commit is contained in:
parent
ffde34cbb2
commit
2c5418feaa
1 changed files with 5 additions and 3 deletions
|
@ -17,6 +17,7 @@ package im.vector.app.core.utils
|
|||
|
||||
import android.os.SystemClock
|
||||
import android.view.View
|
||||
import timber.log.Timber
|
||||
import java.util.WeakHashMap
|
||||
|
||||
/**
|
||||
|
@ -30,13 +31,14 @@ class DebouncedClickListener(
|
|||
private val lastClickMap = WeakHashMap<View, Long>()
|
||||
|
||||
override fun onClick(v: View) {
|
||||
val previousClickTimestamp = lastClickMap[v]
|
||||
val previousClickTimestamp = lastClickMap[v] ?: 0
|
||||
val currentTimestamp = SystemClock.elapsedRealtime()
|
||||
|
||||
lastClickMap[v] = currentTimestamp
|
||||
|
||||
if (previousClickTimestamp == null || currentTimestamp - previousClickTimestamp > minimumInterval) {
|
||||
if (currentTimestamp > previousClickTimestamp + minimumInterval) {
|
||||
original.onClick(v)
|
||||
} else {
|
||||
Timber.v("Debounced click!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue