mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-01 03:36:53 +01:00
Setting 5 seconds for min period of update for location tracking
This commit is contained in:
parent
1411fdd99f
commit
004f40bff5
@ -22,5 +22,5 @@ const val DEFAULT_PIN_ID = "DEFAULT_PIN_ID"
|
||||
|
||||
const val INITIAL_MAP_ZOOM_IN_PREVIEW = 15.0
|
||||
const val INITIAL_MAP_ZOOM_IN_TIMELINE = 17.0
|
||||
const val MIN_TIME_TO_UPDATE_LOCATION_MILLIS = 2 * 1_000L // every 2 seconds
|
||||
const val MIN_TIME_TO_UPDATE_LOCATION_MILLIS = 5 * 1_000L // every 5 seconds
|
||||
const val MIN_DISTANCE_TO_UPDATE_LOCATION_METERS = 10f
|
||||
|
@ -61,6 +61,7 @@ class LocationTracker @Inject constructor(
|
||||
@VisibleForTesting
|
||||
var hasLocationFromGPSProvider = false
|
||||
|
||||
private var firstLocationHandled = false
|
||||
private val _locations = MutableSharedFlow<Location>(replay = 1)
|
||||
|
||||
/**
|
||||
@ -68,7 +69,14 @@ class LocationTracker @Inject constructor(
|
||||
*/
|
||||
val locations = _locations.asSharedFlow()
|
||||
.onEach { Timber.d("new location emitted") }
|
||||
.debounce(MIN_TIME_TO_UPDATE_LOCATION_MILLIS)
|
||||
.debounce {
|
||||
if (firstLocationHandled) {
|
||||
MIN_TIME_TO_UPDATE_LOCATION_MILLIS
|
||||
} else {
|
||||
firstLocationHandled = true
|
||||
0
|
||||
}
|
||||
}
|
||||
.onEach { Timber.d("new location emitted after debounce") }
|
||||
.map { it.toLocationData() }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user