aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/ambientaddons/utils
diff options
context:
space:
mode:
authorAppability <appable@icloud.com>2022-10-30 20:42:56 -0700
committerAppability <appable@icloud.com>2022-11-01 10:37:47 -0700
commit38e6266d2e608f376833dc9bc0c1074bed24535b (patch)
treeecf6e02eca2263b0bf4f5b8791143153dd826470 /src/main/kotlin/com/ambientaddons/utils
parenta0c2f3baf572c747321812241ad941f79218c875 (diff)
downloadAmbientAddons-38e6266d2e608f376833dc9bc0c1074bed24535b.tar.gz
AmbientAddons-38e6266d2e608f376833dc9bc0c1074bed24535b.tar.bz2
AmbientAddons-38e6266d2e608f376833dc9bc0c1074bed24535b.zip
kuudra HP display features
Diffstat (limited to 'src/main/kotlin/com/ambientaddons/utils')
-rw-r--r--src/main/kotlin/com/ambientaddons/utils/Timer.kt30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/main/kotlin/com/ambientaddons/utils/Timer.kt b/src/main/kotlin/com/ambientaddons/utils/Timer.kt
new file mode 100644
index 0000000..dab30b2
--- /dev/null
+++ b/src/main/kotlin/com/ambientaddons/utils/Timer.kt
@@ -0,0 +1,30 @@
+package com.ambientaddons.utils
+
+class Timer {
+ private var previousTime: Long = 0
+ private var startTime: Long? = null
+
+ var isRunning: Boolean = false
+ private set
+
+ private val sessionTime: Long
+ get() {
+ return startTime?.let { System.currentTimeMillis() - it } ?: 0
+ }
+
+ private val time: Long
+ get() {
+ return sessionTime?.let { it + previousTime } ?: 0
+ }
+
+ fun start() {
+ isRunning = true
+ startTime = System.currentTimeMillis()
+ }
+
+ fun stop() {
+ isRunning = false
+ previousTime = sessionTime
+ startTime = null
+ }
+} \ No newline at end of file