Fix bug when blue location point was out of chart
This commit is contained in:
parent
94f76451b1
commit
7675977a48
3 changed files with 14 additions and 4 deletions
|
@ -2,7 +2,6 @@ package net.osmand.plus.mapcontextmenu.other;
|
|||
|
||||
import android.graphics.Matrix;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.util.Pair;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -11,6 +10,7 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.highlight.Highlight;
|
||||
|
@ -18,6 +18,7 @@ import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
|
|||
import com.github.mikephil.charting.listener.ChartTouchListener.ChartGesture;
|
||||
import com.github.mikephil.charting.listener.OnChartGestureListener;
|
||||
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
|
||||
import com.github.mikephil.charting.utils.ViewPortHandler;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.QuadRect;
|
||||
|
@ -286,8 +287,19 @@ public class TrackDetailsMenu {
|
|||
private void refreshChart(LineChart chart, boolean forceFit) {
|
||||
Highlight[] highlights = chart.getHighlighted();
|
||||
LatLon location = null;
|
||||
|
||||
ViewPortHandler handler = chart.getViewPortHandler();
|
||||
float minimumVisibleXValue = (float) chart.getValuesByTouchPoint(handler.contentLeft(), handler.contentBottom(), YAxis.AxisDependency.LEFT).x;
|
||||
float maximumVisibleXValue = (float) chart.getValuesByTouchPoint(handler.contentRight(), handler.contentBottom(), YAxis.AxisDependency.LEFT).x;
|
||||
|
||||
if (highlights != null && highlights.length > 0) {
|
||||
gpxItem.chartHighlightPos = highlights[0].getX();
|
||||
if (highlights[0].getX() < minimumVisibleXValue) {
|
||||
gpxItem.chartHighlightPos = minimumVisibleXValue;
|
||||
} else if (highlights[0].getX() > maximumVisibleXValue) {
|
||||
gpxItem.chartHighlightPos = maximumVisibleXValue;
|
||||
} else {
|
||||
gpxItem.chartHighlightPos = highlights[0].getX();
|
||||
}
|
||||
WptPt wpt = getPoint(chart, gpxItem.chartHighlightPos);
|
||||
if (wpt != null) {
|
||||
if (trackChartPoints == null) {
|
||||
|
|
|
@ -17,7 +17,6 @@ import android.support.annotation.ColorInt;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.util.Pair;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
|
|
|
@ -32,7 +32,6 @@ import android.graphics.Path;
|
|||
import android.graphics.PointF;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.support.v4.util.Pair;
|
||||
|
||||
public class RouteLayer extends OsmandMapLayer {
|
||||
|
||||
|
|
Loading…
Reference in a new issue