Compare commits
2 Commits
7c35da3f5b
...
745f9fb046
Author | SHA1 | Date |
---|---|---|
brandon.presley | 745f9fb046 | |
Joseph | b979d0943f |
|
@ -77,6 +77,7 @@ class TimerService : Service() {
|
||||||
secondsLeft = (intent?.getIntExtra("milliseconds", 0) ?: 0) / 1000
|
secondsLeft = (intent?.getIntExtra("milliseconds", 0) ?: 0) / 1000
|
||||||
currentDescription = intent?.getStringExtra("description").toString()
|
currentDescription = intent?.getStringExtra("description").toString()
|
||||||
secondsTotal = secondsLeft
|
secondsTotal = secondsLeft
|
||||||
|
val startTime = System.currentTimeMillis()
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||||
startForeground(ONGOING_ID, getProgress(secondsLeft).build(), FOREGROUND_SERVICE_TYPE_SPECIAL_USE)
|
startForeground(ONGOING_ID, getProgress(secondsLeft).build(), FOREGROUND_SERVICE_TYPE_SPECIAL_USE)
|
||||||
|
@ -86,14 +87,16 @@ class TimerService : Service() {
|
||||||
}
|
}
|
||||||
|
|
||||||
battery()
|
battery()
|
||||||
Log.d("TimerService", "onStartCommand seconds=$secondsLeft")
|
Log.d("TimerService", "onStartCommand seconds=$secondsTotal")
|
||||||
|
|
||||||
timerRunnable = object : Runnable {
|
timerRunnable = object : Runnable {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (secondsLeft > 0) {
|
val millisElapsed = System.currentTimeMillis() - startTime
|
||||||
secondsLeft--
|
val secondsElapsed = (millisElapsed / 1000).toInt()
|
||||||
|
if (secondsElapsed < secondsTotal) {
|
||||||
|
secondsLeft = secondsTotal - secondsElapsed
|
||||||
updateNotification(secondsLeft)
|
updateNotification(secondsLeft)
|
||||||
timerHandler.postDelayed(this, 1000)
|
timerHandler.postDelayed(this, 1000 - millisElapsed % 1000)
|
||||||
} else {
|
} else {
|
||||||
val settings = getSettings()
|
val settings = getSettings()
|
||||||
vibrate(settings)
|
vibrate(settings)
|
||||||
|
|
Loading…
Reference in New Issue