Created
August 19, 2021 09:26
-
-
Save thesiamak/7a4732b178db9aa35e0bcea767e72541 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DisplayTimer (context: Context) : LinearLayout(context) | |
, LifecycleObserver { | |
private var timer:Timer? =null | |
@OnLifecycleEvent(Lifecycle.Event.ON_RESUME) | |
fun igniteTimer(){ | |
timer = Timer("ring the bell").apply{ | |
schedule(object : TimerTask() { | |
override fun run() { | |
Tick() | |
} | |
},200_000, 250) | |
} | |
} | |
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE) | |
private fun release(){ | |
timer?.cancel() | |
timer?.purge() | |
} | |
private fun Tick() { | |
// update the countdown timer view here | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment