From a2988c96960cc67ddea176999f59005693c9f26f Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 23 Mar 2018 15:18:06 +0200 Subject: [PATCH] Show disabled groups until restart --- .../src/net/osmand/plus/MapMarkersHelper.java | 28 +++++++++++---- .../adapters/MapMarkersGroupsAdapter.java | 36 ++++++++++++------- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java index 457dc79a4e..70cdad461b 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java @@ -282,11 +282,15 @@ public class MapMarkersHelper { return getMapMarkerGroupById(id) != null; } - public void runSynchronization(@NonNull final MapMarkersGroup group) { + public void runSynchronization(@NonNull MapMarkersGroup group) { + runSynchronization(group, false); + } + + public void runSynchronization(@NonNull final MapMarkersGroup group, final boolean loadGpx) { ctx.runInUIThread(new Runnable() { @Override public void run() { - new SyncGroupTask(group).executeOnExecutor(executorService); + new SyncGroupTask(group, loadGpx).executeOnExecutor(executorService); } }); } @@ -1038,9 +1042,11 @@ public class MapMarkersHelper { private class SyncGroupTask extends AsyncTask { private MapMarkersGroup group; + private boolean loadGpx; - SyncGroupTask(MapMarkersGroup group) { + SyncGroupTask(MapMarkersGroup group, boolean loadGpx) { this.group = group; + this.loadGpx = loadGpx; } @Override @@ -1094,10 +1100,15 @@ public class MapMarkersHelper { return; } - SelectedGpxFile selectedGpxFile = gpxHelper.getSelectedFileByPath(group.getId()); + String gpxPath = group.getId(); + SelectedGpxFile selectedGpxFile = gpxHelper.getSelectedFileByPath(gpxPath); GPXFile gpx = selectedGpxFile == null ? null : selectedGpxFile.getGpxFile(); - group.visible = gpx != null; - if (!group.isVisible() || group.isDisabled()) { + if (gpx == null && loadGpx) { + gpx = GPXUtilities.loadGPXFile(ctx, new File(gpxPath)); + gpxHelper.selectGpxFile(gpx, true, false, false); + } + group.visible = gpx != null || group.visibleUntilRestart; + if (gpx == null || group.isDisabled()) { removeGroupActiveMarkers(group, true); return; } @@ -1144,6 +1155,7 @@ public class MapMarkersHelper { private long creationDate; private boolean disabled; private boolean visible = true; + private boolean visibleUntilRestart; private List markers = new ArrayList<>(); // TODO should be removed from this class: private GroupHeader header; @@ -1187,6 +1199,10 @@ public class MapMarkersHelper { return visible; } + public void setVisibleUntilRestart(boolean visibleUntilRestart) { + this.visibleUntilRestart = visibleUntilRestart; + } + public List getMarkers() { return markers; } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java index 2db2218bbe..5eb96b3b24 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java @@ -9,7 +9,6 @@ import android.view.View; import android.view.ViewGroup; import android.widget.CompoundButton; import android.widget.ImageView; -import android.widget.TextView; import net.osmand.AndroidUtils; import net.osmand.data.LatLon; @@ -393,27 +392,40 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter