Merge branch 'sasha_pasha_branch' of ssh://github.com/osmandapp/Osmand into sasha_pasha_branch

This commit is contained in:
PavelRatushny 2017-08-11 18:09:08 +03:00
commit 2796cb25ee
2 changed files with 2 additions and 9 deletions

View file

@ -338,7 +338,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);

View file

@ -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();
}
}