Skip to content

Commit

Permalink
Add Handler.postDelayed convenience wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
janseeger committed Dec 16, 2024
1 parent c4d3e78 commit 3ab6916
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.sipgate.dachlatten.datetime

import android.os.Handler
import kotlin.time.Duration
import androidx.core.os.postDelayed
import kotlin.time.Duration

/**
* Version of [Handler.postDelayed] which re-orders the parameters, allowing the action to be placed
Expand All @@ -21,8 +21,12 @@ inline fun Handler.postDelayed(
delay: Duration,
token: Any? = null,
crossinline action: () -> Unit
) = postDelayed(
): Runnable = postDelayed(
delayInMillis = delay.inWholeMilliseconds,
token = token,
action = action
)

@Suppress("unused")
fun Handler.postDelayed(delay: Duration, runnable: Runnable): Boolean =
postDelayed(runnable, delay.inWholeMilliseconds)

0 comments on commit 3ab6916

Please sign in to comment.