Simpler code

This commit is contained in:
Benoit Marty 2020-04-15 12:53:08 +02:00
parent 667b371653
commit 6639f89a68

View File

@ -23,12 +23,9 @@ internal class Debouncer(private val handler: Handler) {
private val runnables = HashMap<String, Runnable>()
fun debounce(identifier: String, r: Runnable, millis: Long): Boolean {
if (runnables.containsKey(identifier)) {
// debounce
runnables[identifier]?.let {
handler.removeCallbacks(it)
}
}
runnables[identifier]?.let { runnable -> handler.removeCallbacks(runnable) }
insertRunnable(identifier, r, millis)
return true
}