diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java index 2b806e2d6f..4c7f980e07 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java @@ -106,6 +106,10 @@ public class WaypointHelper { public int getRouteDistance(LocationPointWrapper point) { return route.getDistanceToPoint(point.routeIndex); } + + public boolean isPointPassed(LocationPointWrapper point) { + return route.isPointPassed(point.routeIndex); + } public void removeVisibleLocationPoint(LocationPointWrapper lp) { if (lp.type < locationPoints.size()) { diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowAlongTheRouteBottomSheet.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowAlongTheRouteBottomSheet.java index bd0aad8aec..575c45d465 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowAlongTheRouteBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ShowAlongTheRouteBottomSheet.java @@ -35,12 +35,13 @@ import net.osmand.plus.helpers.WaypointDialogHelper; import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.routing.IRouteInformationListener; +import net.osmand.plus.routing.IRoutingDataUpdateListener; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; -public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment implements IRouteInformationListener { +public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment implements IRouteInformationListener, IRoutingDataUpdateListener { public static final String TAG = "ShowAlongTheRouteBottomSheet"; @@ -149,10 +150,11 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment if (tp != null && tp.size() > 0) { for (int j = 0; j < tp.size(); j++) { WaypointHelper.LocationPointWrapper pointWrapper = tp.get(j); - PointItem subheaderItem = new PointItem(pointWrapper.type); - - headerItem.subItems.add(subheaderItem); - subheaderItem.point = pointWrapper; + if (!waypointHelper.isPointPassed(pointWrapper)) { + PointItem subheaderItem = new PointItem(pointWrapper.type); + subheaderItem.point = pointWrapper; + headerItem.subItems.add(subheaderItem); + } } } } else { @@ -182,12 +184,14 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment public void onPause() { super.onPause(); app.getRoutingHelper().removeListener(this); + app.getRoutingHelper().removeRouteDataListener(this); } @Override public void onResume() { super.onResume(); app.getRoutingHelper().addListener(this); + app.getRoutingHelper().addRouteDataListener(this); if (expandIndex != -1) { expListView.expandGroup(expandIndex); setupHeightAndBackground(getView()); @@ -203,6 +207,11 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment } } + @Override + public void onRoutingDataUpdate() { + updateAdapter(); + } + class ExpandableListAdapter extends OsmandBaseExpandableListAdapter { private Context context; diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java index 7cf1a08cb5..198b3c8cff 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java @@ -1021,6 +1021,10 @@ public class RouteCalculationResult { return 0; } + public boolean isPointPassed(int locationIndex) { + return locationIndex <= currentRoute; + } + public int getDistanceToFinish(Location fromLoc) { if(listDistance != null && currentRoute < listDistance.length){ int dist = listDistance[currentRoute];