Search in sources :

Example 11 with FavouritesDbHelper

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;
    }
}
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 12 with FavouritesDbHelper

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;
    }
}
Also used : FavouritePoint(net.osmand.data.FavouritePoint) FavouritesDbHelper(net.osmand.plus.FavouritesDbHelper)

Example 13 with FavouritesDbHelper

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

Example 14 with FavouritesDbHelper

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

Aggregations

FavouritesDbHelper (net.osmand.plus.FavouritesDbHelper)14 FavouritePoint (net.osmand.data.FavouritePoint)10 AlertDialog (android.support.v7.app.AlertDialog)6 View (android.view.View)6 OsmandApplication (net.osmand.plus.OsmandApplication)5 DialogInterface (android.content.DialogInterface)4 EditText (android.widget.EditText)4 TextView (android.widget.TextView)4 AdapterView (android.widget.AdapterView)3 ImageView (android.widget.ImageView)3 AFavoriteGroup (net.osmand.aidl.favorite.group.AFavoriteGroup)3 AMapPoint (net.osmand.aidl.maplayer.point.AMapPoint)3 Dialog (android.app.Dialog)2 AutoCompleteTextView (android.widget.AutoCompleteTextView)2 LinearLayout (android.widget.LinearLayout)2 ListView (android.widget.ListView)2 ArrayList (java.util.ArrayList)2 LatLon (net.osmand.data.LatLon)2 PointDescription (net.osmand.data.PointDescription)2 MapMarkersHelper (net.osmand.plus.MapMarkersHelper)2