Remove unnecessary changes
This commit is contained in:
parent
294bfc47b0
commit
5ab760dcf1
2 changed files with 24 additions and 60 deletions
|
@ -41,8 +41,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
|
||||
public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider, MapTextLayer.MapTextProvider<AMapPoint> {
|
||||
|
||||
public static final float SELECTED_POINT_VERTICAL_OFFSET = 0.09f;
|
||||
|
||||
private static final float POINT_IMAGE_VERTICAL_OFFSET = 0.91f;
|
||||
private static final float POINT_SELECTED_IMAGE_VERTICAL_OFFSET = 0.99f;
|
||||
|
||||
|
@ -80,8 +78,6 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
private Set<String> imageRequests = new HashSet<>();
|
||||
private List<AMapPoint> displayedPoints = new ArrayList<>();
|
||||
|
||||
private AMapPoint selectedPoint;
|
||||
|
||||
public AidlMapLayer(MapActivity map, AMapLayer aidlLayer) {
|
||||
this.map = map;
|
||||
this.aidlLayer = aidlLayer;
|
||||
|
@ -128,18 +124,6 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||
AMapPoint aMapPoint = selectedPoint;
|
||||
if (aMapPoint != null && !contextMenuOpenForPoint(aMapPoint)) {
|
||||
ALatLon l = aMapPoint.getLocation();
|
||||
if (l != null) {
|
||||
int x = (int) tileBox.getPixXFromLatLon(l.getLatitude(), l.getLongitude());
|
||||
int y = (int) tileBox.getPixYFromLatLon(l.getLatitude(), l.getLongitude());
|
||||
if (tileBox.containsPoint(x, y, bigIconSize)) {
|
||||
Bitmap image = getPointImage(aMapPoint);
|
||||
drawPoint(canvas, x, y, tileBox, aMapPoint, image);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -160,20 +144,21 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
int x = (int) tileBox.getPixXFromLatLon(l.getLatitude(), l.getLongitude());
|
||||
int y = (int) tileBox.getPixYFromLatLon(l.getLatitude(), l.getLongitude());
|
||||
if (tileBox.containsPoint(x, y, bigIconSize)) {
|
||||
Bitmap image = getPointImage(point);
|
||||
Bitmap image = null;
|
||||
if (pointsType != PointsType.STANDARD) {
|
||||
String imageUri = point.getParams().get(AMapPoint.POINT_IMAGE_URI_PARAM);
|
||||
if (!TextUtils.isEmpty(imageUri)) {
|
||||
image = pointImages.get(imageUri);
|
||||
if (image == null) {
|
||||
imageRequests.add(imageUri);
|
||||
}
|
||||
}
|
||||
}
|
||||
displayedPoints.add(point);
|
||||
boolean contextMenuOpenForPoint = contextMenuOpenForPoint(point);
|
||||
if (contextMenuOpenForPoint) {
|
||||
selectedPoint = point;
|
||||
} else {
|
||||
if (selectedPoint != null && point.getId().equals(selectedPoint.getId())) {
|
||||
selectedPoint = null;
|
||||
}
|
||||
drawPoint(canvas, x, y, tileBox, point, image);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (imageRequests.size() > 0) {
|
||||
executeTaskInBackground(new PointImageReaderTask(this), imageRequests.toArray(new String[imageRequests.size()]));
|
||||
|
@ -189,25 +174,18 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
return aidlLayer.getId();
|
||||
}
|
||||
|
||||
private Bitmap getPointImage(AMapPoint point) {
|
||||
Bitmap image = null;
|
||||
if (pointsType != PointsType.STANDARD) {
|
||||
String imageUri = point.getParams().get(AMapPoint.POINT_IMAGE_URI_PARAM);
|
||||
if (!TextUtils.isEmpty(imageUri)) {
|
||||
image = pointImages.get(imageUri);
|
||||
if (image == null) {
|
||||
imageRequests.add(imageUri);
|
||||
}
|
||||
}
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
private void drawPoint(Canvas canvas, int x, int y, RotatedTileBox tb, AMapPoint point, Bitmap image) {
|
||||
if (image == null) {
|
||||
image = placeholder;
|
||||
}
|
||||
if (pointsType == PointsType.STANDARD) {
|
||||
boolean contextMenuOpenForPoint = contextMenuOpenForPoint(point);
|
||||
if (contextMenuOpenForPoint) {
|
||||
bitmapPaint.setColorFilter(null);
|
||||
float vOffset = bigIconBgSelected.getHeight() * POINT_IMAGE_VERTICAL_OFFSET;
|
||||
int imageCenterY = (int) (y - vOffset + bigIconBgSelected.getHeight() / 2);
|
||||
canvas.drawBitmap(bigIconBgSelected, x - bigIconBgSelected.getWidth() / 2, y - vOffset, bitmapPaint);
|
||||
canvas.drawBitmap(image, null, getDstRect(x, imageCenterY, bigIconSize / 2), bitmapPaint);
|
||||
} else if (pointsType == PointsType.STANDARD) {
|
||||
int radius = getRadiusPoi(tb);
|
||||
float density = tb.getDensity();
|
||||
pointInnerCircle.setColor(point.getColor());
|
||||
|
|
|
@ -8,8 +8,6 @@ import android.graphics.Canvas;
|
|||
import android.graphics.Paint;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Vibrator;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
@ -97,7 +95,6 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
private MapQuickActionLayer mapQuickActionLayer;
|
||||
|
||||
private ImageView contextMarker;
|
||||
private Drawable contextMenuPin;
|
||||
private Paint paint;
|
||||
private Paint outlinePaint;
|
||||
private Bitmap pressedBitmap;
|
||||
|
@ -142,11 +139,13 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
this.view = view;
|
||||
|
||||
Context context = view.getContext();
|
||||
contextMenuPin = ContextCompat.getDrawable(context, R.drawable.map_pin_context_menu);
|
||||
contextMarker = new ImageView(context);
|
||||
contextMarker.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
|
||||
contextMarker.setClickable(true);
|
||||
updateContextMarkerIcon(contextMenuPin);
|
||||
contextMarker.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.map_pin_context_menu));
|
||||
int minw = contextMarker.getDrawable().getMinimumWidth();
|
||||
int minh = contextMarker.getDrawable().getMinimumHeight();
|
||||
contextMarker.layout(0, 0, minw, minh);
|
||||
|
||||
paint = new Paint();
|
||||
pressedBitmap = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_shield_tap);
|
||||
|
@ -198,7 +197,6 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings nightMode) {
|
||||
boolean markerCustomized = false;
|
||||
float vOffset = 0f;
|
||||
if (selectedObject != null) {
|
||||
TIntArrayList x = null;
|
||||
TIntArrayList y = null;
|
||||
|
@ -218,8 +216,6 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
if (aidlLayer != null) {
|
||||
Bitmap selectedImage = aidlLayer.getSelectedPointImage(imageUri);
|
||||
if (selectedImage != null) {
|
||||
vOffset = selectedImage.getHeight() * AidlMapLayer.SELECTED_POINT_VERTICAL_OFFSET;
|
||||
updateContextMarkerIcon(new BitmapDrawable(activity.getResources(), selectedImage));
|
||||
markerCustomized = true;
|
||||
}
|
||||
}
|
||||
|
@ -266,15 +262,12 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
canvas.translate(box.getPixWidth() / 2 - contextMarker.getWidth() / 2, box.getPixHeight() / 2 - contextMarker.getHeight());
|
||||
contextMarker.draw(canvas);
|
||||
mAddGpxPointBottomSheetHelper.onDraw(box);
|
||||
} else if (menu.isActive()) {
|
||||
} else if (menu.isActive() && !markerCustomized) {
|
||||
LatLon latLon = menu.getLatLon();
|
||||
int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||
int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
|
||||
canvas.translate(x - contextMarker.getWidth() / 2, y - contextMarker.getHeight() + vOffset);
|
||||
canvas.translate(x - contextMarker.getWidth() / 2, y - contextMarker.getHeight());
|
||||
contextMarker.draw(canvas);
|
||||
if (markerCustomized) {
|
||||
updateContextMarkerIcon(contextMenuPin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -530,13 +523,6 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
view.refreshMap();
|
||||
}
|
||||
|
||||
private void updateContextMarkerIcon(Drawable icon){
|
||||
contextMarker.setImageDrawable(icon);
|
||||
int minw = contextMarker.getDrawable().getMinimumWidth();
|
||||
int minh = contextMarker.getDrawable().getMinimumHeight();
|
||||
contextMarker.layout(0, 0, minw, minh);
|
||||
}
|
||||
|
||||
private void enterMovingMode(RotatedTileBox tileBox) {
|
||||
Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
if (vibrator != null) {
|
||||
|
|
Loading…
Reference in a new issue