Update AMapLayer in OsmAnd-Telegram

This commit is contained in:
Alex Sytnyk 2018-07-27 13:50:32 +03:00
parent 5a1cc4a3ff
commit 05503e1371
2 changed files with 80 additions and 0 deletions

View file

@ -16,6 +16,14 @@ public class AMapLayer implements Parcelable {
private float zOrder = 5.5f;
private Map<String, AMapPoint> points = new ConcurrentHashMap<>();
private boolean imagePoints = false;
private int circlePointMinZoom = 0;
private int circlePointMaxZoom = 6;
private int smallPointMinZoom = 7;
private int smallPointMaxZoom = 13;
private int bigPointMinZoom = 14;
private int bigPointMaxZoom = 22;
public AMapLayer(String id, String name, float zOrder, List<AMapPoint> pointList) {
this.id = id;
this.name = name;
@ -70,11 +78,74 @@ public class AMapLayer implements Parcelable {
points.remove(pointId);
}
public boolean isImagePoints() {
return imagePoints;
}
public void setImagePoints(boolean imagePoints) {
this.imagePoints = imagePoints;
}
public void copyZoomBounds(AMapLayer layer) {
circlePointMinZoom = layer.circlePointMinZoom;
circlePointMaxZoom = layer.circlePointMaxZoom;
smallPointMinZoom = layer.smallPointMinZoom;
smallPointMaxZoom = layer.smallPointMaxZoom;
bigPointMinZoom = layer.bigPointMinZoom;
bigPointMaxZoom = layer.bigPointMaxZoom;
}
public void setCirclePointZoomBounds(int min, int max) {
circlePointMinZoom = min;
circlePointMaxZoom = max;
}
public void setSmallPointZoomBounds(int min, int max) {
smallPointMinZoom = min;
smallPointMaxZoom = max;
}
public void setBigPointZoomBounds(int min, int max) {
bigPointMinZoom = min;
bigPointMaxZoom = max;
}
public int getCirclePointMinZoom() {
return circlePointMinZoom;
}
public int getCirclePointMaxZoom() {
return circlePointMaxZoom;
}
public int getSmallPointMinZoom() {
return smallPointMinZoom;
}
public int getSmallPointMaxZoom() {
return smallPointMaxZoom;
}
public int getBigPointMinZoom() {
return bigPointMinZoom;
}
public int getBigPointMaxZoom() {
return bigPointMaxZoom;
}
public void writeToParcel(Parcel out, int flags) {
out.writeString(id);
out.writeString(name);
out.writeFloat(zOrder);
out.writeTypedList(new ArrayList<>(points.values()));
out.writeByte((byte) (imagePoints ? 1 : 0));
out.writeInt(circlePointMinZoom);
out.writeInt(circlePointMaxZoom);
out.writeInt(smallPointMinZoom);
out.writeInt(smallPointMaxZoom);
out.writeInt(bigPointMinZoom);
out.writeInt(bigPointMaxZoom);
}
private void readFromParcel(Parcel in) {
@ -86,6 +157,13 @@ public class AMapLayer implements Parcelable {
for (AMapPoint p : pointList) {
this.points.put(p.getId(), p);
}
imagePoints = in.readByte() == 1;
circlePointMinZoom = in.readInt();
circlePointMaxZoom = in.readInt();
smallPointMinZoom = in.readInt();
smallPointMaxZoom = in.readInt();
bigPointMinZoom = in.readInt();
bigPointMaxZoom = in.readInt();
}
public int describeContents() {

View file

@ -474,6 +474,7 @@ class OsmandAidlHelper(private val app: Application) {
if (mIOsmAndAidlInterface != null) {
try {
val layer = AMapLayer(id, name, zOrder, points)
layer.isImagePoints = true
return mIOsmAndAidlInterface!!.addMapLayer(AddMapLayerParams(layer))
} catch (e: RemoteException) {
e.printStackTrace()
@ -495,6 +496,7 @@ class OsmandAidlHelper(private val app: Application) {
if (mIOsmAndAidlInterface != null) {
try {
val layer = AMapLayer(id, name, zOrder, points)
layer.isImagePoints = true
return mIOsmAndAidlInterface!!.updateMapLayer(UpdateMapLayerParams(layer))
} catch (e: RemoteException) {
e.printStackTrace()