diff options
author | Allan Wang <me@allanwang.ca> | 2018-12-24 17:41:08 -0500 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2018-12-24 17:41:08 -0500 |
commit | 25760fa2d066a23e7fc72747f59c964e76ed0889 (patch) | |
tree | 52841d13e5d420029c8ea7849cdf4303a9fc8d8d | |
parent | 9e1fe4bb7c692626c9aa336bebcb6c26ca49ea48 (diff) | |
download | frost-25760fa2d066a23e7fc72747f59c964e76ed0889.tar.gz frost-25760fa2d066a23e7fc72747f59c964e76ed0889.tar.bz2 frost-25760fa2d066a23e7fc72747f59c964e76ed0889.zip |
Avoid events for duplicate cancellations
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt index ea215b5c..40a78b04 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt @@ -57,6 +57,8 @@ class NotificationService : JobService(), CoroutineScope { } private fun prepareFinish(abrupt: Boolean) { + if (job.isCancelled) + return val time = System.currentTimeMillis() - startTime L.i { "Notification service has ${if (abrupt) "finished abruptly" else "finished"} in $time ms" } frostEvent( @@ -75,7 +77,8 @@ class NotificationService : JobService(), CoroutineScope { try { async { sendNotifications(params) }.await() } finally { - prepareFinish(false) + if (!job.isCancelled) + prepareFinish(false) jobFinished(params, false) } } |