Navigation state & location observer
This commit is contained in:
parent
b5cc580cf8
commit
9a553cf563
5 changed files with 70 additions and 21 deletions
|
@ -1,11 +1,15 @@
|
|||
package eu.ztsh.garmin.data
|
||||
|
||||
import com.mapbox.navigation.core.trip.session.LocationMatcherResult
|
||||
import com.mapbox.navigation.core.trip.session.NavigationSessionState
|
||||
import com.mapbox.navigation.ui.maneuver.model.Maneuver
|
||||
|
||||
class DataCache {
|
||||
|
||||
private val stateCache: State = State()
|
||||
private var maneuverCache: Maneuver? = null
|
||||
private var locationCache: LocationMatcherResult? = null
|
||||
private var session: NavigationSessionState? = null
|
||||
|
||||
// state
|
||||
fun hasChanged(lanes: Lanes?): Boolean {
|
||||
|
@ -63,4 +67,22 @@ class DataCache {
|
|||
maneuverCache = maneuver
|
||||
}
|
||||
|
||||
// location
|
||||
fun hasChanged(locationMatcherResult: LocationMatcherResult): Boolean {
|
||||
return locationCache == null || locationCache!! != locationMatcherResult
|
||||
}
|
||||
|
||||
fun update(locationMatcherResult: LocationMatcherResult) {
|
||||
locationCache = locationMatcherResult
|
||||
}
|
||||
|
||||
// session
|
||||
fun isActive(): Boolean {
|
||||
return session != null && session is NavigationSessionState.ActiveGuidance
|
||||
}
|
||||
|
||||
fun update(sessionState: NavigationSessionState) {
|
||||
session = sessionState
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue