Save position before refreshing, handle top/bottom moving and notify adapter
This commit is contained in:
parent
f12362c776
commit
58813db553
|
@ -162,8 +162,9 @@ public class QueueFragment extends Fragment {
|
||||||
recyclerAdapter.notifyDataSetChanged();
|
recyclerAdapter.notifyDataSetChanged();
|
||||||
break;
|
break;
|
||||||
case MOVED:
|
case MOVED:
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
|
saveScrollPosition();
|
||||||
onFragmentLoaded();
|
onFragmentLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,9 +326,15 @@ public class QueueFragment extends Fragment {
|
||||||
|
|
||||||
switch(item.getItemId()) {
|
switch(item.getItemId()) {
|
||||||
case R.id.move_to_top_item:
|
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);
|
DBWriter.moveQueueItemToTop(selectedItem.getId(), true);
|
||||||
return true;
|
return true;
|
||||||
case R.id.move_to_bottom_item:
|
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);
|
DBWriter.moveQueueItemToBottom(selectedItem.getId(), true);
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue