fix #3768 double check the item is still in the queue

This commit is contained in:
Tony Tam 2020-01-19 21:03:12 -08:00
parent e0236361a4
commit c7ec68193b

View File

@ -472,15 +472,19 @@ public class QueueFragment extends Fragment {
return super.onContextItemSelected(item);
}
int position = FeedItemUtil.indexOfItemWithId(queue, selectedItem.getId());
if (position < 0) {
Log.i(TAG, "Selected item no longer exist, ignoring selection");
return super.onContextItemSelected(item);
}
switch(item.getItemId()) {
case R.id.move_to_top_item:
int position = FeedItemUtil.indexOfItemWithId(queue, selectedItem.getId());
queue.add(0, queue.remove(position));
recyclerAdapter.notifyItemMoved(position, 0);
DBWriter.moveQueueItemToTop(selectedItem.getId(), true);
return true;
case R.id.move_to_bottom_item:
position = FeedItemUtil.indexOfItemWithId(queue, selectedItem.getId());
queue.add(queue.size()-1, queue.remove(position));
recyclerAdapter.notifyItemMoved(position, queue.size()-1);
DBWriter.moveQueueItemToBottom(selectedItem.getId(), true);