Save position before refreshing, handle top/bottom moving and notify adapter

This commit is contained in:
Martin Fietz 2015-11-23 23:31:38 +01:00
parent f12362c776
commit 58813db553
1 changed files with 8 additions and 1 deletions

View File

@ -162,8 +162,9 @@ public class QueueFragment extends Fragment {
recyclerAdapter.notifyDataSetChanged();
break;
case MOVED:
break;
return;
}
saveScrollPosition();
onFragmentLoaded();
}
@ -325,9 +326,15 @@ public class QueueFragment extends Fragment {
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);
return true;
default: