Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanPyrohivskyi committed Nov 29, 2024
1 parent 50f50f5 commit 13d3d16
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions OsmAnd/src/net/osmand/plus/auto/TripUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.routing.CurrentStreetName;
import net.osmand.plus.routing.RoadShield;
import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper;
Expand Down Expand Up @@ -226,30 +227,6 @@ public static String defineStreetName(@NonNull OsmandApplication app, @Nullable

@NonNull
public static CurrentStreetName getStreetName(@NonNull OsmandApplication app, @NonNull NextDirectionInfo info, @NonNull RouteDirectionInfo routeInfo) {
CurrentStreetName streetName = new CurrentStreetName(info, true);
if (Algorithms.isEmpty(streetName.text)) {
streetName.text = getTurnDescription(app, info, routeInfo);
}
return streetName;
}

@Nullable
private static String getTurnDescription(@NonNull OsmandApplication app, @NonNull NextDirectionInfo info, @NonNull RouteDirectionInfo routeInfo) {
String description = routeInfo.getRef();
if (Algorithms.isEmpty(description)) {
TurnType turnType = routeInfo.getTurnType();
NextDirectionInfo nextInfo = getNextDirectionInfoAfter(app, info);
TurnType nextTurnType = nextInfo != null && nextInfo.directionInfo != null ? nextInfo.directionInfo.getTurnType() : null;

description = turnType != null ? nextTurnsToString(app, turnType, nextTurnType) : null;
}
return description;
}

@Nullable
private static NextDirectionInfo getNextDirectionInfoAfter(@NonNull OsmandApplication app, @NonNull NextDirectionInfo info) {
RoutingHelper helper = app.getRoutingHelper();
boolean onRoute = !helper.isDeviatedFromRoute();
return onRoute ? helper.getNextRouteDirectionInfoAfter(info, new NextDirectionInfo(), true) : null;
return new CurrentStreetName(info, true);
}
}

0 comments on commit 13d3d16

Please sign in to comment.