Skip to content

Commit

Permalink
Merge pull request #21851 from osmandapp/update-route-info-widget-if-…
Browse files Browse the repository at this point in the history
…display-mode-changed

Update Route Details widget if display mode changed
  • Loading branch information
Chumva authored Feb 4, 2025
2 parents cd49f24 + e31149d commit 7404c55
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class RouteInfoWidget extends MapWidget implements ISupportVerticalPanel,
private TextState textState;
private final RouteInfoCalculator calculator;
private List<DestinationInfo> cachedRouteInfo;
private RouteInfoDisplayMode cachedDisplayMode;
private int cachedContentLayoutId;
private Integer cachedMetricSystem;
private boolean forceUpdate = false;
Expand Down Expand Up @@ -252,6 +253,11 @@ private boolean isUpdateNeeded(@NonNull List<DestinationInfo> routeInfo) {
if (metricSystemChanged) {
return true;
}
RouteInfoDisplayMode displayMode = widgetState.getDisplayMode();
if (cachedDisplayMode != displayMode) {
cachedDisplayMode = displayMode;
return true;
}
if (Algorithms.isEmpty(cachedRouteInfo) || isDataChanged(cachedRouteInfo.get(0), routeInfo.get(0))) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public RouteInfoWidgetState(@NonNull OsmandApplication app, @Nullable String cus
displayModePref = registerDisplayModePreference(customId);
}

@NonNull
public RouteInfoDisplayMode getDisplayMode() {
return getDisplayMode(settings.getApplicationMode());
}

@NonNull
public RouteInfoDisplayMode getDisplayMode(@NonNull ApplicationMode appMode) {
return displayModePref.getModeValue(appMode);
Expand Down

0 comments on commit 7404c55

Please sign in to comment.