Merge pull request #4501 from osmandapp/gpx_current_track

Fix #4328
This commit is contained in:
vshcherb 2017-10-01 23:35:44 +02:00 committed by GitHub
commit 87e1942ed4

View file

@ -465,31 +465,44 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
private void drawSelectedFilesSegments(Canvas canvas, RotatedTileBox tileBox, private void drawSelectedFilesSegments(Canvas canvas, RotatedTileBox tileBox,
List<SelectedGpxFile> selectedGPXFiles, DrawSettings settings) { List<SelectedGpxFile> selectedGPXFiles, DrawSettings settings) {
SelectedGpxFile currentTrack = null;
for (SelectedGpxFile g : selectedGPXFiles) { for (SelectedGpxFile g : selectedGPXFiles) {
GpxDataItem gpxDataItem = null; if (g.isShowCurrentTrack()) {
if (!g.isShowCurrentTrack()) { currentTrack = g;
gpxDataItem = view.getApplication().getGpxDatabase().getItem(new File(g.getGpxFile().path)); } else {
drawSelectedFileSegments(g, false, canvas, tileBox, settings);
} }
List<TrkSegment> segments = g.getPointsToDisplay(); }
for (TrkSegment ts : segments) { if (currentTrack != null) {
int color = gpxDataItem != null ? gpxDataItem.getColor() : 0; drawSelectedFileSegments(currentTrack, true, canvas, tileBox, settings);
if (g.isShowCurrentTrack()) { }
color = currentTrackColor; }
}
if (color == 0) { private void drawSelectedFileSegments(SelectedGpxFile selectedGpxFile, boolean currentTrack, Canvas canvas,
color = ts.getColor(cachedColor); RotatedTileBox tileBox, DrawSettings settings) {
} GpxDataItem gpxDataItem = null;
if (ts.renders.isEmpty() // only do once (CODE HERE NEEDS TO BE UI INSTEAD) if (!currentTrack) {
&& !ts.points.isEmpty()) { // hmmm. 0-point tracks happen, but.... how? gpxDataItem = view.getApplication().getGpxDatabase().getItem(new File(selectedGpxFile.getGpxFile().path));
if (g.isShowCurrentTrack()) { }
ts.renders.add(new Renderable.CurrentTrack(ts.points)); List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
} else { for (TrkSegment ts : segments) {
ts.renders.add(new Renderable.StandardTrack(ts.points, 17.2)); int color = gpxDataItem != null ? gpxDataItem.getColor() : 0;
} if (currentTrack) {
} color = currentTrackColor;
updatePaints(color, g.isRoutePoints(), g.isShowCurrentTrack(), settings, tileBox);
ts.drawRenderers(view.getZoom(), paint, canvas, tileBox);
} }
if (color == 0) {
color = ts.getColor(cachedColor);
}
if (ts.renders.isEmpty() // only do once (CODE HERE NEEDS TO BE UI INSTEAD)
&& !ts.points.isEmpty()) { // hmmm. 0-point tracks happen, but.... how?
if (currentTrack) {
ts.renders.add(new Renderable.CurrentTrack(ts.points));
} else {
ts.renders.add(new Renderable.StandardTrack(ts.points, 17.2));
}
}
updatePaints(color, selectedGpxFile.isRoutePoints(), currentTrack, settings, tileBox);
ts.drawRenderers(view.getZoom(), paint, canvas, tileBox);
} }
} }