Blog Infos
Author
Published
Topics
,
Published
Posted By: Udit Verma
@Composable
fun TimerScreen() {
LaunchedEffect(key1 = Unit, block = {
try {
startTimer(5000L) { // start a timer for 5 secs
println("Timer ended")
}
} catch(ex: Exception) {
println("timer cancelled")
}
})
}
suspend fun startTimer(time: Long, onTimerEnd: () -> Unit) {
delay(timeMillis = time)
onTimerEnd()
}
@Composable
fun TimerScreen1() {
Column(
modifier = Modifier
.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally
) {
var timerDuration by remember {
mutableStateOf(1000L) // default value = 1 sec
}
Button({
timerDuration -= 1000
}) {
Text("-1 second")
}
Text(timerDuration.toString())
Button({
timerDuration += 1000
}) {
Text("+1 second")
}
Timer(timerDuration = timerDuration)
}
}
@Composable
fun Timer(timerDuration: Long) {
LaunchedEffect(key1 = timerDuration, block = {
try {
startTimer(timerDuration) {
println("Timer ended")
}
} catch (ex: Exception) {
println("timer cancelled")
}
})
}

Job Offers

Job Offers


    Android Manager (all genders)

    Babbel
    Berlin
    • Full Time
    apply now

    Android Engineer (d/f/m)

    Mobimeo GmbH
    Berlin or Hamburg
    • Full Time
    apply now

    Senior Android Engineer – Big Release Team

    Zalando SE
    Berlin
    • Full Time
    apply now
Load more listings

RECOMMENDED VIDEO

, , ,

Painless Persistence on Kotlin Multiplatform with Realm Kotlin

In this session, we will explore a fast, intuitive way to build great mobile applications using Realm’s new Kotlin SDK with Multiplatform support. We will dive deeper into how we evolved the Realm Java SDK to be a fully native Kotlin Multiplatform SDK. You will learn how Realm’s natural object model combined with Kotlin features like…
READ MORE

<h3>Jobs</h3>

YOU MAY BE INTERESTED IN

YOU MAY BE INTERESTED IN

blog
Nowadays authentication has become common in almost all apps. And many of us know…
READ MORE
blog
Collections are a set of interfaces and classes that implement highly optimised data structures.…
READ MORE
blog
Hi, today I come to you with a quick tip on how to update…
READ MORE
blog

How to animate BottomSheet content using Jetpack Compose

Early this year I started a new pet project for listening to random radio…
READ MORE

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

Menu