Hi! What is the diference between Java `Runnable` ...
# android
e
Hi! What is the diference between Java
Runnable
and Kotlin
() -> Unit
? I mean I have in kotlin the next Runnable code
val mResetTapsCounterRunnable = Runnable { mTapsCounter = 0 }
and in an on click event I have a handler like this
Copy code
mHandler.removeCallbacks(mResetTapsCounterRunnable)
mHandler.postDelayed(mResetTapsCounterRunnable, mDelayMillisToResetTapsCounter.toLong())
With this everything works as I hope(the runnable is removed and readded to the handler). But if I change the runnable declaration to a lambda expression like this
val mResetTapsCounterRunnable = { mTapsCounter = 0 }
kotlin compiles well but it is not been removed from the hadler with the
removeCallbacks()
method and the
mResetTapsCounterRunnable
is invoked.