Fix bug when blue location point was out of chart

This commit is contained in:
PavelRatushny 2017-06-16 13:22:04 +03:00
parent 94f76451b1
commit 7675977a48
3 changed files with 14 additions and 4 deletions

View file

@ -2,7 +2,6 @@ package net.osmand.plus.mapcontextmenu.other;
import android.graphics.Matrix; import android.graphics.Matrix;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.util.Pair;
import android.support.v7.widget.PopupMenu; import android.support.v7.widget.PopupMenu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.MotionEvent; import android.view.MotionEvent;
@ -11,6 +10,7 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.github.mikephil.charting.charts.LineChart; 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.Entry;
import com.github.mikephil.charting.data.LineData; import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.highlight.Highlight; 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.ChartTouchListener.ChartGesture;
import com.github.mikephil.charting.listener.OnChartGestureListener; import com.github.mikephil.charting.listener.OnChartGestureListener;
import com.github.mikephil.charting.listener.OnChartValueSelectedListener; import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
import com.github.mikephil.charting.utils.ViewPortHandler;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.QuadRect; import net.osmand.data.QuadRect;
@ -286,8 +287,19 @@ public class TrackDetailsMenu {
private void refreshChart(LineChart chart, boolean forceFit) { private void refreshChart(LineChart chart, boolean forceFit) {
Highlight[] highlights = chart.getHighlighted(); Highlight[] highlights = chart.getHighlighted();
LatLon location = null; 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) { if (highlights != null && highlights.length > 0) {
if (highlights[0].getX() < minimumVisibleXValue) {
gpxItem.chartHighlightPos = minimumVisibleXValue;
} else if (highlights[0].getX() > maximumVisibleXValue) {
gpxItem.chartHighlightPos = maximumVisibleXValue;
} else {
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) { if (trackChartPoints == null) {

View file

@ -17,7 +17,6 @@ import android.support.annotation.ColorInt;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v4.util.Pair;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;

View file

@ -32,7 +32,6 @@ import android.graphics.Path;
import android.graphics.PointF; import android.graphics.PointF;
import android.graphics.PorterDuff.Mode; import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter; import android.graphics.PorterDuffColorFilter;
import android.support.v4.util.Pair;
public class RouteLayer extends OsmandMapLayer { public class RouteLayer extends OsmandMapLayer {