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
|
@Override
|
||||||
public void onDragEnded(RecyclerView.ViewHolder holder) {
|
public void onDragEnded(RecyclerView.ViewHolder holder) {
|
||||||
toPosition = holder.getAdapterPosition();
|
toPosition = holder.getAdapterPosition();
|
||||||
if (toPosition != fromPosition) {
|
if (toPosition >= 0 && fromPosition >= 0 && toPosition != fromPosition) {
|
||||||
commandManager.execute(new ReorderPointCommand(measurementLayer, fromPosition, toPosition));
|
commandManager.execute(new ReorderPointCommand(measurementLayer, fromPosition, toPosition));
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
disable(redoBtn);
|
disable(redoBtn);
|
||||||
|
|
|
@ -32,14 +32,7 @@ public class ReorderPointCommand implements Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void swap() {
|
private void swap() {
|
||||||
// todo: fix exception
|
Collections.swap(measurementLayer.getMeasurementPoints(), from, to);
|
||||||
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();
|
measurementLayer.refreshMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue