commit
de6c9bb0f9
3 changed files with 53 additions and 12 deletions
|
@ -321,6 +321,16 @@ public class MenuBuilder {
|
||||||
return routes.size() > 0;
|
return routes.size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean showLocalTransportRoutes() {
|
||||||
|
List<TransportStopRoute> localTransportRoutes = mapContextMenu.getLocalTransportStopRoutes();
|
||||||
|
return localTransportRoutes != null && localTransportRoutes.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean showNearbyTransportRoutes() {
|
||||||
|
List<TransportStopRoute> nearbyTransportRoutes = mapContextMenu.getNearbyTransportStopRoutes();
|
||||||
|
return nearbyTransportRoutes != null && nearbyTransportRoutes.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
void onHide() {
|
void onHide() {
|
||||||
hidden = true;
|
hidden = true;
|
||||||
}
|
}
|
||||||
|
@ -440,11 +450,12 @@ public class MenuBuilder {
|
||||||
|
|
||||||
protected void buildTopInternal(View view) {
|
protected void buildTopInternal(View view) {
|
||||||
if (showTransportRoutes()) {
|
if (showTransportRoutes()) {
|
||||||
buildRow(view, 0, null, app.getString(R.string.transport_Routes), 0, true, getCollapsableTransportStopRoutesView(view.getContext(), false, false),
|
if (showLocalTransportRoutes()) {
|
||||||
false, 0, false, null, true);
|
buildRow(view, 0, null, app.getString(R.string.transport_Routes), 0, true, getCollapsableTransportStopRoutesView(view.getContext(), false, false),
|
||||||
|
false, 0, false, null, true);
|
||||||
CollapsableView collapsableView = getCollapsableTransportStopRoutesView(view.getContext(), false, true);
|
}
|
||||||
if (collapsableView != null) {
|
if (showNearbyTransportRoutes()) {
|
||||||
|
CollapsableView collapsableView = getCollapsableTransportStopRoutesView(view.getContext(), false, true);
|
||||||
String routesWithingDistance = app.getString(R.string.transport_nearby_routes_within) + " " + OsmAndFormatter.getFormattedDistance(TransportStopController.SHOW_STOPS_RADIUS_METERS, app);
|
String routesWithingDistance = app.getString(R.string.transport_nearby_routes_within) + " " + OsmAndFormatter.getFormattedDistance(TransportStopController.SHOW_STOPS_RADIUS_METERS, app);
|
||||||
buildRow(view, 0, null, routesWithingDistance, 0, true, collapsableView,
|
buildRow(view, 0, null, routesWithingDistance, 0, true, collapsableView,
|
||||||
false, 0, false, null, true);
|
false, 0, false, null, true);
|
||||||
|
@ -747,6 +758,19 @@ public class MenuBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String adjustRouteRef(String ref) {
|
||||||
|
if (ref != null) {
|
||||||
|
int charPos = ref.lastIndexOf(':');
|
||||||
|
if (charPos != -1) {
|
||||||
|
ref = ref.substring(0, charPos);
|
||||||
|
}
|
||||||
|
if (ref.length() > 4) {
|
||||||
|
ref = ref.substring(0, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ref;
|
||||||
|
}
|
||||||
|
|
||||||
public int dpToPx(float dp) {
|
public int dpToPx(float dp) {
|
||||||
Resources r = app.getResources();
|
Resources r = app.getResources();
|
||||||
return (int) TypedValue.applyDimension(
|
return (int) TypedValue.applyDimension(
|
||||||
|
@ -785,7 +809,7 @@ public class MenuBuilder {
|
||||||
shape.setColor(route.getColor(mapActivity.getMyApplication(), !light));
|
shape.setColor(route.getColor(mapActivity.getMyApplication(), !light));
|
||||||
|
|
||||||
transportRect.setBackgroundDrawable(shape);
|
transportRect.setBackgroundDrawable(shape);
|
||||||
transportRect.setText(route.route.getRef());
|
transportRect.setText(adjustRouteRef(route.route.getRef()));
|
||||||
baseView.addView(transportRect);
|
baseView.addView(transportRect);
|
||||||
|
|
||||||
LinearLayout infoView = new LinearLayout(view.getContext());
|
LinearLayout infoView = new LinearLayout(view.getContext());
|
||||||
|
@ -850,11 +874,7 @@ public class MenuBuilder {
|
||||||
} else {
|
} else {
|
||||||
buildTransportRouteRows(view, nearbyTransportStopRoutes);
|
buildTransportRouteRows(view, nearbyTransportStopRoutes);
|
||||||
}
|
}
|
||||||
if (isNearbyRoutes && nearbyTransportStopRoutes.isEmpty()) {
|
return new CollapsableView(view, this, collapsed);
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return new CollapsableView(view, this, collapsed);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildTransportRouteRows(LinearLayout view, List<TransportStopRoute> routes) {
|
private void buildTransportRouteRows(LinearLayout view, List<TransportStopRoute> routes) {
|
||||||
|
|
|
@ -521,7 +521,7 @@ public abstract class MenuController extends BaseMenuController implements Colla
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<TransportStopRoute> getSubTransportStopRoutes(boolean nearby) {
|
protected List<TransportStopRoute> getSubTransportStopRoutes(boolean nearby) {
|
||||||
List<TransportStopRoute> allRoutes = getTransportStopRoutes();
|
List<TransportStopRoute> allRoutes = getTransportStopRoutes();
|
||||||
if (allRoutes != null) {
|
if (allRoutes != null) {
|
||||||
List<TransportStopRoute> res = new ArrayList<>();
|
List<TransportStopRoute> res = new ArrayList<>();
|
||||||
|
|
|
@ -178,6 +178,24 @@ public class AmenityMenuController extends MenuController {
|
||||||
return routes;
|
return routes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<TransportStopRoute> getSubTransportStopRoutes(boolean nearby) {
|
||||||
|
List<TransportStopRoute> allRoutes = getTransportStopRoutes();
|
||||||
|
if (allRoutes != null) {
|
||||||
|
List<TransportStopRoute> res = new ArrayList<>();
|
||||||
|
for (TransportStopRoute route : allRoutes) {
|
||||||
|
boolean isCurrentRouteLocal = route.refStop != null && route.refStop.getName().equals(route.stop.getName());
|
||||||
|
if (!nearby && isCurrentRouteLocal) {
|
||||||
|
res.add(route);
|
||||||
|
} else if (nearby && route.refStop == null) {
|
||||||
|
res.add(route);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
|
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
|
||||||
}
|
}
|
||||||
|
@ -261,6 +279,9 @@ public class AmenityMenuController extends MenuController {
|
||||||
r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName();
|
r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName();
|
||||||
r.route = rs;
|
r.route = rs;
|
||||||
r.stop = s;
|
r.stop = s;
|
||||||
|
if (amenity.getLocation().equals(s.getLocation()) || (isSubwayEntrance && type == TransportStopType.SUBWAY)) {
|
||||||
|
r.refStop = s;
|
||||||
|
}
|
||||||
r.distance = dist;
|
r.distance = dist;
|
||||||
this.routes.add(r);
|
this.routes.add(r);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue