From 2524a3f73a604f52bf04d607df9ff75ed60d896e Mon Sep 17 00:00:00 2001 From: cepprice Date: Sun, 18 Apr 2021 16:00:54 +0500 Subject: [PATCH] Review fixes --- .../net/osmand/plus/views/layers/GPXLayer.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java index 7185fbc7c7..7ce7ec3feb 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java @@ -277,7 +277,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM } } cache.clear(); - fireUnselectedGpxFiles(selectedGPXFiles); + removeCachedUnselectedTracks(selectedGPXFiles); if (!selectedGPXFiles.isEmpty()) { drawSelectedFilesSegments(canvas, tileBox, selectedGPXFiles, settings); canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY()); @@ -460,10 +460,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM QuadRect correctedQuadRect = getCorrectedQuadRect(tileBox.getLatLonBounds()); for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) { boolean showArrows = isShowArrowsForTrack(selectedGpxFile.getGpxFile()); - if (!showArrows) { - continue; - } - if (!QuadRect.trivialOverlap(correctedQuadRect, GPXUtilities.calculateTrackBounds(selectedGpxFile.getPointsToDisplay()))) { + if (!showArrows || !QuadRect.trivialOverlap(correctedQuadRect, GPXUtilities.calculateTrackBounds(selectedGpxFile.getPointsToDisplay()))) { continue; } String width = getTrackWidthName(selectedGpxFile.getGpxFile(), defaultTrackWidthPref.get()); @@ -1056,15 +1053,15 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM return name.replace('_', ' '); } - private void fireUnselectedGpxFiles(List selectedGpxFiles) { + private void removeCachedUnselectedTracks(List selectedGpxFiles) { Set cachedTracksPaths = segmentsCache.keySet(); List selectedTracksPaths = new ArrayList<>(); for (SelectedGpxFile gpx : selectedGpxFiles) { selectedTracksPaths.add(gpx.getGpxFile().path); } - for (String cachedPath : cachedTracksPaths) { - if (!selectedTracksPaths.contains(cachedPath)) { - cachedTracksPaths.remove(cachedPath); + for (Iterator iterator = cachedTracksPaths.iterator(); iterator.hasNext();) { + if (!selectedTracksPaths.contains(iterator.next())) { + iterator.remove(); } } }