Fix #5831
This commit is contained in:
parent
b4d79ee28c
commit
6c0895b6e9
5 changed files with 69 additions and 56 deletions
|
@ -40,6 +40,7 @@ import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.QuadPoint;
|
import net.osmand.data.QuadPoint;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
|
import net.osmand.data.TransportRoute;
|
||||||
import net.osmand.plus.LockableScrollView;
|
import net.osmand.plus.LockableScrollView;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
@ -62,6 +63,7 @@ import net.osmand.plus.views.controls.HorizontalSwipeConfirm;
|
||||||
import net.osmand.plus.views.controls.SingleTapConfirm;
|
import net.osmand.plus.views.controls.SingleTapConfirm;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
|
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
|
||||||
|
@ -645,7 +647,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
}
|
}
|
||||||
|
|
||||||
private TransportStopRouteAdapter createTransportStopRouteAdapter(List<TransportStopRoute> routes) {
|
private TransportStopRouteAdapter createTransportStopRouteAdapter(List<TransportStopRoute> routes) {
|
||||||
final TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getMyApplication(), routes, nightMode);
|
final TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getMyApplication(), filterTransportRoutes(routes), nightMode);
|
||||||
adapter.setListener(new TransportStopRouteAdapter.OnClickListener() {
|
adapter.setListener(new TransportStopRouteAdapter.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(int position) {
|
public void onClick(int position) {
|
||||||
|
@ -664,6 +666,25 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
||||||
return adapter;
|
return adapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<TransportStopRoute> filterTransportRoutes(List<TransportStopRoute> routes) {
|
||||||
|
List<TransportStopRoute> filteredRoutes = new ArrayList<>();
|
||||||
|
for (TransportStopRoute route : routes) {
|
||||||
|
if (!containsRef(filteredRoutes, route.route) && filteredRoutes.size() < 6) {
|
||||||
|
filteredRoutes.add(route);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filteredRoutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean containsRef(List<TransportStopRoute> routes, TransportRoute transportRoute) {
|
||||||
|
for (TransportStopRoute route : routes) {
|
||||||
|
if (route.route.getRef().equals(transportRoute.getRef())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private float getToolbarAlpha(int y) {
|
private float getToolbarAlpha(int y) {
|
||||||
float a = 0;
|
float a = 0;
|
||||||
if (menu != null && !menu.isLandscapeLayout()) {
|
if (menu != null && !menu.isLandscapeLayout()) {
|
||||||
|
|
|
@ -554,17 +554,6 @@ public abstract class MenuController extends BaseMenuController implements Colla
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
protected List<TransportStopRoute> getSubTransportStopRoutes(boolean nearby) {
|
protected List<TransportStopRoute> getSubTransportStopRoutes(boolean nearby) {
|
||||||
List<TransportStopRoute> allRoutes = getTransportStopRoutes();
|
|
||||||
if (allRoutes != null) {
|
|
||||||
List<TransportStopRoute> res = new ArrayList<>();
|
|
||||||
for (TransportStopRoute route : allRoutes) {
|
|
||||||
boolean isCurrentRouteNearby = route.refStop != null && !route.refStop.getName().equals(route.stop.getName());
|
|
||||||
if ((nearby && isCurrentRouteNearby) || (!nearby && !isCurrentRouteNearby)) {
|
|
||||||
res.add(route);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -311,32 +311,21 @@ public class AmenityMenuController extends MenuController {
|
||||||
Collection<TransportRoute> rts = t.getRouteForStop(s);
|
Collection<TransportRoute> rts = t.getRouteForStop(s);
|
||||||
if (rts != null) {
|
if (rts != null) {
|
||||||
for (TransportRoute rs : rts) {
|
for (TransportRoute rs : rts) {
|
||||||
if (!containsRef(rs)) {
|
TransportStopType type = TransportStopType.findType(rs.getType());
|
||||||
TransportStopType type = TransportStopType.findType(rs.getType());
|
if (isSubwayEntrance && type != TransportStopType.SUBWAY && dist > 150) {
|
||||||
if (isSubwayEntrance && type != TransportStopType.SUBWAY && dist > 150) {
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
TransportStopRoute r = new TransportStopRoute();
|
|
||||||
r.type = type;
|
|
||||||
r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName();
|
|
||||||
r.route = rs;
|
|
||||||
r.stop = s;
|
|
||||||
if (amenity.getLocation().equals(s.getLocation()) || (isSubwayEntrance && type == TransportStopType.SUBWAY)) {
|
|
||||||
r.refStop = s;
|
|
||||||
}
|
|
||||||
r.distance = dist;
|
|
||||||
this.routes.add(r);
|
|
||||||
}
|
}
|
||||||
|
TransportStopRoute r = new TransportStopRoute();
|
||||||
|
r.type = type;
|
||||||
|
r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName();
|
||||||
|
r.route = rs;
|
||||||
|
r.stop = s;
|
||||||
|
if (amenity.getLocation().equals(s.getLocation()) || (isSubwayEntrance && type == TransportStopType.SUBWAY)) {
|
||||||
|
r.refStop = s;
|
||||||
|
}
|
||||||
|
r.distance = dist;
|
||||||
|
this.routes.add(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean containsRef(TransportRoute transportRoute) {
|
|
||||||
for (TransportStopRoute route : routes) {
|
|
||||||
if (route.route.getRef().equals(transportRoute.getRef())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class FavouritePointMenuController extends MenuController {
|
||||||
private FavouritePoint fav;
|
private FavouritePoint fav;
|
||||||
private MapMarker mapMarker;
|
private MapMarker mapMarker;
|
||||||
private List<TransportStopRoute> routes = new ArrayList<>();
|
private List<TransportStopRoute> routes = new ArrayList<>();
|
||||||
|
private TransportStopController transportStopController;
|
||||||
|
|
||||||
public FavouritePointMenuController(@NonNull MapActivity mapActivity, @NonNull PointDescription pointDescription, final @NonNull FavouritePoint fav) {
|
public FavouritePointMenuController(@NonNull MapActivity mapActivity, @NonNull PointDescription pointDescription, final @NonNull FavouritePoint fav) {
|
||||||
super(new FavouritePointMenuBuilder(mapActivity, fav), pointDescription, mapActivity);
|
super(new FavouritePointMenuBuilder(mapActivity, fav), pointDescription, mapActivity);
|
||||||
|
@ -47,7 +48,7 @@ public class FavouritePointMenuController extends MenuController {
|
||||||
}
|
}
|
||||||
if (getObject() instanceof TransportStop) {
|
if (getObject() instanceof TransportStop) {
|
||||||
TransportStop stop = (TransportStop) getObject();
|
TransportStop stop = (TransportStop) getObject();
|
||||||
TransportStopController transportStopController = new TransportStopController(getMapActivity(), pointDescription, stop);
|
transportStopController = new TransportStopController(mapActivity, pointDescription, stop);
|
||||||
routes = transportStopController.processTransportStop();
|
routes = transportStopController.processTransportStop();
|
||||||
builder.setRoutes(routes);
|
builder.setRoutes(routes);
|
||||||
}
|
}
|
||||||
|
@ -75,6 +76,14 @@ public class FavouritePointMenuController extends MenuController {
|
||||||
return routes;
|
return routes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<TransportStopRoute> getSubTransportStopRoutes(boolean nearby) {
|
||||||
|
if (transportStopController != null) {
|
||||||
|
return transportStopController.getSubTransportStopRoutes(nearby);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleSingleTapOnMap() {
|
public boolean handleSingleTapOnMap() {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
|
|
@ -72,6 +72,22 @@ public class TransportStopController 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 isCurrentRouteNearby = route.stop != null && !route.stop.equals(transportStop);
|
||||||
|
if ((nearby && isCurrentRouteNearby) || (!nearby && !isCurrentRouteNearby)) {
|
||||||
|
res.add(route);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean needStreetName() {
|
public boolean needStreetName() {
|
||||||
return Algorithms.isEmpty(getNameStr());
|
return Algorithms.isEmpty(getNameStr());
|
||||||
|
@ -151,29 +167,18 @@ public class TransportStopController extends MenuController {
|
||||||
if (topType == null && type != null && type.isTopType()) {
|
if (topType == null && type != null && type.isTopType()) {
|
||||||
topType = type;
|
topType = type;
|
||||||
}
|
}
|
||||||
if (!containsRef(routes, rs)) {
|
TransportStopRoute r = new TransportStopRoute();
|
||||||
TransportStopRoute r = new TransportStopRoute();
|
r.type = type;
|
||||||
r.type = type;
|
r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName();
|
||||||
r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName();
|
r.route = rs;
|
||||||
r.route = rs;
|
r.refStop = refStop;
|
||||||
r.refStop = refStop;
|
r.stop = s;
|
||||||
r.stop = s;
|
r.distance = dist;
|
||||||
r.distance = dist;
|
routes.add(r);
|
||||||
routes.add(r);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean containsRef(List<TransportStopRoute> routes, TransportRoute transportRoute) {
|
|
||||||
for (TransportStopRoute route : routes) {
|
|
||||||
if (route.route.getRef().equals(transportRoute.getRef())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
|
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
|
||||||
Amenity amenity = transportStop.getAmenity();
|
Amenity amenity = transportStop.getAmenity();
|
||||||
|
|
Loading…
Reference in a new issue