From 655ab8c46751690400059e6be91cbc1156226ea4 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 30 Jul 2016 01:12:42 +0200 Subject: [PATCH] Fix ui search route --- .../plus/mapcontextmenu/MapContextMenu.java | 3 ++ .../plus/mapcontextmenu/MenuController.java | 7 +++- .../controllers/TransportRouteController.java | 14 +++++-- .../plus/views/TransportStopsLayer.java | 42 ++++++++++--------- 4 files changed, 42 insertions(+), 24 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java index d2e405892f..3bbd59b0a5 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java @@ -450,6 +450,9 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL } private void acquireMenuController() { + if(menuController != null) { + menuController.onAcquireNewController(pointDescription, object); + } menuController = MenuController.getMenuController(mapActivity, pointDescription, object, MenuType.STANDARD); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java index c958c6fb1d..4d24a71ca5 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MenuController.java @@ -352,6 +352,11 @@ public abstract class MenuController extends BaseMenuController { } public void onHide() { - + } + + public void onClose() { + } + + public void onAcquireNewController(PointDescription pointDescription2, Object object) { } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java index fc787b7f93..a69b674931 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportRouteController.java @@ -4,6 +4,7 @@ import java.util.List; import android.view.View; import android.view.View.OnClickListener; +import net.osmand.binary.OsmandOdb.TransportRouteStop; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.TransportStop; @@ -76,11 +77,18 @@ public class TransportRouteController extends MenuController { } @Override - public void onHide() { + public void onClose() { super.onHide(); TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer(); stopsLayer.setRoute(null); } + + public void onAcquireNewController(PointDescription pointDescription, Object object) { + if(object instanceof TransportRouteStop) { + TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer(); + stopsLayer.setRoute(null); + } + }; @Override public void addPlainMenuItems(String typeStr, PointDescription pointDescription, final LatLon latLon) { @@ -89,8 +97,8 @@ public class TransportRouteController extends MenuController { boolean useEnglishNames = getMapActivity().getMyApplication().getSettings().usingEnglishNames(); for (final TransportStop stop : stops) { final String name = useEnglishNames ? stop.getEnName(true) : stop.getName(); - addPlainMenuItem( - stop == transportStop.stop ? R.drawable.ic_action_marker_dark : + boolean currentStop = stop.getName().equals(transportStop.stop.getName()); + addPlainMenuItem(currentStop? R.drawable.ic_action_marker_dark : (transportStop.type == null ? R.drawable.mx_route_bus_ref : transportStop.type.getResourceId()), name , false, false, new OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java index 57b24f2ad2..6b2abc2813 100644 --- a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java @@ -164,26 +164,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tb, DrawSettings settings) { if (tb.getZoom() >= startZoom) { - data.queryNewData(tb);; - float iconSize = stopBus.getWidth() * 3 / 2.5f; - QuadTree boundIntersections = initBoundIntersections(tb); - List fullObjects = new ArrayList<>(); - for (TransportStop o : data.getResults()) { - float x = tb.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude()); - float y = tb.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude()); - - if (intersects(boundIntersections, x, y, iconSize, iconSize)) { - canvas.drawBitmap(stopSmall, x - stopSmall.getWidth() / 2, y - stopSmall.getHeight() / 2, paintIcon); - } else { - fullObjects.add(o); - } - } - for (TransportStop o : fullObjects) { - float x = tb.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude()); - float y = tb.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude()); - Bitmap b = stopBus; - canvas.drawBitmap(b, x - b.getWidth() / 2, y - b.getHeight() / 2, paintIcon); - } + data.queryNewData(tb); if(route != null) { attrs.updatePaints(view, settings, tb); canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); @@ -208,6 +189,27 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa } } + + float iconSize = stopBus.getWidth() * 3 / 2.5f; + QuadTree boundIntersections = initBoundIntersections(tb); + List fullObjects = new ArrayList<>(); + for (TransportStop o : data.getResults()) { + float x = tb.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude()); + float y = tb.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude()); + + if (intersects(boundIntersections, x, y, iconSize, iconSize)) { + canvas.drawBitmap(stopSmall, x - stopSmall.getWidth() / 2, y - stopSmall.getHeight() / 2, paintIcon); + } else { + fullObjects.add(o); + } + } + for (TransportStop o : fullObjects) { + float x = tb.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude()); + float y = tb.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude()); + Bitmap b = stopBus; + canvas.drawBitmap(b, x - b.getWidth() / 2, y - b.getHeight() / 2, paintIcon); + } + } }