diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java index e8330de7d0..592e2f6918 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java @@ -369,6 +369,7 @@ public class MapMarkersHelper { } if (!favGroup.visible) { removeActiveMarkersFromSyncGroup(group.getId()); + removeActiveMarkersFromGroup(group.getId()); return; } if (group.getColor() == -1) { @@ -391,6 +392,7 @@ public class MapMarkersHelper { GPXFile gpx = selectedGpxFile == null ? null : selectedGpxFile.getGpxFile(); if (gpx == null) { removeActiveMarkersFromSyncGroup(group.getId()); + removeActiveMarkersFromGroup(group.getId()); return; } @@ -438,6 +440,7 @@ public class MapMarkersHelper { if (!marker.history) { markersDbHelper.removeMarker(marker, false); mapMarkers.remove(marker); + removeMarkerFromGroup(marker); needRefresh = true; } } @@ -861,6 +864,21 @@ public class MapMarkersHelper { } } + private void removeActiveMarkersFromGroup(String groupId) { + MapMarkersGroup group = getMapMarkerGroupByKey(groupId); + if (group != null) { + List markers = group.getMarkers(); + List historyMarkers = new ArrayList<>(); + for (MapMarker marker : markers) { + if (marker.history) { + historyMarkers.add(marker); + } + } + group.setMarkers(historyMarkers); + updateGroup(group); + } + } + public void updateGroup(MapMarkersGroup mapMarkersGroup) { if (mapMarkersGroup.getMarkers().size() == 0) { mapMarkersGroups.remove(mapMarkersGroup); @@ -1029,6 +1047,16 @@ public class MapMarkersHelper { return null; } + public MapMarkersGroup getMapMarkerGroupByKey(String key) { + for (MapMarkersGroup group : mapMarkersGroups) { + if ((key == null && group.getGroupKey() == null) + || (group.getGroupKey() != null && group.getGroupKey().equals(key))) { + return group; + } + } + return null; + } + public static class MapMarkersGroup { private String name; private String groupKey;