Change adding color only once

This commit is contained in:
PavelRatushny 2017-06-12 23:59:12 +03:00
parent b46f2873c6
commit 691b913e1e

View file

@ -53,7 +53,7 @@ public class TrackDetailsMenu {
private GpxDisplayItem gpxItem; private GpxDisplayItem gpxItem;
private TrackDetailsBarController toolbarController; private TrackDetailsBarController toolbarController;
private TrkSegment segment; private TrkSegment segment;
private int segmentColor; private TrackChartPoints trackChartPoints;
private static boolean VISIBLE; private static boolean VISIBLE;
@ -289,12 +289,16 @@ public class TrackDetailsMenu {
gpxItem.chartHighlightPos = highlights[0].getX(); gpxItem.chartHighlightPos = highlights[0].getX();
WptPt wpt = getPoint(chart, gpxItem.chartHighlightPos); WptPt wpt = getPoint(chart, gpxItem.chartHighlightPos);
if (wpt != null) { if (wpt != null) {
if (trackChartPoints == null) {
trackChartPoints = new TrackChartPoints();
int segmentColor = getTrackSegment(chart).getColor(0);
trackChartPoints.setSegmentColor(segmentColor);
trackChartPoints.setGpx(getGpxItem().group.getGpx());
}
location = new LatLon(wpt.lat, wpt.lon); location = new LatLon(wpt.lat, wpt.lon);
List<Pair<String, WptPt>> xAxisPoints = getXAxisPoints(chart); List<Pair<String, WptPt>> xAxisPoints = getXAxisPoints(chart);
if (segmentColor == 0) { trackChartPoints.setHighlightedPoint(location);
segmentColor = getTrackSegment(chart).getColor(0); trackChartPoints.setXAxisPoints(xAxisPoints);
}
TrackChartPoints trackChartPoints = new TrackChartPoints(xAxisPoints, location, segmentColor, getGpxItem().group.getGpx());
if (gpxItem.route) { if (gpxItem.route) {
mapActivity.getMapLayers().getMapInfoLayer().setTrackChartPoints(trackChartPoints); mapActivity.getMapLayers().getMapInfoLayer().setTrackChartPoints(trackChartPoints);
} else { } else {
@ -586,13 +590,6 @@ public class TrackDetailsMenu {
private int segmentColor; private int segmentColor;
private GPXFile gpx; private GPXFile gpx;
public TrackChartPoints(List<Pair<String, WptPt>> xAxisPoints, LatLon highlightedPoint, int segmentColor, GPXFile gpx) {
this.xAxisPoints = xAxisPoints;
this.highlightedPoint = highlightedPoint;
this.segmentColor = segmentColor;
this.gpx = gpx;
}
public List<Pair<String, WptPt>> getXAxisPoints() { public List<Pair<String, WptPt>> getXAxisPoints() {
return xAxisPoints; return xAxisPoints;
} }
@ -608,5 +605,21 @@ public class TrackDetailsMenu {
public GPXFile getGpx() { public GPXFile getGpx() {
return gpx; return gpx;
} }
public void setXAxisPoints(List<Pair<String, WptPt>> xAxisPoints) {
this.xAxisPoints = xAxisPoints;
}
public void setHighlightedPoint(LatLon highlightedPoint) {
this.highlightedPoint = highlightedPoint;
}
public void setSegmentColor(int segmentColor) {
this.segmentColor = segmentColor;
}
public void setGpx(GPXFile gpx) {
this.gpx = gpx;
}
} }
} }