Fix reordering bug
This commit is contained in:
parent
6714afb316
commit
bad41b8c66
2 changed files with 2 additions and 9 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
measurementLayer.refreshMap();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue