From 2697095a9933f471bf63b76ecfac5ddd8b8e95b7 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Wed, 19 Feb 2020 12:40:44 +0200 Subject: [PATCH] Fix remarks remove loadingFileName --- .../net/osmand/plus/GpxSelectionHelper.java | 49 +++---------------- .../plus/myplaces/AvailableGPXFragment.java | 5 +- 2 files changed, 11 insertions(+), 43 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index 3bef239a9d..31bec44718 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -440,16 +440,6 @@ public class GpxSelectionHelper { } } - private SelectedGpxFile getSelectedFileByLoadedFileName(String path) { - List newList = new ArrayList<>(selectedGPXFiles); - for (SelectedGpxFile s : newList) { - if (path.endsWith("/" + s.getLoadedName())) { - return s; - } - } - return null; - } - public SelectedGpxFile getSelectedFileByPath(String path) { List newList = new ArrayList<>(selectedGPXFiles); for (SelectedGpxFile s : newList) { @@ -462,10 +452,7 @@ public class GpxSelectionHelper { public SelectedGpxFile getSelectedFileByName(String path) { for (SelectedGpxFile s : selectedGPXFiles) { - if (path.equals(s.getLoadedName())) { - return s; - } - if (s.getLoadedName().isEmpty() && s.getGpxFile().path.endsWith("/" + path)) { + if (s.getGpxFile().path.endsWith("/" + path)) { return s; } } @@ -604,17 +591,11 @@ public class GpxSelectionHelper { } } else { assert gpx != null; - sf = getSelectedFileByLoadedFileName(gpx.path); - if (sf == null) { - sf = getSelectedFileByPath(gpx.path); - } + sf = getSelectedFileByPath(gpx.path); displayed = sf != null; if (show) { if (sf == null) { sf = new SelectedGpxFile(); - List newSelectedGPXFiles = new ArrayList<>(selectedGPXFiles); - newSelectedGPXFiles.add(sf); - selectedGPXFiles = newSelectedGPXFiles; } if (dataItem != null) { if (dataItem.getColor() != 0) { @@ -623,22 +604,13 @@ public class GpxSelectionHelper { sf.setJoinSegments(dataItem.isJoinSegments()); } sf.setGpxFile(gpx, app); - sf.setLoadedName(""); sf.notShowNavigationDialog = notShowNavigationDialog; sf.selectedByUser = selectedByUser; } } - if (sf != null && sf.getLoadedName().isEmpty()) { + if (sf != null && sf.isLoaded()) { if (displayed != show) { - List newSelectedGPXFiles = new ArrayList<>(selectedGPXFiles); - if (show) { - if (!newSelectedGPXFiles.contains(sf)) { - newSelectedGPXFiles.add(sf); - } - } else { - newSelectedGPXFiles.remove(sf); - } - selectedGPXFiles = newSelectedGPXFiles; + addRemoveSelected(show, sf); } } if (syncGroup) { @@ -727,15 +699,6 @@ public class GpxSelectionHelper { private boolean joinSegments; private boolean showCurrentTrack; private boolean splitProcessed = false; - private String loadedName = ""; - - public String getLoadedName() { - return loadedName; - } - - public void setLoadedName(String loadedName) { - this.loadedName = loadedName; - } public void setGpxFile(GPXFile gpxFile, OsmandApplication app) { this.gpxFile = gpxFile; @@ -745,6 +708,10 @@ public class GpxSelectionHelper { processPoints(app); } + public boolean isLoaded() { + return gpxFile.modifiedTime != 0 || gpxFile.showCurrentTrack; + } + public GPXTrackAnalysis getTrackAnalysis(OsmandApplication app) { if (modifiedTime != gpxFile.modifiedTime) { update(app); diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index 43faa235ec..74afe1ffc7 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -623,8 +623,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement SelectedGpxFile sf = selectedGpxHelper.getSelectedFileByName(gpxInfo.fileName); if (sf == null) { sf = new SelectedGpxFile(); + sf.setGpxFile(new GPXFile(null), app); } - sf.setLoadedName(gpxInfo.fileName); + sf.getGpxFile().path = gpxInfo.file.getPath(); selectedGpxHelper.addRemoveSelected(visible, sf); } } @@ -1884,7 +1885,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement SelectedGpxFile sgpx = getSelectedGpxFile(gpxInfo, app); GPXTrackAnalysis analysis = null; if (sgpx != null) { - if (sgpx.getLoadedName().isEmpty()) { + if (sgpx.isLoaded()) { analysis = sgpx.getTrackAnalysis(app); } } else if (gpxInfo.currentlyRecordingTrack) {