From 3b09323ee4a2c704515d9f34f8fb0229e2c67fe4 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 27 Jun 2022 15:10:54 +0200 Subject: [PATCH] Avoid stopping location service twice --- .../app/features/location/LocationSharingService.kt | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingService.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingService.kt index 9b3a1432de..0515947474 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationSharingService.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingService.kt @@ -169,21 +169,16 @@ class LocationSharingService : VectorService(), LocationTracker.Callback { private fun tryToDestroyMe() { if (roomArgsMap.isEmpty()) { Timber.i("### LocationSharingService. Destroying self, time is up for all rooms") - destroyMe() + stopSelf() } } - private fun destroyMe() { - jobs.forEach { it.cancel() } - jobs.clear() - locationTracker.removeCallback(this) - stopSelf() - } - override fun onDestroy() { super.onDestroy() Timber.i("### LocationSharingService.onDestroy") - destroyMe() + jobs.forEach { it.cancel() } + jobs.clear() + locationTracker.removeCallback(this) } private fun addRoomArgs(beaconEventId: String, roomArgs: RoomArgs) {