use of net.osmand.plus.FavouritesDbHelper in project Osmand by osmandapp.
the class OsmandAidlApi method updateFavoriteGroup.
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;
}
}
use of net.osmand.plus.FavouritesDbHelper in project Osmand by osmandapp.
the class OsmandAidlApi method updateFavorite.
boolean updateFavorite(AFavorite fPrev, AFavorite fNew) {
if (fPrev != null && fNew != null) {
FavouritesDbHelper favoritesHelper = app.getFavorites();
List<FavouritePoint> favorites = favoritesHelper.getFavouritePoints();
for (FavouritePoint f : favorites) {
if (f.getName().equals(fPrev.getName()) && f.getCategory().equals(fPrev.getCategory()) && f.getLatitude() == fPrev.getLat() && f.getLongitude() == fPrev.getLon()) {
if (fNew.getLat() != f.getLatitude() || fNew.getLon() != f.getLongitude()) {
favoritesHelper.editFavourite(f, fNew.getLat(), fNew.getLon());
}
if (!fNew.getName().equals(f.getName()) || !fNew.getDescription().equals(f.getDescription()) || !fNew.getCategory().equals(f.getCategory())) {
favoritesHelper.editFavouriteName(f, fNew.getName(), fNew.getCategory(), fNew.getDescription());
}
refreshMap();
return true;
}
}
return false;
} else {
return false;
}
}
use of net.osmand.plus.FavouritesDbHelper in project Osmand by osmandapp.
the class OsmandAidlApi method addFavorite.
boolean addFavorite(AFavorite favorite) {
if (favorite != null) {
FavouritesDbHelper favoritesHelper = app.getFavorites();
FavouritePoint point = new FavouritePoint(favorite.getLat(), favorite.getLon(), favorite.getName(), favorite.getCategory());
point.setDescription(favorite.getDescription());
int color = 0;
if (!Algorithms.isEmpty(favorite.getColor())) {
color = ColorDialogs.getColorByTag(favorite.getColor());
}
point.setColor(color);
point.setVisible(favorite.isVisible());
favoritesHelper.addFavourite(point);
refreshMap();
return true;
} else {
return false;
}
}
use of net.osmand.plus.FavouritesDbHelper in project Osmand by osmandapp.
the class OsmandAidlApi method removeFavoriteGroup.
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;
}
}
Aggregations