Fixed 2 little bugs related to queue movement

- moving while downloading sometimes caused ArrayIndexOutOfBoundsException
- Long-pressing and then swiping out leaves the screen empty and the
context menu open. Pressing items crashed the app.
This commit is contained in:
ByteHamster 2021-03-06 21:50:34 +01:00
parent f9baf6812b
commit 0d21dbed4c
1 changed files with 2 additions and 2 deletions

View File

@ -385,7 +385,7 @@ public class QueueFragment extends Fragment implements Toolbar.OnMenuItemClickLi
@Override
public boolean onContextItemSelected(MenuItem item) {
Log.d(TAG, "onContextItemSelected() called with: " + "item = [" + item + "]");
if(!isVisible()) {
if (!isVisible() || recyclerAdapter == null) {
return false;
}
FeedItem selectedItem = recyclerAdapter.getSelectedItem();
@ -464,7 +464,7 @@ public class QueueFragment extends Fragment implements Toolbar.OnMenuItemClickLi
int from = viewHolder.getAdapterPosition();
int to = target.getAdapterPosition();
Log.d(TAG, "move(" + from + ", " + to + ") in memory");
if (from >= queue.size() || to >= queue.size()) {
if (from >= queue.size() || to >= queue.size() || from < 0 || to < 0) {
return false;
}
queue.add(to, queue.remove(from));