Fix sending location right after checkbox switched

This commit is contained in:
crimean 2018-06-19 16:33:15 +03:00
parent fa3917510c
commit 3f52aebedd
3 changed files with 11 additions and 0 deletions

View file

@ -127,6 +127,10 @@ class TelegramApplication : Application(), OsmandHelperListener {
telegramService?.stopIfNeeded(this, TelegramService.USED_BY_MY_LOCATION)
}
fun forceUpdateMyLocation() {
telegramService?.forceLocationUpdate()
}
fun startUserLocationService() {
startTelegramService(TelegramService.USED_BY_USERS_LOCATIONS)
}

View file

@ -130,6 +130,11 @@ class TelegramService : Service(), LocationListener, TelegramIncomingMessagesLis
stopForeground(java.lang.Boolean.TRUE)
}
fun forceLocationUpdate() {
val location = getFirstTimeRunDefaultLocation()
app().shareLocationHelper.updateLocation(location)
}
private fun initLocationUpdates() {
val firstLocation = getFirstTimeRunDefaultLocation()
app().shareLocationHelper.updateLocation(firstLocation)

View file

@ -58,6 +58,8 @@ class ShareLocationHelper(private val app: TelegramApplication) {
app.startMyLocationService()
refreshNotification()
} else {
app.forceUpdateMyLocation()
}
}