From e97c85cf95abd928bc4ae59e3b6fdf9a7856c1a8 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 15 Nov 2017 19:06:20 +0200 Subject: [PATCH] Store favourite point and waypoint in marker when sync --- .../src/net/osmand/plus/MapMarkersHelper.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java index 6bafde3b7a..9487b8f52e 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java @@ -75,6 +75,8 @@ public class MapMarkersHelper { public String nextKey; public String groupKey; public String groupName; + public WptPt wptPt; + public FavouritePoint favouritePoint; public MapMarker(LatLon point, PointDescription name, int colorIndex, boolean selected, int index) { @@ -516,7 +518,7 @@ public class MapMarkersHelper { } for (FavouritePoint fp : favGroup.points) { - addNewMarkerIfNeeded(group, dbMarkers, new LatLon(fp.getLatitude(), fp.getLongitude()), fp.getName(), enabled); + addNewMarkerIfNeeded(group, dbMarkers, new LatLon(fp.getLatitude(), fp.getLongitude()), fp.getName(), enabled, fp, null); } favouritesDbHelper.removeSyncedGroup(favGroup); favouritesDbHelper.addSyncedGroup(favGroup); @@ -541,7 +543,7 @@ public class MapMarkersHelper { int defColor = ContextCompat.getColor(ctx, R.color.marker_red); for (WptPt pt : gpxPoints) { group.setColor(pt.getColor(defColor)); - addNewMarkerIfNeeded(group, dbMarkers, new LatLon(pt.lat, pt.lon), pt.name, enabled); + addNewMarkerIfNeeded(group, dbMarkers, new LatLon(pt.lat, pt.lon), pt.name, enabled, null, pt); } gpx.setSynced(true); @@ -561,7 +563,7 @@ public class MapMarkersHelper { } } - private void addNewMarkerIfNeeded(MarkersSyncGroup group, List markers, LatLon latLon, String name, boolean enabled) { + private void addNewMarkerIfNeeded(MarkersSyncGroup group, List markers, LatLon latLon, String name, boolean enabled, FavouritePoint favouritePoint, WptPt wptPt) { boolean exists = false; for (MapMarker marker : markers) { @@ -583,7 +585,8 @@ public class MapMarkersHelper { if (!exists) { addMarkers(Collections.singletonList(latLon), - Collections.singletonList(new PointDescription(POINT_TYPE_MAP_MARKER, name)), group, enabled); + Collections.singletonList(new PointDescription(POINT_TYPE_MAP_MARKER, name)), + group, enabled, Collections.singletonList(favouritePoint), Collections.singletonList(wptPt)); } } @@ -896,12 +899,19 @@ public class MapMarkersHelper { } private void addMarkers(List points, List historyNames, @Nullable MarkersSyncGroup group, boolean enabled) { + addMarkers(points, historyNames, group, enabled, new ArrayList(), new ArrayList()); + } + + private void addMarkers(List points, List historyNames, @Nullable MarkersSyncGroup group, + boolean enabled, List favouritePoints, List wptPts) { if (points.size() > 0) { int colorIndex = -1; List addedMarkers = new ArrayList<>(); for (int i = 0; i < points.size(); i++) { LatLon point = points.get(i); PointDescription historyName = historyNames.get(i); + FavouritePoint favouritePoint = favouritePoints.get(i); + WptPt wptPt = wptPts.get(i); final PointDescription pointDescription; if (historyName == null) { pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, ""); @@ -932,6 +942,8 @@ public class MapMarkersHelper { } marker.history = false; marker.nextKey = MapMarkersDbHelper.TAIL_NEXT_VALUE; + marker.favouritePoint = favouritePoint; + marker.wptPt = wptPt; markersDbHelper.addMarker(marker); if (enabled) { addToMapMarkersList(0, marker);