code cleaning

This commit is contained in:
Chumva 2019-05-29 19:04:08 +03:00
parent f8d3c377f4
commit ddafc9b329
2 changed files with 13 additions and 15 deletions

View file

@ -136,6 +136,7 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
String selectedPointId = getSelectedContextMenuPointId();
for (AMapPoint point : aidlLayer.getPoints()) {
ALatLon l = point.getLocation();
if (l != null) {
@ -153,7 +154,8 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
}
}
displayedPoints.add(point);
drawPoint(canvas, x, y, tileBox, point, image);
boolean selected = selectedPointId != null && selectedPointId.equals(point.getId());
drawPoint(canvas, x, y, tileBox, point, image, selected);
}
}
}
@ -168,12 +170,11 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
return aidlLayer.getId();
}
private void drawPoint(Canvas canvas, int x, int y, RotatedTileBox tb, AMapPoint point, Bitmap image) {
private void drawPoint(Canvas canvas, int x, int y, RotatedTileBox tb, AMapPoint point, Bitmap image, boolean selected) {
if (image == null) {
image = placeholder;
}
boolean contextMenuOpenForPoint = contextMenuOpenForPoint(point);
if (contextMenuOpenForPoint) {
if (selected) {
drawBigIcon(canvas, x, y, image, bigIconBgSelected);
} else if (pointsType == PointsType.STANDARD) {
int radius = getRadiusPoi(tb);
@ -201,14 +202,14 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
canvas.drawBitmap(image, null, getDstRect(x, imageCenterY, bigIconSize / 2), bitmapPaint);
}
private boolean contextMenuOpenForPoint(AMapPoint point) {
private String getSelectedContextMenuPointId() {
MapContextMenu mapContextMenu = map.getContextMenu();
Object object = mapContextMenu.getObject();
if (!mapContextMenu.isVisible() || !(object instanceof AMapPoint)) {
return false;
if (mapContextMenu.isVisible() && object instanceof AMapPoint) {
AMapPoint aMapPoint = (AMapPoint) object;
return aMapPoint.getId();
}
AMapPoint oldPoint = (AMapPoint) object;
return oldPoint.getLayerId().equals(getLayerId()) && oldPoint.getId().equals(point.getId());
return null;
}
private void drawColoredBitmap(Canvas canvas, int x, int y, Bitmap bitmap, int color) {

View file

@ -210,12 +210,9 @@ public class ContextMenuLayer extends OsmandMapLayer {
y = r.getY();
} else if (selectedObject instanceof AMapPoint) {
AMapPoint mapPoint = (AMapPoint) selectedObject;
String imageUri = mapPoint.getParams().get(AMapPoint.POINT_IMAGE_URI_PARAM);
if (!TextUtils.isEmpty(imageUri)) {
AidlMapLayer aidlLayer = view.getAidlMapLayer(mapPoint.getLayerId());
if (aidlLayer != null) {
markerCustomized = true;
}
AidlMapLayer aidlLayer = view.getAidlMapLayer(mapPoint.getLayerId());
if (aidlLayer != null) {
markerCustomized = true;
}
}
if (x != null && y != null && x.size() > 2) {