From 6c542058b160a478b87d3d41830d4f78aa59760d Mon Sep 17 00:00:00 2001 From: crimean Date: Fri, 15 Mar 2019 19:06:51 +0300 Subject: [PATCH] Fix PT details time --- .../osmand/router/TransportRoutePlanner.java | 6 +- .../src/net/osmand/plus/OsmAndFormatter.java | 6 + .../ShowRouteInfoDialogFragment.java | 166 ++++++++---------- .../cards/PublicTransportCard.java | 29 +-- .../plus/routing/TransportRoutingHelper.java | 44 +++++ 5 files changed, 147 insertions(+), 104 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/TransportRoutePlanner.java b/OsmAnd-java/src/main/java/net/osmand/router/TransportRoutePlanner.java index 7b05fb6865..6f9ee56dc2 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/TransportRoutePlanner.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/TransportRoutePlanner.java @@ -489,7 +489,11 @@ public class TransportRoutePlanner { public double getWalkTime() { return getWalkDist() / cfg.walkSpeed; } - + + public double getChangeTime() { + return cfg.getChangeTime(); + } + public int getChanges() { return segments.size() - 1; } diff --git a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java index cac73795f7..cd87a1e744 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndFormatter.java @@ -60,6 +60,12 @@ public class OsmAndFormatter { return hours + ":" + (minutes < 10 ? "0" + minutes : minutes) + ":" + (sec < 10 ? "0" + sec : sec); } + public static String getFormattedDurationShortMinutes(int seconds) { + int hours = seconds / (60 * 60); + int minutes = (seconds / 60) % 60; + return hours + ":" + (minutes < 10 ? "0" + minutes : minutes); + } + public static String getFormattedTime(long seconds, boolean useCurrentTime) { Calendar calendar = Calendar.getInstance(); if (useCurrentTime) { diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowRouteInfoDialogFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowRouteInfoDialogFragment.java index 718d74571a..e6f1e1ae33 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowRouteInfoDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowRouteInfoDialogFragment.java @@ -607,7 +607,8 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment implements P !nightMode ? R.color.ctx_menu_collapse_icon_color_light : R.color.ctx_menu_collapse_icon_color_dark); } - private void buildSegmentItem(View view, final TransportRouteResultSegment segment, long startTime) { + private void buildSegmentItem(View view, final TransportRouteResultSegment segment, + final TransportRouteResultSegment nextSegment, int[] startTime, double walkSpeed, double changeTime) { TransportRoute transportRoute = segment.route; List stops = segment.getTravelStops(); final TransportStop startStop = stops.get(0); @@ -632,7 +633,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment implements P Drawable icon = getContentIcon(drawableResId); Typeface typeface = FontCache.getRobotoMedium(app); - String timeText = OsmAndFormatter.getFormattedTime(startTime, false); + String timeText = OsmAndFormatter.getFormattedDurationShortMinutes(startTime[0]); SpannableString secondaryText = new SpannableString(getString(R.string.sit_on_the_stop)); secondaryText.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.primary_text_dark : R.color.primary_text_light)), 0, secondaryText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); @@ -695,11 +696,13 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment implements P buildCollapsableRow(stopsContainer, spannable, textType, true, collapsableView, null); final TransportStop endStop = stops.get(stops.size() - 1); - long depTime = segment.depTime + arrivalTime; + int depTime = segment.depTime + arrivalTime; if (depTime <= 0) { - depTime = startTime + arrivalTime; + depTime = startTime[0] + arrivalTime; } - String textTime = OsmAndFormatter.getFormattedTime(depTime, false); + // TODO: fix later for schedule + startTime[0] += (int) segment.travelTime + (nextSegment != null ? changeTime / 2 : 0); + String textTime = OsmAndFormatter.getFormattedDurationShortMinutes(startTime[0]); secondaryText = new SpannableString(getString(R.string.exit_at)); secondaryText.setSpan(new CustomTypefaceSpan(typeface), 0, secondaryText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); @@ -719,6 +722,33 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment implements P }); ((ViewGroup) view).addView(baseContainer); + + if (nextSegment != null) { + double walkDist = (long) getWalkDistance(segment, nextSegment, segment.walkDist); + if (walkDist > 0) { + int walkTime = (int) getWalkTime(segment, nextSegment, walkDist, walkSpeed); + if (walkTime < 60) { + walkTime = 60; + } + spannable = new SpannableStringBuilder("~"); + spannable.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light)), 0, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + startIndex = spannable.length(); + spannable.append(OsmAndFormatter.getFormattedDuration(walkTime, app)).append(" "); + spannable.setSpan(new CustomTypefaceSpan(typeface), startIndex, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + startIndex = spannable.length(); + spannable.append(getString(R.string.on_foot)).append(", ").append(OsmAndFormatter.getFormattedDistance((float) walkDist, app)); + spannable.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light)), startIndex, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + + buildRowDivider(view, true); + buildWalkRow(view, spannable, null, new OnClickListener() { + @Override + public void onClick(View v) { + showWalkingRouteOnMap(segment, nextSegment); + } + }); + startTime[0] += walkTime; + } + } } private View createImagesContainer() { @@ -739,93 +769,29 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment implements P } private void buildTransportRouteRow(ViewGroup parent, TransportRouteResult routeResult, boolean showDivider) { - Typeface typeface = FontCache.getRobotoMedium(app); TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper(); TargetPoint startPoint = targetPointsHelper.getPointToStart(); TargetPoint endPoint = targetPointsHelper.getPointToNavigate(); - long startTime = System.currentTimeMillis() / 1000; - + int[] startTime = { 0 }; List segments = routeResult.getSegments(); - boolean previousWalkItemUsed = false; - for (int i = 0; i < segments.size(); i++) { + boolean first = i == 0; + boolean last = i == segments.size() - 1; final TransportRouteResultSegment segment = segments.get(i); - final TransportRouteResultSegment nextSegment = segments.size() > i + 1 ? segments.get(i + 1) : null; - long walkTime = (long) getWalkTime(segment.walkDist, routeResult.getWalkSpeed()); - if (walkTime < 60) { - walkTime = 60; - } - if (i == 0) { + if (first) { buildStartItem(parent, startPoint, startTime, segment, routeResult.getWalkSpeed()); - startTime += walkTime; - } else if (segment.walkDist > 0 && !previousWalkItemUsed) { - SpannableStringBuilder spannable = new SpannableStringBuilder("~"); - int startIndex = spannable.length(); - spannable.append(OsmAndFormatter.getFormattedDuration((int) walkTime, app)).append(" "); - spannable.setSpan(new CustomTypefaceSpan(typeface), startIndex, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - spannable.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.primary_text_dark : R.color.primary_text_light)), startIndex, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - spannable.append(getString(R.string.on_foot)).append(" ").append(", ").append(OsmAndFormatter.getFormattedDistance((float) segment.walkDist, app)); - - buildWalkRow(parent, spannable, null, new OnClickListener() { - @Override - public void onClick(View v) { - showWalkingRouteOnMap(segment, nextSegment); - } - }); - buildRowDivider(parent, true); - startTime += walkTime; } - - buildSegmentItem(parent, segment, startTime); - - double finishWalkDist = routeResult.getFinishWalkDist(); - if (i == segments.size() - 1) { + buildSegmentItem(parent, segment, !last ? segments.get(i + 1) : null, startTime, routeResult.getWalkSpeed(), routeResult.getChangeTime()); + if (last) { buildDestinationItem(parent, endPoint, startTime, segment, routeResult.getWalkSpeed()); - } else if (finishWalkDist > 0) { - walkTime = (long) getWalkTime(finishWalkDist, routeResult.getWalkSpeed()); - startTime += walkTime; - if (nextSegment != null) { - if (nextSegment.walkDist > 0) { - finishWalkDist += nextSegment.walkDist; - walkTime += getWalkTime(nextSegment.walkDist, routeResult.getWalkSpeed()); - previousWalkItemUsed = true; - } else { - previousWalkItemUsed = false; - } - } - buildRowDivider(parent, true); - - Spannable title = getWalkTitle(finishWalkDist, walkTime); - buildWalkRow(parent, title, null, new OnClickListener() { - @Override - public void onClick(View v) { - showWalkingRouteOnMap(segment, nextSegment); - } - }); } - if (showDivider && i != segments.size() - 1) { + if (showDivider && !last) { buildRowDivider(parent, true); } } } - private Spannable getWalkTitle(double finishWalkDist, double walkTime) { - if (walkTime < 60) { - walkTime = 60; - } - Typeface typeface = FontCache.getRobotoMedium(app); - SpannableStringBuilder title = new SpannableStringBuilder("~"); - int startIndex = title.length(); - title.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light)), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - title.append(OsmAndFormatter.getFormattedDuration((int) walkTime, app)).append(" "); - title.setSpan(new CustomTypefaceSpan(typeface), startIndex, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - startIndex = title.length(); - title.append(getString(R.string.on_foot)).append(", ").append(OsmAndFormatter.getFormattedDistance((float) finishWalkDist, app)); - title.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light)), startIndex, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - return title; - } - - private void buildStartItem(View view, final TargetPoint start, long startTime, + private void buildStartItem(View view, final TargetPoint start, int[] startTime, final TransportRouteResultSegment segment, double walkSpeed) { FrameLayout baseItemView = new FrameLayout(view.getContext()); @@ -843,7 +809,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment implements P name = getString(R.string.shared_string_my_location); } Spannable startTitle = new SpannableString(name); - String text = OsmAndFormatter.getFormattedTime(startTime, false); + String text = OsmAndFormatter.getFormattedDurationShortMinutes(startTime[0]); int drawableId = start == null ? R.drawable.ic_action_location_color : R.drawable.list_startpoint; Drawable icon = app.getUIUtilities().getIcon(drawableId); @@ -857,17 +823,19 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment implements P addWalkRouteIcon(imagesContainer); buildRowDivider(infoContainer, true); - long walkTime = (long) getWalkTime(segment.walkDist, walkSpeed); + double walkDist = (long) getWalkDistance(null, segment, segment.walkDist); + int walkTime = (int) getWalkTime(null, segment, walkDist, walkSpeed); if (walkTime < 60) { walkTime = 60; } + startTime[0] += walkTime; SpannableStringBuilder title = new SpannableStringBuilder(Algorithms.capitalizeFirstLetter(getString(R.string.on_foot))); title.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light)), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); int startIndex = title.length(); - title.append(" ").append(OsmAndFormatter.getFormattedDuration((int) walkTime, app)); + title.append(" ").append(OsmAndFormatter.getFormattedDuration(walkTime, app)); title.setSpan(new CustomTypefaceSpan(FontCache.getRobotoMedium(app)), startIndex, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); startIndex = title.length(); - title.append(", ").append(OsmAndFormatter.getFormattedDistance((float) segment.walkDist, app)); + title.append(", ").append(OsmAndFormatter.getFormattedDistance((float) walkDist, app)); title.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light)), startIndex, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); buildWalkRow(infoContainer, title, imagesContainer, new OnClickListener() { @@ -882,9 +850,9 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment implements P } public void showLocationOnMap(LatLon latLon) { - OsmandSettings settings = app.getSettings(); - if (latLon == null) { - latLon = settings.isLastKnownMapLocation() ? settings.getLastKnownMapLocation() : null; + Location lastLocation = app.getLocationProvider().getLastKnownLocation(); + if (latLon == null && lastLocation != null) { + latLon = new LatLon(lastLocation.getLatitude(), lastLocation.getLongitude()); } if (latLon != null) { openMenuHeaderOnly(); @@ -934,7 +902,8 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment implements P container.addView(walkLineImage); } - private void buildDestinationItem(View view, final TargetPoint destination, long startTime, final TransportRouteResultSegment segment, double walkSpeed) { + private void buildDestinationItem(View view, final TargetPoint destination, int[] startTime, + final TransportRouteResultSegment segment, double walkSpeed) { Typeface typeface = FontCache.getRobotoMedium(app); FrameLayout baseItemView = new FrameLayout(view.getContext()); @@ -946,17 +915,18 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment implements P buildRowDivider(infoContainer, true); - long walkTime = (long) getWalkTime(segment.walkDist, walkSpeed); + double walkDist = (long) getWalkDistance(segment, null, segment.walkDist); + int walkTime = (int) getWalkTime(segment, null, walkDist, walkSpeed); if (walkTime < 60) { walkTime = 60; } SpannableStringBuilder spannable = new SpannableStringBuilder("~"); spannable.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light)), 0, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); int startIndex = spannable.length(); - spannable.append(OsmAndFormatter.getFormattedDuration((int) walkTime, app)).append(" "); + spannable.append(OsmAndFormatter.getFormattedDuration(walkTime, app)).append(" "); spannable.setSpan(new CustomTypefaceSpan(typeface), startIndex, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); startIndex = spannable.length(); - spannable.append(getString(R.string.on_foot)).append(", ").append(OsmAndFormatter.getFormattedDistance((float) segment.walkDist, app)); + spannable.append(getString(R.string.on_foot)).append(", ").append(OsmAndFormatter.getFormattedDistance((float) walkDist, app)); spannable.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light)), startIndex, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); buildWalkRow(infoContainer, spannable, imagesContainer, new OnClickListener() { @@ -968,7 +938,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment implements P buildRowDivider(infoContainer, true); addWalkRouteIcon(imagesContainer); - String timeStr = OsmAndFormatter.getFormattedTime(startTime + walkTime, false); + String timeStr = OsmAndFormatter.getFormattedDurationShortMinutes(startTime[0] + walkTime); String name = getRoutePointDescription(destination.point, destination.getOnlyName()); SpannableString title = new SpannableString(name); title.setSpan(new CustomTypefaceSpan(typeface), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); @@ -1650,8 +1620,22 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment implements P return ""; } - private double getWalkTime(double walkDist, double walkSpeed) { - return walkDist / walkSpeed; + private double getWalkTime(@Nullable TransportRouteResultSegment segment, + @Nullable TransportRouteResultSegment nextSegment, double walkDistPT, double walkSpeedPT) { + RouteCalculationResult walkingRouteSegment = app.getTransportRoutingHelper().getWalkingRouteSegment(segment, nextSegment); + if (walkingRouteSegment != null) { + return walkingRouteSegment.getRoutingTime(); + } + return walkDistPT / walkSpeedPT; + } + + private double getWalkDistance(@Nullable TransportRouteResultSegment segment, + @Nullable TransportRouteResultSegment nextSegment, double walkDistPT) { + RouteCalculationResult walkingRouteSegment = app.getTransportRoutingHelper().getWalkingRouteSegment(segment, nextSegment); + if (walkingRouteSegment != null) { + return walkingRouteSegment.getWholeDistance(); + } + return walkDistPT; } public void buildRowDivider(View view, boolean needMargin) { diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PublicTransportCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PublicTransportCard.java index f6b7c0d941..aa2efd1dc2 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PublicTransportCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/PublicTransportCard.java @@ -85,7 +85,7 @@ public class PublicTransportCard extends BaseCard { TextView wayLine = (TextView) view.findViewById(R.id.way_line); fromLine.setText(getFirstLineDescrSpan()); - wayLine.setText(getSecondLineDescrSpan()); + wayLine.setText(getSecondLineDescrSpan(segments)); FrameLayout detailsButton = (FrameLayout) view.findViewById(R.id.details_button); TextView detailsButtonDescr = (TextView) view.findViewById(R.id.details_button_descr); @@ -171,27 +171,32 @@ public class PublicTransportCard extends BaseCard { return firstLineDesc; } - private SpannableString getSecondLineDescrSpan() { + private SpannableString getSecondLineDescrSpan(List segments) { + TransportRoutingHelper transportRoutingHelper = app.getTransportRoutingHelper(); Typeface typeface = FontCache.getRobotoMedium(app); - String travelTime = OsmAndFormatter.getFormattedDuration((int) routeResult.getTravelTime(), app); - String walkTime = OsmAndFormatter.getFormattedDuration((int) routeResult.getWalkTime(), app); - String walkDistance = OsmAndFormatter.getFormattedDistance((int) routeResult.getWalkDist(), app); + String travelTimeStr = OsmAndFormatter.getFormattedDuration((int) routeResult.getTravelTime(), app); + int walkTimeReal = transportRoutingHelper.getWalkingTime(segments); + int walkTimePT = (int) routeResult.getWalkTime(); + String walkTimeStr = OsmAndFormatter.getFormattedDuration(walkTimeReal > 0 ? walkTimeReal : walkTimePT, app); + int walkDistanceReal = transportRoutingHelper.getWalkingDistance(segments); + int walkDistancePT = (int) routeResult.getWalkDist(); + String walkDistanceStr = OsmAndFormatter.getFormattedDistance(walkDistanceReal > 0 ? walkDistanceReal : walkDistancePT, app); - String secondLine = travelTime + " • " + app.getString(R.string.on_foot) + " " + walkTime + ", " + walkDistance; + String secondLine = travelTimeStr + " • " + app.getString(R.string.on_foot) + " " + walkTimeStr + ", " + walkDistanceStr; SpannableString secondLineDesc = new SpannableString(secondLine); - int startTravelTime = secondLine.indexOf(travelTime); + int startTravelTime = secondLine.indexOf(travelTimeStr); secondLineDesc.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.primary_text_dark : R.color.primary_text_light)), - startTravelTime, startTravelTime + travelTime.length(), 0); + startTravelTime, startTravelTime + travelTimeStr.length(), 0); secondLineDesc.setSpan(new CustomTypefaceSpan(typeface), - startTravelTime, startTravelTime + travelTime.length(), 0); + startTravelTime, startTravelTime + travelTimeStr.length(), 0); - int startWalkTime = secondLine.lastIndexOf(walkTime); + int startWalkTime = secondLine.lastIndexOf(walkTimeStr); secondLineDesc.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.primary_text_dark : R.color.primary_text_light)), - startWalkTime, startWalkTime + walkTime.length(), 0); + startWalkTime, startWalkTime + walkTimeStr.length(), 0); secondLineDesc.setSpan(new CustomTypefaceSpan(typeface), - startWalkTime, startWalkTime + walkTime.length(), 0); + startWalkTime, startWalkTime + walkTimeStr.length(), 0); return secondLineDesc; } diff --git a/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java index 2126cf960d..17c983418d 100644 --- a/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java @@ -111,6 +111,50 @@ public class TransportRoutingHelper { return null; } + public int getWalkingTime(@NonNull List segments) { + int res = 0; + Map, RouteCalculationResult> walkingRouteSegments = this.walkingRouteSegments; + if (walkingRouteSegments != null) { + TransportRouteResultSegment prevSegment = null; + for (TransportRouteResultSegment segment : segments) { + RouteCalculationResult walkingRouteSegment = getWalkingRouteSegment(prevSegment, segment); + if (walkingRouteSegment != null) { + res += walkingRouteSegment.getRoutingTime(); + } + prevSegment = segment; + } + if (segments.size() > 0) { + RouteCalculationResult walkingRouteSegment = getWalkingRouteSegment(segments.get(segments.size() - 1), null); + if (walkingRouteSegment != null) { + res += walkingRouteSegment.getRoutingTime(); + } + } + } + return res; + } + + public int getWalkingDistance(@NonNull List segments) { + int res = 0; + Map, RouteCalculationResult> walkingRouteSegments = this.walkingRouteSegments; + if (walkingRouteSegments != null) { + TransportRouteResultSegment prevSegment = null; + for (TransportRouteResultSegment segment : segments) { + RouteCalculationResult walkingRouteSegment = getWalkingRouteSegment(prevSegment, segment); + if (walkingRouteSegment != null) { + res += walkingRouteSegment.getWholeDistance(); + } + prevSegment = segment; + } + if (segments.size() > 0) { + RouteCalculationResult walkingRouteSegment = getWalkingRouteSegment(segments.get(segments.size() - 1), null); + if (walkingRouteSegment != null) { + res += walkingRouteSegment.getWholeDistance(); + } + } + } + return res; + } + public void setCurrentRoute(int currentRoute) { this.currentRoute = currentRoute; }