Fix ui search route

This commit is contained in:
Victor Shcherb 2016-07-30 01:12:42 +02:00
parent a4d3ca4576
commit 655ab8c467
4 changed files with 42 additions and 24 deletions

View file

@ -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);
}

View file

@ -352,6 +352,11 @@ public abstract class MenuController extends BaseMenuController {
}
public void onHide() {
}
public void onClose() {
}
public void onAcquireNewController(PointDescription pointDescription2, Object object) {
}
}

View file

@ -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() {

View file

@ -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<QuadRect> boundIntersections = initBoundIntersections(tb);
List<TransportStop> 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<QuadRect> boundIntersections = initBoundIntersections(tb);
List<TransportStop> 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);
}
}
}