This commit is contained in:
Nazar 2019-10-30 12:34:26 +02:00
parent b6032abbc6
commit a2da336ff0
3 changed files with 22 additions and 5 deletions

View file

@ -107,6 +107,10 @@ public class WaypointHelper {
return route.getDistanceToPoint(point.routeIndex); return route.getDistanceToPoint(point.routeIndex);
} }
public boolean isPointPassed(LocationPointWrapper point) {
return route.isPointPassed(point.routeIndex);
}
public void removeVisibleLocationPoint(LocationPointWrapper lp) { public void removeVisibleLocationPoint(LocationPointWrapper lp) {
if (lp.type < locationPoints.size()) { if (lp.type < locationPoints.size()) {
locationPoints.get(lp.type).remove(lp); locationPoints.get(lp.type).remove(lp);

View file

@ -35,12 +35,13 @@ import net.osmand.plus.helpers.WaypointDialogHelper;
import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.routing.IRouteInformationListener; import net.osmand.plus.routing.IRouteInformationListener;
import net.osmand.plus.routing.IRoutingDataUpdateListener;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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"; public static final String TAG = "ShowAlongTheRouteBottomSheet";
@ -149,10 +150,11 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
if (tp != null && tp.size() > 0) { if (tp != null && tp.size() > 0) {
for (int j = 0; j < tp.size(); j++) { for (int j = 0; j < tp.size(); j++) {
WaypointHelper.LocationPointWrapper pointWrapper = tp.get(j); WaypointHelper.LocationPointWrapper pointWrapper = tp.get(j);
if (!waypointHelper.isPointPassed(pointWrapper)) {
PointItem subheaderItem = new PointItem(pointWrapper.type); PointItem subheaderItem = new PointItem(pointWrapper.type);
headerItem.subItems.add(subheaderItem);
subheaderItem.point = pointWrapper; subheaderItem.point = pointWrapper;
headerItem.subItems.add(subheaderItem);
}
} }
} }
} else { } else {
@ -182,12 +184,14 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
app.getRoutingHelper().removeListener(this); app.getRoutingHelper().removeListener(this);
app.getRoutingHelper().removeRouteDataListener(this);
} }
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
app.getRoutingHelper().addListener(this); app.getRoutingHelper().addListener(this);
app.getRoutingHelper().addRouteDataListener(this);
if (expandIndex != -1) { if (expandIndex != -1) {
expListView.expandGroup(expandIndex); expListView.expandGroup(expandIndex);
setupHeightAndBackground(getView()); setupHeightAndBackground(getView());
@ -203,6 +207,11 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
} }
} }
@Override
public void onRoutingDataUpdate() {
updateAdapter();
}
class ExpandableListAdapter extends OsmandBaseExpandableListAdapter { class ExpandableListAdapter extends OsmandBaseExpandableListAdapter {
private Context context; private Context context;

View file

@ -1021,6 +1021,10 @@ public class RouteCalculationResult {
return 0; return 0;
} }
public boolean isPointPassed(int locationIndex) {
return locationIndex <= currentRoute;
}
public int getDistanceToFinish(Location fromLoc) { public int getDistanceToFinish(Location fromLoc) {
if(listDistance != null && currentRoute < listDistance.length){ if(listDistance != null && currentRoute < listDistance.length){
int dist = listDistance[currentRoute]; int dist = listDistance[currentRoute];