From 3730a000df735667eaa5be9dfd1edf15e0a3c9d7 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Thu, 16 Mar 2017 12:43:46 +0300 Subject: [PATCH] Hold marker while moving chart --- .../plus/myplaces/TrackSegmentFragment.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java index e2aae9594c..9aed3bb225 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java @@ -1000,8 +1000,16 @@ public class TrackSegmentFragment extends OsmAndListFragment { }); final View finalView = view; chart.setOnChartGestureListener(new OnChartGestureListener() { + + float highlightDrawX = -1; + @Override public void onChartGestureStart(MotionEvent me, ChartGesture lastPerformedGesture) { + if (chart.getHighlighted() != null && chart.getHighlighted().length > 0) { + highlightDrawX = chart.getHighlighted()[0].getDrawX(); + } else { + highlightDrawX = -1; + } } @Override @@ -1043,6 +1051,18 @@ public class TrackSegmentFragment extends OsmAndListFragment { @Override public void onChartTranslate(MotionEvent me, float dX, float dY) { + if (highlightDrawX != -1) { + Highlight h = chart.getHighlightByTouchPoint(highlightDrawX, 0f); + if (h != null) { + chart.highlightValue(h); + WptPt wpt = getPoint(chart, h.getX()); + if (wpt != null) { + selectedPointLatLon = new LatLon(wpt.lat, wpt.lon); + Bitmap bmp = drawSelectedPoint(); + imageView.setImageDrawable(new BitmapDrawable(app.getResources(), bmp)); + } + } + } } });