From 50bbd2005a7c8e32386c5fa8a47656e41499a4ac Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Fri, 20 Oct 2017 16:58:03 +0300 Subject: [PATCH] Fix index out of bounds exception --- .../adapters/MapMarkersItemTouchHelperCallback.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersItemTouchHelperCallback.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersItemTouchHelperCallback.java index 32f08e9e0d..8a4d1c0285 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersItemTouchHelperCallback.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersItemTouchHelperCallback.java @@ -88,7 +88,12 @@ public class MapMarkersItemTouchHelperCallback extends ItemTouchHelper.Callback @Override public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder source, RecyclerView.ViewHolder target) { - return adapter.onItemMove(source.getAdapterPosition(), target.getAdapterPosition()); + int from = source.getAdapterPosition(); + int to = target.getAdapterPosition(); + if (from == RecyclerView.NO_POSITION || to == RecyclerView.NO_POSITION) { + return false; + } + return adapter.onItemMove(from, to); } @Override