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
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
package eu.ztsh.garmin.data
|
||||
|
||||
import com.mapbox.navigation.core.trip.session.LocationMatcherResult
|
||||
import com.mapbox.navigation.ui.maneuver.model.Maneuver
|
||||
|
||||
class ManeuverMapper {
|
||||
class MapboxMapper {
|
||||
|
||||
companion object {
|
||||
|
||||
|
@ -59,6 +60,12 @@ class ManeuverMapper {
|
|||
return state
|
||||
}
|
||||
|
||||
fun apply(locationMatcherResult: LocationMatcherResult): State {
|
||||
val state = State()
|
||||
// TODO: speed, limit, location?, bearing
|
||||
return state
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -106,6 +106,7 @@ class State {
|
|||
var distance: Distance? = null
|
||||
var speed: Speed? = null
|
||||
var arrival: Arrival? = null
|
||||
// TODO: Bearing
|
||||
// TODO: support
|
||||
var traffic: Boolean? = null
|
||||
var flag: Boolean? = null
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue