Update favorite group with aidl
This commit is contained in:
parent
a89946290b
commit
760e218475
5 changed files with 90 additions and 0 deletions
|
@ -6,6 +6,7 @@ import net.osmand.aidl.map.SetMapLocationParams;
|
||||||
import net.osmand.aidl.favorite.group.AFavoriteGroup;
|
import net.osmand.aidl.favorite.group.AFavoriteGroup;
|
||||||
import net.osmand.aidl.favorite.group.AddFavoriteGroupParams;
|
import net.osmand.aidl.favorite.group.AddFavoriteGroupParams;
|
||||||
import net.osmand.aidl.favorite.group.RemoveFavoriteGroupParams;
|
import net.osmand.aidl.favorite.group.RemoveFavoriteGroupParams;
|
||||||
|
import net.osmand.aidl.favorite.group.UpdateFavoriteGroupParams;
|
||||||
|
|
||||||
import net.osmand.aidl.favorite.AFavorite;
|
import net.osmand.aidl.favorite.AFavorite;
|
||||||
import net.osmand.aidl.favorite.AddFavoriteParams;
|
import net.osmand.aidl.favorite.AddFavoriteParams;
|
||||||
|
@ -42,6 +43,7 @@ interface IOsmAndAidlInterface {
|
||||||
|
|
||||||
boolean addFavoriteGroup(in AddFavoriteGroupParams params);
|
boolean addFavoriteGroup(in AddFavoriteGroupParams params);
|
||||||
boolean removeFavoriteGroup(in RemoveFavoriteGroupParams params);
|
boolean removeFavoriteGroup(in RemoveFavoriteGroupParams params);
|
||||||
|
boolean updateFavoriteGroup(in UpdateFavoriteGroupParams params);
|
||||||
|
|
||||||
boolean addFavorite(in AddFavoriteParams params);
|
boolean addFavorite(in AddFavoriteParams params);
|
||||||
boolean removeFavorite(in RemoveFavoriteParams params);
|
boolean removeFavorite(in RemoveFavoriteParams params);
|
||||||
|
|
|
@ -380,6 +380,26 @@ public class OsmandAidlApi {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean updateFavoriteGroup(AFavoriteGroup gPrev, AFavoriteGroup gNew) {
|
||||||
|
if (gPrev != null && gNew != null) {
|
||||||
|
FavouritesDbHelper favoritesHelper = app.getFavorites();
|
||||||
|
List<FavouritesDbHelper.FavoriteGroup> groups = favoritesHelper.getFavoriteGroups();
|
||||||
|
for (FavouritesDbHelper.FavoriteGroup g : groups) {
|
||||||
|
if (g.name.equals(gPrev.getName())) {
|
||||||
|
int color = 0;
|
||||||
|
if (!Algorithms.isEmpty(gNew.getColor())) {
|
||||||
|
color = ColorDialogs.getColorByTag(gNew.getColor());
|
||||||
|
}
|
||||||
|
favoritesHelper.editFavouriteGroup(g, gNew.getName(), color, gNew.isVisible());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean addFavorite(AFavorite favorite) {
|
boolean addFavorite(AFavorite favorite) {
|
||||||
if (favorite != null) {
|
if (favorite != null) {
|
||||||
FavouritesDbHelper favoritesHelper = app.getFavorites();
|
FavouritesDbHelper favoritesHelper = app.getFavorites();
|
||||||
|
|
|
@ -11,6 +11,7 @@ import net.osmand.aidl.favorite.RemoveFavoriteParams;
|
||||||
import net.osmand.aidl.favorite.UpdateFavoriteParams;
|
import net.osmand.aidl.favorite.UpdateFavoriteParams;
|
||||||
import net.osmand.aidl.favorite.group.AddFavoriteGroupParams;
|
import net.osmand.aidl.favorite.group.AddFavoriteGroupParams;
|
||||||
import net.osmand.aidl.favorite.group.RemoveFavoriteGroupParams;
|
import net.osmand.aidl.favorite.group.RemoveFavoriteGroupParams;
|
||||||
|
import net.osmand.aidl.favorite.group.UpdateFavoriteGroupParams;
|
||||||
import net.osmand.aidl.gpx.ASelectedGpxFile;
|
import net.osmand.aidl.gpx.ASelectedGpxFile;
|
||||||
import net.osmand.aidl.gpx.HideGpxParams;
|
import net.osmand.aidl.gpx.HideGpxParams;
|
||||||
import net.osmand.aidl.gpx.ImportGpxParams;
|
import net.osmand.aidl.gpx.ImportGpxParams;
|
||||||
|
@ -69,6 +70,15 @@ public class OsmandAidlService extends Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateFavoriteGroup(UpdateFavoriteGroupParams params) throws RemoteException {
|
||||||
|
try {
|
||||||
|
return params != null && getApi().updateFavoriteGroup(params.getFavoriteGroupPrev(), params.getFavoriteGroupNew());
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addFavorite(AddFavoriteParams params) throws RemoteException {
|
public boolean addFavorite(AddFavoriteParams params) throws RemoteException {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package net.osmand.aidl.favorite.group;
|
||||||
|
|
||||||
|
parcelable UpdateFavoriteGroupParams;
|
|
@ -0,0 +1,55 @@
|
||||||
|
package net.osmand.aidl.favorite.group;
|
||||||
|
|
||||||
|
import android.os.Parcel;
|
||||||
|
import android.os.Parcelable;
|
||||||
|
|
||||||
|
public class UpdateFavoriteGroupParams implements Parcelable {
|
||||||
|
|
||||||
|
private AFavoriteGroup favoriteGroupPrev;
|
||||||
|
private AFavoriteGroup favoriteGroupNew;
|
||||||
|
|
||||||
|
public UpdateFavoriteGroupParams(AFavoriteGroup favoriteGroup, AFavoriteGroup favoriteGroupNew) {
|
||||||
|
this.favoriteGroupPrev = favoriteGroup;
|
||||||
|
this.favoriteGroupNew = favoriteGroupNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UpdateFavoriteGroupParams(Parcel in) {
|
||||||
|
readFromParcel(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Creator<UpdateFavoriteGroupParams> CREATOR = new Creator<UpdateFavoriteGroupParams>() {
|
||||||
|
@Override
|
||||||
|
public UpdateFavoriteGroupParams createFromParcel(Parcel in) {
|
||||||
|
return new UpdateFavoriteGroupParams(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UpdateFavoriteGroupParams[] newArray(int size) {
|
||||||
|
return new UpdateFavoriteGroupParams[size];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public AFavoriteGroup getFavoriteGroupPrev() {
|
||||||
|
return favoriteGroupPrev;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AFavoriteGroup getFavoriteGroupNew() {
|
||||||
|
return favoriteGroupNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToParcel(Parcel out, int flags) {
|
||||||
|
out.writeParcelable(favoriteGroupPrev, flags);
|
||||||
|
out.writeParcelable(favoriteGroupNew, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readFromParcel(Parcel in) {
|
||||||
|
favoriteGroupPrev = in.readParcelable(AFavoriteGroup.class.getClassLoader());
|
||||||
|
favoriteGroupNew = in.readParcelable(AFavoriteGroup.class.getClassLoader());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int describeContents() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue