mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-30 02:44:56 +01:00
Check if location tracking is started before starting it
This commit is contained in:
parent
25ca598414
commit
df2c3e7c07
@ -66,6 +66,8 @@ class LocationTracker @Inject constructor(
|
||||
@VisibleForTesting
|
||||
var hasLocationFromGPSProvider = false
|
||||
|
||||
private var isStarted = false
|
||||
private var isStarting = false
|
||||
private var firstLocationHandled = false
|
||||
private val _locations = MutableSharedFlow<Location>(replay = 1)
|
||||
|
||||
@ -90,7 +92,8 @@ class LocationTracker @Inject constructor(
|
||||
|
||||
@RequiresPermission(anyOf = [Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION])
|
||||
fun start() {
|
||||
// TODO start only if not already started
|
||||
if(!isStarting && !isStarted) {
|
||||
isStarting = true
|
||||
Timber.d("start()")
|
||||
|
||||
if (locationManager == null) {
|
||||
@ -129,6 +132,9 @@ class LocationTracker @Inject constructor(
|
||||
notifyLocation(latestKnownLocation)
|
||||
}
|
||||
}
|
||||
isStarted = true
|
||||
isStarting = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,6 +155,8 @@ class LocationTracker @Inject constructor(
|
||||
callbacks.clear()
|
||||
hasLocationFromGPSProvider = false
|
||||
hasLocationFromFusedProvider = false
|
||||
isStarting = false
|
||||
isStarted = false
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user