Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
0edddca4a5
5 changed files with 81 additions and 0 deletions
|
@ -5,6 +5,7 @@ import net.osmand.aidl.map.SetMapLocationParams;
|
|||
|
||||
import net.osmand.aidl.favorite.AFavorite;
|
||||
import net.osmand.aidl.favorite.AddFavoriteParams;
|
||||
import net.osmand.aidl.favorite.RemoveFavoriteParams;
|
||||
|
||||
import net.osmand.aidl.mapmarker.AMapMarker;
|
||||
import net.osmand.aidl.mapmarker.AddMapMarkerParams;
|
||||
|
@ -35,6 +36,7 @@ import net.osmand.aidl.maplayer.UpdateMapLayerParams;
|
|||
interface IOsmAndAidlInterface {
|
||||
|
||||
boolean addFavorite(in AddFavoriteParams params);
|
||||
boolean removeFavorite(in RemoveFavoriteParams params);
|
||||
|
||||
boolean addMapMarker(in AddMapMarkerParams params);
|
||||
boolean removeMapMarker(in RemoveMapMarkerParams params);
|
||||
|
|
|
@ -361,12 +361,31 @@ public class OsmandAidlApi {
|
|||
point.setColor(color);
|
||||
point.setVisible(favorite.isVisible());
|
||||
favoritesHelper.addFavourite(point);
|
||||
refreshMap();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
boolean removeFavorite(AFavorite favorite) {
|
||||
if (favorite != null) {
|
||||
FavouritesDbHelper favoritesHelper = app.getFavorites();
|
||||
List<FavouritePoint> favorites = favoritesHelper.getFavouritePoints();
|
||||
for (FavouritePoint f : favorites) {
|
||||
if (f.getName().equals(favorite.getName()) && f.getCategory().equals(favorite.getCategory()) &&
|
||||
f.getLatitude() == favorite.getLat() && f.getLongitude() == favorite.getLon()) {
|
||||
favoritesHelper.deleteFavourite(f);
|
||||
refreshMap();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
boolean addMapMarker(AMapMarker marker) {
|
||||
if (marker != null) {
|
||||
PointDescription pd = new PointDescription(
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.os.RemoteException;
|
|||
|
||||
import net.osmand.aidl.calculateroute.CalculateRouteParams;
|
||||
import net.osmand.aidl.favorite.AddFavoriteParams;
|
||||
import net.osmand.aidl.favorite.RemoveFavoriteParams;
|
||||
import net.osmand.aidl.gpx.ASelectedGpxFile;
|
||||
import net.osmand.aidl.gpx.HideGpxParams;
|
||||
import net.osmand.aidl.gpx.ImportGpxParams;
|
||||
|
@ -56,6 +57,15 @@ public class OsmandAidlService extends Service {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeFavorite(RemoveFavoriteParams params) throws RemoteException {
|
||||
try {
|
||||
return params != null && getApi().removeFavorite(params.getFavorite());
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addMapMarker(AddMapMarkerParams params) throws RemoteException {
|
||||
try {
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidl.favorite;
|
||||
|
||||
parcelable RemoveFavoriteParams;
|
|
@ -0,0 +1,47 @@
|
|||
package net.osmand.aidl.favorite;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
public class RemoveFavoriteParams implements Parcelable {
|
||||
|
||||
private AFavorite favorite;
|
||||
|
||||
public RemoveFavoriteParams(AFavorite favorite) {
|
||||
this.favorite = favorite;
|
||||
}
|
||||
|
||||
public RemoveFavoriteParams(Parcel in) {
|
||||
readFromParcel(in);
|
||||
}
|
||||
|
||||
public static final Creator<RemoveFavoriteParams> CREATOR = new Creator<RemoveFavoriteParams>() {
|
||||
@Override
|
||||
public RemoveFavoriteParams createFromParcel(Parcel in) {
|
||||
return new RemoveFavoriteParams(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoveFavoriteParams[] newArray(int size) {
|
||||
return new RemoveFavoriteParams[size];
|
||||
}
|
||||
};
|
||||
|
||||
public AFavorite getFavorite() {
|
||||
return favorite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
out.writeParcelable(favorite, flags);
|
||||
}
|
||||
|
||||
private void readFromParcel(Parcel in) {
|
||||
favorite = in.readParcelable(AFavorite.class.getClassLoader());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue