Avoid stopping location service twice

This commit is contained in:
Maxime NATUREL 2022-06-27 15:10:54 +02:00
parent 353a8a70eb
commit 3b09323ee4

View file

@ -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()
}
}
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) {