From 97442bc292cf29d9d906a353675cc2a9ff908912 Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Sat, 5 Nov 2022 17:22:51 +1300 Subject: [PATCH] Fix adding one minute to a complete alarm --- .../app/src/main/java/com/massive/AlarmModule.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/java/com/massive/AlarmModule.kt b/android/app/src/main/java/com/massive/AlarmModule.kt index 2de0bdf..ae88556 100644 --- a/android/app/src/main/java/com/massive/AlarmModule.kt +++ b/android/app/src/main/java/com/massive/AlarmModule.kt @@ -72,6 +72,14 @@ class AlarmModule constructor(context: ReactApplicationContext?) : countdownTimer = getTimer(newMs, vibrate, sound, noSound) countdownTimer?.start() running = true + val manager = getManager() + manager.cancel(NOTIFICATION_ID_DONE) + reactApplicationContext.stopService( + Intent( + reactApplicationContext, + AlarmService::class.java + ) + ) } @RequiresApi(api = Build.VERSION_CODES.O) @@ -146,7 +154,12 @@ class AlarmModule constructor(context: ReactApplicationContext?) : } @RequiresApi(Build.VERSION_CODES.M) - private fun getTimer(endMs: Int, vibrate: Boolean, sound: String?, noSound: Boolean): CountDownTimer { + private fun getTimer( + endMs: Int, + vibrate: Boolean, + sound: String?, + noSound: Boolean + ): CountDownTimer { val builder = getBuilder() return object : CountDownTimer(endMs.toLong(), 1000) { @RequiresApi(Build.VERSION_CODES.O)