Fix index out of bounds exception

This commit is contained in:
Alexander Sytnyk 2017-10-20 16:58:03 +03:00
parent 9d5dbe4d04
commit 50bbd2005a

View file

@ -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