Search in sources :

Example 1 with AFavoriteGroup

use of net.osmand.aidl.favorite.group.AFavoriteGroup in project Osmand by osmandapp.

the class OsmandAidlApi method addFavoriteGroup.

boolean addFavoriteGroup(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())) {
                return false;
            }
        }
        int color = 0;
        if (!Algorithms.isEmpty(favoriteGroup.getColor())) {
            color = ColorDialogs.getColorByTag(favoriteGroup.getColor());
        }
        favoritesHelper.addEmptyCategory(favoriteGroup.getName(), color, favoriteGroup.isVisible());
        return true;
    } else {
        return false;
    }
}
Also used : AFavoriteGroup(net.osmand.aidl.favorite.group.AFavoriteGroup) FavouritesDbHelper(net.osmand.plus.FavouritesDbHelper) FavouritePoint(net.osmand.data.FavouritePoint) AMapPoint(net.osmand.aidl.maplayer.point.AMapPoint)

Example 2 with AFavoriteGroup

use of net.osmand.aidl.favorite.group.AFavoriteGroup 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;
    }
}
Also used : AFavoriteGroup(net.osmand.aidl.favorite.group.AFavoriteGroup) FavouritesDbHelper(net.osmand.plus.FavouritesDbHelper) FavouritePoint(net.osmand.data.FavouritePoint) AMapPoint(net.osmand.aidl.maplayer.point.AMapPoint)

Example 3 with AFavoriteGroup

use of net.osmand.aidl.favorite.group.AFavoriteGroup 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;
    }
}
Also used : AFavoriteGroup(net.osmand.aidl.favorite.group.AFavoriteGroup) FavouritesDbHelper(net.osmand.plus.FavouritesDbHelper)

Aggregations

AFavoriteGroup (net.osmand.aidl.favorite.group.AFavoriteGroup)3 FavouritesDbHelper (net.osmand.plus.FavouritesDbHelper)3 AMapPoint (net.osmand.aidl.maplayer.point.AMapPoint)2 FavouritePoint (net.osmand.data.FavouritePoint)2