Prevent ArrayIndexOutOfBoundsException

This commit is contained in:
Martin Fietz 2017-10-19 21:53:21 +02:00
parent 3a150ac428
commit a98ed53625
1 changed files with 3 additions and 0 deletions

View File

@ -400,6 +400,9 @@ public class QueueFragment extends Fragment {
int from = viewHolder.getAdapterPosition(); int from = viewHolder.getAdapterPosition();
int to = target.getAdapterPosition(); int to = target.getAdapterPosition();
Log.d(TAG, "move(" + from + ", " + to + ")"); Log.d(TAG, "move(" + from + ", " + to + ")");
if(from >= queue.size() || to >= queue.size()) {
return false;
}
queue.add(to, queue.remove(from)); queue.add(to, queue.remove(from));
recyclerAdapter.notifyItemMoved(from, to); recyclerAdapter.notifyItemMoved(from, to);
DBWriter.moveQueueItem(from, to, true); DBWriter.moveQueueItem(from, to, true);