Skip to content

Commit

Permalink
Merge pull request #172 from stadiamaps/fix-android-default-recalcula…
Browse files Browse the repository at this point in the history
…tion

Fix broken recalculation logic on Android
  • Loading branch information
ianthetechie authored Aug 5, 2024
2 parents 712cbf3 + 70816c5 commit 1a2c668
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,14 +327,13 @@ class FerrostarCore(
val routes = getRoutes(location, action.waypoints)
val config = _config
val processor = alternativeRouteProcessor
val state = _state?.value
val state = _state.value
// Make sure we are still navigating and the new route is still relevant
if (state != null &&
state.tripState is TripState.Navigating &&
if (state.tripState is TripState.Navigating &&
state.tripState.deviation is RouteDeviation.OffRoute) {
if (processor != null) {
processor.loadedAlternativeRoutes(this@FerrostarCore, routes)
} else if (routes.count() > 1 && config != null) {
} else if (routes.isNotEmpty()) {
// Default behavior when there is no user-defined behavior:
// accept the first route, as this is what most users want when they go off
// route.
Expand Down Expand Up @@ -367,7 +366,7 @@ class FerrostarCore(
val controller = _navigationController

if (controller != null) {
_state?.update { currentValue ->
_state.update { currentValue ->
val newState =
controller.updateUserLocation(location = location, state = currentValue.tripState)

Expand Down

0 comments on commit 1a2c668

Please sign in to comment.