On specific events I want to stop a handler. I want a target to fade after several seconds. I want to interrupt and immediately fade (or extend time before fading how can I do this? What is the new best practice for accomplishing this? Here is existing code:
private fun startTargetFade(target: Target, delayMs: Long = 2000) {
Handler(Looper.getMainLooper()).postDelayed({
target.isVisible = false
viewModel.remove(target)
}, delayMs)
}