fix: Model rebuilt
This commit is contained in:
parent
75e10c1579
commit
785a35473e
6 changed files with 136 additions and 137 deletions
|
@ -6,39 +6,38 @@ import com.mapbox.navigation.tripdata.maneuver.model.Maneuver
|
|||
|
||||
class DataCache {
|
||||
|
||||
private val stateCache: State = State()
|
||||
private val garminManeuver: GarminManeuver = GarminManeuver.empty()
|
||||
private var maneuverCache: Maneuver? = null
|
||||
private var locationCache: LocationMatcherResult? = null
|
||||
private var session: NavigationSessionState? = null
|
||||
|
||||
// state
|
||||
fun hasChanged(lanes: Lanes?): Boolean {
|
||||
return stateCache.lineArrows == null || stateCache.lineArrows != lanes
|
||||
fun hasChanged(lanes: Lanes): Boolean {
|
||||
return garminManeuver.lanes != lanes
|
||||
}
|
||||
|
||||
fun hasChanged(outlines: Outlines?): Boolean {
|
||||
return stateCache.lineOutlines == null || stateCache.lineOutlines != outlines
|
||||
fun hasChanged(distance: Distance): Boolean {
|
||||
return garminManeuver.distance != distance
|
||||
}
|
||||
|
||||
fun hasChanged(distance: Distance?): Boolean {
|
||||
return stateCache.distance == null || stateCache.distance != distance
|
||||
}
|
||||
|
||||
fun hasChanged(direction: Direction?): Boolean {
|
||||
return stateCache.direction == null || stateCache.direction != direction
|
||||
}
|
||||
|
||||
fun hasChanged(speed: Speed?): Boolean {
|
||||
return stateCache.speed == null || stateCache.speed != speed
|
||||
}
|
||||
|
||||
fun hasChanged(arrival: Arrival?): Boolean {
|
||||
return stateCache.arrival == null || stateCache.arrival != arrival
|
||||
fun hasChanged(direction: Direction): Boolean {
|
||||
return garminManeuver.direction != direction
|
||||
}
|
||||
//
|
||||
// fun hasChanged(speed: Speed?): Boolean {
|
||||
// return stateCache.speed == null || stateCache.speed != speed
|
||||
// }
|
||||
//
|
||||
// fun hasChanged(arrival: Arrival?): Boolean {
|
||||
// return stateCache.arrival == null || stateCache.arrival != arrival
|
||||
// }
|
||||
|
||||
// Merge states
|
||||
fun update(state: State) {
|
||||
stateCache.merge(state)
|
||||
fun update(item: GarminModelItem) {
|
||||
when(item) {
|
||||
is GarminManeuver -> garminManeuver.merge(item)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// maneuver
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue