From 783b0f64b29e462d7aa3a88b6b55650a49fa800e Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 5 Oct 2017 13:03:51 +0300 Subject: [PATCH] Save snapped points and mode in markers helper --- .../src/net/osmand/plus/MapMarkersHelper.java | 17 +++++++++++++++++ .../plus/mapmarkers/PlanRouteFragment.java | 7 ++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java index 9bfb1469c1..c295947bec 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java @@ -4,6 +4,7 @@ import android.content.Context; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.content.ContextCompat; +import android.util.Pair; import net.osmand.IndexConstants; import net.osmand.data.FavouritePoint; @@ -27,6 +28,7 @@ import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import static net.osmand.data.PointDescription.POINT_TYPE_MAP_MARKER; @@ -42,6 +44,9 @@ public class MapMarkersHelper { private MapMarkersDbHelper markersDbHelper; private boolean startFromMyLocation; + private final Map, List> snappedToRoadPoints = new ConcurrentHashMap<>(); + private ApplicationMode snappedMode; + public interface MapMarkerChangedListener { void onMapMarkerChanged(MapMarker mapMarker); @@ -231,6 +236,18 @@ public class MapMarkersHelper { createMapMarkersGroups(); } + public Map, List> getSnappedToRoadPoints() { + return snappedToRoadPoints; + } + + public ApplicationMode getSnappedMode() { + return snappedMode; + } + + public void setSnappedMode(ApplicationMode snappedMode) { + this.snappedMode = snappedMode; + } + public boolean isStartFromMyLocation() { return startFromMyLocation; } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java index f1a7d96f77..3e58861599 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java @@ -63,7 +63,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Queue; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; import static net.osmand.plus.OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT; @@ -96,7 +95,7 @@ public class PlanRouteFragment extends Fragment { private TextView countTv; private final Queue> snapToRoadPairsToCalculate = new ConcurrentLinkedQueue<>(); - private final Map, List> snappedToRoadPoints = new ConcurrentHashMap<>(); + private Map, List> snappedToRoadPoints; private TrkSegment snapTrkSegment = new TrkSegment(); private RouteCalculationProgress calculationProgress; private int calculatedPairs; @@ -107,6 +106,7 @@ public class PlanRouteFragment extends Fragment { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { final MapActivity mapActivity = getMapActivity(); markersHelper = mapActivity.getMyApplication().getMapMarkersHelper(); + snappedToRoadPoints = markersHelper.getSnappedToRoadPoints(); // Handling screen rotation FragmentManager fragmentManager = mapActivity.getSupportFragmentManager(); @@ -363,6 +363,7 @@ public class PlanRouteFragment extends Fragment { if (appMode != null && !appMode.getStringKey().equals(mode.getStringKey())) { appMode = mode; snappedToRoadPoints.clear(); + markersHelper.setSnappedMode(mode); recreateSnapTrkSegment(); setupAppModesBtn(); } @@ -426,7 +427,7 @@ public class PlanRouteFragment extends Fragment { wasCollapseButtonVisible = false; } - if (appMode == null) { + if ((appMode = markersHelper.getSnappedMode()) == null) { appMode = ApplicationMode.DEFAULT; } setupAppModesBtn();