Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-07-30 01:13:12 +02:00
commit 38803616e0
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() { private void acquireMenuController() {
if(menuController != null) {
menuController.onAcquireNewController(pointDescription, object);
}
menuController = MenuController.getMenuController(mapActivity, pointDescription, object, MenuType.STANDARD); 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 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;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import net.osmand.binary.OsmandOdb.TransportRouteStop;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.data.TransportStop; import net.osmand.data.TransportStop;
@ -76,12 +77,19 @@ public class TransportRouteController extends MenuController {
} }
@Override @Override
public void onHide() { public void onClose() {
super.onHide(); super.onHide();
TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer(); TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
stopsLayer.setRoute(null); stopsLayer.setRoute(null);
} }
public void onAcquireNewController(PointDescription pointDescription, Object object) {
if(object instanceof TransportRouteStop) {
TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
stopsLayer.setRoute(null);
}
};
@Override @Override
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, final LatLon latLon) { public void addPlainMenuItems(String typeStr, PointDescription pointDescription, final LatLon latLon) {
super.addPlainMenuItems(typeStr, pointDescription, latLon); super.addPlainMenuItems(typeStr, pointDescription, latLon);
@ -89,8 +97,8 @@ public class TransportRouteController extends MenuController {
boolean useEnglishNames = getMapActivity().getMyApplication().getSettings().usingEnglishNames(); boolean useEnglishNames = getMapActivity().getMyApplication().getSettings().usingEnglishNames();
for (final TransportStop stop : stops) { for (final TransportStop stop : stops) {
final String name = useEnglishNames ? stop.getEnName(true) : stop.getName(); final String name = useEnglishNames ? stop.getEnName(true) : stop.getName();
addPlainMenuItem( boolean currentStop = stop.getName().equals(transportStop.stop.getName());
stop == transportStop.stop ? R.drawable.ic_action_marker_dark : addPlainMenuItem(currentStop? R.drawable.ic_action_marker_dark :
(transportStop.type == null ? R.drawable.mx_route_bus_ref : transportStop.type.getResourceId()), (transportStop.type == null ? R.drawable.mx_route_bus_ref : transportStop.type.getResourceId()),
name , false, false, new OnClickListener() { 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, public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tb,
DrawSettings settings) { DrawSettings settings) {
if (tb.getZoom() >= startZoom) { if (tb.getZoom() >= startZoom) {
data.queryNewData(tb);; 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);
}
if(route != null) { if(route != null) {
attrs.updatePaints(view, settings, tb); attrs.updatePaints(view, settings, tb);
canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); 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);
}
} }
} }