From bad41b8c6688fe9a754fc488be8d6be220317b41 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 11 Aug 2017 18:07:50 +0300 Subject: [PATCH] Fix reordering bug --- .../plus/measurementtool/MeasurementToolFragment.java | 2 +- .../measurementtool/command/ReorderPointCommand.java | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index f7d68147a6..356c0254b1 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -334,7 +334,7 @@ public class MeasurementToolFragment extends Fragment { @Override public void onDragEnded(RecyclerView.ViewHolder holder) { toPosition = holder.getAdapterPosition(); - if (toPosition != fromPosition) { + if (toPosition >= 0 && fromPosition >= 0 && toPosition != fromPosition) { commandManager.execute(new ReorderPointCommand(measurementLayer, fromPosition, toPosition)); adapter.notifyDataSetChanged(); disable(redoBtn); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/command/ReorderPointCommand.java b/OsmAnd/src/net/osmand/plus/measurementtool/command/ReorderPointCommand.java index 1189676555..0e41a22d34 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/command/ReorderPointCommand.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/command/ReorderPointCommand.java @@ -32,14 +32,7 @@ public class ReorderPointCommand implements Command { } private void swap() { - // todo: fix exception - try { - Collections.swap(measurementLayer.getMeasurementPoints(), from, to); - } catch (Exception e) { - // index out of bounds - // an exception occurs when to == -1 basically - // but maybe from == measurementPoints.size() sometimes so there is an exception - } + Collections.swap(measurementLayer.getMeasurementPoints(), from, to); measurementLayer.refreshMap(); } }