From cda30a29571108e4e168bf21adab96f697744da1 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Mon, 7 Aug 2017 13:05:11 +0300 Subject: [PATCH] Add the ability to delete points from the list; add small changes --- .../MeasurementToolAdapter.java | 17 ++++++++--- .../MeasurementToolFragment.java | 29 +++++++++++++++++-- .../measurementtool/MeasurementToolLayer.java | 10 +++++-- 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolAdapter.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolAdapter.java index 8d4d1817bf..8304957b3b 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolAdapter.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolAdapter.java @@ -7,7 +7,6 @@ import android.view.ViewGroup; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; -import android.widget.Toast; import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.IconsCache; @@ -22,12 +21,17 @@ class MeasurementToolAdapter extends RecyclerView.Adapter points; + private RemovePointListener listener; - public MeasurementToolAdapter(MapActivity mapActivity, List points) { + MeasurementToolAdapter(MapActivity mapActivity, List points) { this.mapActivity = mapActivity; this.points = points; } + public void setListener(RemovePointListener listener) { + this.listener = listener; + } + @Override public Holder onCreateViewHolder(ViewGroup viewGroup, int i) { View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.measure_points_list_item, viewGroup, false); @@ -53,7 +57,8 @@ class MeasurementToolAdapter extends RecyclerView.Adapter getMeasurementPoints() { + LinkedList getMeasurementPoints() { return measurementPoints; } @@ -141,6 +141,10 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL canvas.rotate(tb.getRotate(), center.x, center.y); } + void resetCachePoints() { + cacheMeasurementPoints = new LinkedList<>(measurementPoints); + } + void addPointOnClick() { RotatedTileBox tb = view.getCurrentRotatedTileBox(); LatLon l = tb.getLatLonFromPixel(tb.getCenterPixelX(), tb.getCenterPixelY()); @@ -154,7 +158,7 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL } else { measurementPoints.add(pt); } - cacheMeasurementPoints = new LinkedList<>(measurementPoints); + resetCachePoints(); view.refreshMap(); }