Replace AIDL-API#showLayerPointOnMap with AIDL-API#showMapPoint

This commit is contained in:
Alex Sytnyk 2018-07-11 12:49:46 +03:00
parent f00a89e0e8
commit 9e5e8bef1f
7 changed files with 84 additions and 74 deletions

View file

@ -51,7 +51,7 @@ import net.osmand.aidl.note.StopRecordingParams;
import net.osmand.aidl.gpx.RemoveGpxParams; import net.osmand.aidl.gpx.RemoveGpxParams;
import net.osmand.aidl.maplayer.ShowLayerPointOnMapParams; import net.osmand.aidl.maplayer.point.ShowMapPointParams;
// NOTE: Add new methods at the end of file!!! // NOTE: Add new methods at the end of file!!!
@ -104,5 +104,5 @@ interface IOsmAndAidlInterface {
boolean removeGpx(in RemoveGpxParams params); boolean removeGpx(in RemoveGpxParams params);
boolean showLayerPointOnMap(in ShowLayerPointOnMapParams params); boolean showMapPoint(in ShowMapPointParams params);
} }

View file

@ -833,23 +833,28 @@ public class OsmandAidlApi {
} }
} }
boolean showLayerPointOnMap(String layerId, String pointId) { boolean showMapPoint(String layerId, AMapPoint point) {
if (!TextUtils.isEmpty(layerId) && !TextUtils.isEmpty(pointId)) { if (point != null) {
AMapLayer layer = layers.get(layerId); if (!TextUtils.isEmpty(layerId)) {
if (layer != null) { AMapLayer layer = layers.get(layerId);
AMapPoint point = layer.getPoint(pointId); if (layer != null) {
if (point != null) { AMapPoint p = layer.getPoint(point.getId());
app.getSettings().setMapLocationToShow( if (p != null) {
point.getLocation().getLatitude(), point = p;
point.getLocation().getLongitude(), }
DEFAULT_ZOOM,
new PointDescription(PointDescription.POINT_TYPE_MARKER, point.getFullName()),
false,
point
);
MapActivity.launchMapActivityMoveToTop(app);
} }
} }
app.getSettings().setMapLocationToShow(
point.getLocation().getLatitude(),
point.getLocation().getLongitude(),
DEFAULT_ZOOM,
new PointDescription(PointDescription.POINT_TYPE_MARKER, point.getFullName()),
false,
point
);
MapActivity.launchMapActivityMoveToTop(app);
return true;
} }
return false; return false;
} }

View file

@ -23,10 +23,10 @@ import net.osmand.aidl.gpx.StopGpxRecordingParams;
import net.osmand.aidl.map.SetMapLocationParams; import net.osmand.aidl.map.SetMapLocationParams;
import net.osmand.aidl.maplayer.AddMapLayerParams; import net.osmand.aidl.maplayer.AddMapLayerParams;
import net.osmand.aidl.maplayer.RemoveMapLayerParams; import net.osmand.aidl.maplayer.RemoveMapLayerParams;
import net.osmand.aidl.maplayer.ShowLayerPointOnMapParams;
import net.osmand.aidl.maplayer.UpdateMapLayerParams; import net.osmand.aidl.maplayer.UpdateMapLayerParams;
import net.osmand.aidl.maplayer.point.AddMapPointParams; import net.osmand.aidl.maplayer.point.AddMapPointParams;
import net.osmand.aidl.maplayer.point.RemoveMapPointParams; import net.osmand.aidl.maplayer.point.RemoveMapPointParams;
import net.osmand.aidl.maplayer.point.ShowMapPointParams;
import net.osmand.aidl.maplayer.point.UpdateMapPointParams; import net.osmand.aidl.maplayer.point.UpdateMapPointParams;
import net.osmand.aidl.mapmarker.AddMapMarkerParams; import net.osmand.aidl.mapmarker.AddMapMarkerParams;
import net.osmand.aidl.mapmarker.RemoveMapMarkerParams; import net.osmand.aidl.mapmarker.RemoveMapMarkerParams;
@ -203,9 +203,9 @@ public class OsmandAidlService extends Service {
} }
@Override @Override
public boolean showLayerPointOnMap(ShowLayerPointOnMapParams params) throws RemoteException { public boolean showMapPoint(ShowMapPointParams params) throws RemoteException {
try { try {
return params != null && getApi("showLayerPointOnMap").showLayerPointOnMap(params.getLayerId(), params.getPointId()); return params != null && getApi("showMapPoint").showMapPoint(params.getLayerId(), params.getPoint());
} catch (Exception e) { } catch (Exception e) {
handleException(e); handleException(e);
return false; return false;

View file

@ -1,3 +0,0 @@
package net.osmand.aidl.maplayer;
parcelable ShowLayerPointOnMapParams;

View file

@ -1,51 +0,0 @@
package net.osmand.aidl.maplayer;
import android.os.Parcel;
import android.os.Parcelable;
public class ShowLayerPointOnMapParams implements Parcelable {
private String layerId;
private String pointId;
public ShowLayerPointOnMapParams(String layerId, String pointId) {
this.layerId = layerId;
this.pointId = pointId;
}
public ShowLayerPointOnMapParams(Parcel in) {
layerId = in.readString();
pointId = in.readString();
}
public String getLayerId() {
return layerId;
}
public String getPointId() {
return pointId;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(layerId);
dest.writeString(pointId);
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<ShowLayerPointOnMapParams> CREATOR = new Creator<ShowLayerPointOnMapParams>() {
@Override
public ShowLayerPointOnMapParams createFromParcel(Parcel in) {
return new ShowLayerPointOnMapParams(in);
}
@Override
public ShowLayerPointOnMapParams[] newArray(int size) {
return new ShowLayerPointOnMapParams[size];
}
};
}

View file

@ -0,0 +1,3 @@
package net.osmand.aidl.maplayer.point;
parcelable ShowMapPointParams;

View file

@ -0,0 +1,56 @@
package net.osmand.aidl.maplayer.point;
import android.os.Parcel;
import android.os.Parcelable;
public class ShowMapPointParams implements Parcelable {
private String layerId;
private AMapPoint point;
public ShowMapPointParams(String layerId, AMapPoint point) {
this.layerId = layerId;
this.point = point;
}
public ShowMapPointParams(Parcel in) {
readFromParcel(in);
}
public static final Creator<ShowMapPointParams> CREATOR = new
Creator<ShowMapPointParams>() {
@Override
public ShowMapPointParams createFromParcel(Parcel in) {
return new ShowMapPointParams(in);
}
@Override
public ShowMapPointParams[] newArray(int size) {
return new ShowMapPointParams[size];
}
};
public String getLayerId() {
return layerId;
}
public AMapPoint getPoint() {
return point;
}
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeString(layerId);
out.writeParcelable(point, flags);
}
private void readFromParcel(Parcel in) {
layerId = in.readString();
point = in.readParcelable(AMapPoint.class.getClassLoader());
}
@Override
public int describeContents() {
return 0;
}
}