From 29db40747ae210f5f7955ac57a0afc884a40a3b7 Mon Sep 17 00:00:00 2001 From: Chumva Date: Sat, 13 Jul 2019 12:20:24 +0300 Subject: [PATCH] Fix #7233 --- .../plus/myplaces/TrackBitmapDrawer.java | 51 ++++++++++--------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackBitmapDrawer.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackBitmapDrawer.java index 47ab04446b..627c72ca06 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackBitmapDrawer.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackBitmapDrawer.java @@ -12,13 +12,13 @@ import android.support.annotation.Nullable; import android.support.v4.content.ContextCompat; import net.osmand.AndroidUtils; +import net.osmand.GPXUtilities; +import net.osmand.GPXUtilities.GPXFile; +import net.osmand.GPXUtilities.TrkSegment; import net.osmand.data.LatLon; import net.osmand.data.QuadRect; import net.osmand.data.RotatedTileBox; import net.osmand.plus.GPXDatabase.GpxDataItem; -import net.osmand.GPXUtilities; -import net.osmand.GPXUtilities.GPXFile; -import net.osmand.GPXUtilities.TrkSegment; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -30,6 +30,7 @@ import net.osmand.plus.views.Renderable; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.RejectedExecutionException; public class TrackBitmapDrawer { @@ -225,30 +226,34 @@ public class TrackBitmapDrawer { } private void drawTrack(Canvas canvas, RotatedTileBox tileBox, GpxSelectionHelper.SelectedGpxFile g) { - GpxDataItem gpxDataItem = null; - if (!g.isShowCurrentTrack()) { - gpxDataItem = getGpxDataItem(); - } - List segments = g.getPointsToDisplay(); - for (TrkSegment ts : segments) { - int color = gpxDataItem != null ? gpxDataItem.getColor() : 0; - if (g.isShowCurrentTrack()) { - color = currentTrackColor; + try { + GpxDataItem gpxDataItem = null; + if (!g.isShowCurrentTrack()) { + gpxDataItem = getGpxDataItem(); } - if (color == 0) { - color = ts.getColor(trackColor); - } - if (ts.renderer == null && !ts.points.isEmpty()) { + List segments = g.getPointsToDisplay(); + for (TrkSegment ts : segments) { + int color = gpxDataItem != null ? gpxDataItem.getColor() : 0; if (g.isShowCurrentTrack()) { - ts.renderer = new Renderable.CurrentTrack(ts.points); - } else { - ts.renderer = new Renderable.StandardTrack(ts.points, 17.2); + color = currentTrackColor; + } + if (color == 0) { + color = ts.getColor(trackColor); + } + if (ts.renderer == null && !ts.points.isEmpty()) { + if (g.isShowCurrentTrack()) { + ts.renderer = new Renderable.CurrentTrack(ts.points); + } else { + ts.renderer = new Renderable.StandardTrack(ts.points, 17.2); + } + } + paint.setColor(color == 0 ? trackColor : color); + if (ts.renderer instanceof Renderable.RenderableSegment) { + ((Renderable.RenderableSegment) ts.renderer).drawSegment(tileBox.getZoom(), paint, canvas, tileBox); } } - paint.setColor(color == 0 ? trackColor : color); - if(ts.renderer instanceof Renderable.RenderableSegment) { - ((Renderable.RenderableSegment)ts.renderer).drawSegment(tileBox.getZoom(), paint, canvas, tileBox); - } + } catch (RejectedExecutionException e) { + // ignore } }