Remove favorite group with aidl
This commit is contained in:
parent
a32be27bb9
commit
a89946290b
5 changed files with 78 additions and 0 deletions
|
@ -5,6 +5,7 @@ import net.osmand.aidl.map.SetMapLocationParams;
|
|||
|
||||
import net.osmand.aidl.favorite.group.AFavoriteGroup;
|
||||
import net.osmand.aidl.favorite.group.AddFavoriteGroupParams;
|
||||
import net.osmand.aidl.favorite.group.RemoveFavoriteGroupParams;
|
||||
|
||||
import net.osmand.aidl.favorite.AFavorite;
|
||||
import net.osmand.aidl.favorite.AddFavoriteParams;
|
||||
|
@ -40,6 +41,7 @@ import net.osmand.aidl.maplayer.UpdateMapLayerParams;
|
|||
interface IOsmAndAidlInterface {
|
||||
|
||||
boolean addFavoriteGroup(in AddFavoriteGroupParams params);
|
||||
boolean removeFavoriteGroup(in RemoveFavoriteGroupParams params);
|
||||
|
||||
boolean addFavorite(in AddFavoriteParams params);
|
||||
boolean removeFavorite(in RemoveFavoriteParams params);
|
||||
|
|
|
@ -364,6 +364,22 @@ public class OsmandAidlApi {
|
|||
}
|
||||
}
|
||||
|
||||
boolean removeFavoriteGroup(AFavoriteGroup favoriteGroup) {
|
||||
if (favoriteGroup != null) {
|
||||
FavouritesDbHelper favoritesHelper = app.getFavorites();
|
||||
List<FavouritesDbHelper.FavoriteGroup> groups = favoritesHelper.getFavoriteGroups();
|
||||
for (FavouritesDbHelper.FavoriteGroup g : groups) {
|
||||
if (g.name.equals(favoriteGroup.getName())) {
|
||||
favoritesHelper.deleteGroup(g);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
boolean addFavorite(AFavorite favorite) {
|
||||
if (favorite != null) {
|
||||
FavouritesDbHelper favoritesHelper = app.getFavorites();
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.osmand.aidl.favorite.AddFavoriteParams;
|
|||
import net.osmand.aidl.favorite.RemoveFavoriteParams;
|
||||
import net.osmand.aidl.favorite.UpdateFavoriteParams;
|
||||
import net.osmand.aidl.favorite.group.AddFavoriteGroupParams;
|
||||
import net.osmand.aidl.favorite.group.RemoveFavoriteGroupParams;
|
||||
import net.osmand.aidl.gpx.ASelectedGpxFile;
|
||||
import net.osmand.aidl.gpx.HideGpxParams;
|
||||
import net.osmand.aidl.gpx.ImportGpxParams;
|
||||
|
@ -59,6 +60,15 @@ public class OsmandAidlService extends Service {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeFavoriteGroup(RemoveFavoriteGroupParams params) throws RemoteException {
|
||||
try {
|
||||
return params != null && getApi().removeFavoriteGroup(params.getFavoriteGroup());
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addFavorite(AddFavoriteParams params) throws RemoteException {
|
||||
try {
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidl.favorite.group;
|
||||
|
||||
parcelable RemoveFavoriteGroupParams;
|
|
@ -0,0 +1,47 @@
|
|||
package net.osmand.aidl.favorite.group;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
public class RemoveFavoriteGroupParams implements Parcelable {
|
||||
|
||||
private AFavoriteGroup favoriteGroup;
|
||||
|
||||
public RemoveFavoriteGroupParams(AFavoriteGroup favoriteGroup) {
|
||||
this.favoriteGroup = favoriteGroup;
|
||||
}
|
||||
|
||||
public RemoveFavoriteGroupParams(Parcel in) {
|
||||
readFromParcel(in);
|
||||
}
|
||||
|
||||
public static final Creator<RemoveFavoriteGroupParams> CREATOR = new Creator<RemoveFavoriteGroupParams>() {
|
||||
@Override
|
||||
public RemoveFavoriteGroupParams createFromParcel(Parcel in) {
|
||||
return new RemoveFavoriteGroupParams(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoveFavoriteGroupParams[] newArray(int size) {
|
||||
return new RemoveFavoriteGroupParams[size];
|
||||
}
|
||||
};
|
||||
|
||||
public AFavoriteGroup getFavoriteGroup() {
|
||||
return favoriteGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
out.writeParcelable(favoriteGroup, flags);
|
||||
}
|
||||
|
||||
private void readFromParcel(Parcel in) {
|
||||
favoriteGroup = in.readParcelable(AFavoriteGroup.class.getClassLoader());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue