Merge pull request #1410 from mfietz/issue/1409-drag-glitch
Queue: Restore scroll position, don't glitch
This commit is contained in:
commit
3fa38f8b1b
|
@ -162,16 +162,9 @@ public class QueueFragment extends Fragment {
|
||||||
recyclerAdapter.notifyDataSetChanged();
|
recyclerAdapter.notifyDataSetChanged();
|
||||||
break;
|
break;
|
||||||
case MOVED:
|
case MOVED:
|
||||||
int from = FeedItemUtil.indexOfItemWithId(queue, event.item.getId());
|
return;
|
||||||
int to = event.position;
|
|
||||||
if(from != to) {
|
|
||||||
queue.add(to, queue.remove(from));
|
|
||||||
recyclerAdapter.notifyItemMoved(from, to);
|
|
||||||
} else {
|
|
||||||
// QueueFragment itself sent the event and already moved the item
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
saveScrollPosition();
|
||||||
onFragmentLoaded();
|
onFragmentLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,11 +204,6 @@ public class QueueFragment extends Fragment {
|
||||||
float offset = prefs.getFloat(PREF_SCROLL_OFFSET, 0.0f);
|
float offset = prefs.getFloat(PREF_SCROLL_OFFSET, 0.0f);
|
||||||
if (position > 0 || offset > 0) {
|
if (position > 0 || offset > 0) {
|
||||||
layoutManager.scrollToPositionWithOffset(position, (int) offset);
|
layoutManager.scrollToPositionWithOffset(position, (int) offset);
|
||||||
// restore once, then forget
|
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
|
||||||
editor.putInt(PREF_SCROLL_POSITION, 0);
|
|
||||||
editor.putFloat(PREF_SCROLL_OFFSET, 0.0f);
|
|
||||||
editor.commit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,12 +324,27 @@ public class QueueFragment extends Fragment {
|
||||||
return super.onContextItemSelected(item);
|
return super.onContextItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
switch(item.getItemId()) {
|
||||||
return FeedItemMenuHandler.onMenuItemClicked(getActivity(), item.getItemId(), selectedItem);
|
case R.id.move_to_top_item:
|
||||||
} catch (DownloadRequestException e) {
|
int position = FeedItemUtil.indexOfItemWithId(queue, selectedItem.getId());
|
||||||
e.printStackTrace();
|
queue.add(0, queue.remove(position));
|
||||||
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show();
|
recyclerAdapter.notifyItemMoved(position, 0);
|
||||||
return true;
|
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:
|
||||||
|
try {
|
||||||
|
return FeedItemMenuHandler.onMenuItemClicked(getActivity(), item.getItemId(), selectedItem);
|
||||||
|
} catch (DownloadRequestException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,11 +186,6 @@ public class FeedItemMenuHandler {
|
||||||
GpodnetPreferences.enqueueEpisodeAction(actionNew);
|
GpodnetPreferences.enqueueEpisodeAction(actionNew);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.move_to_top_item:
|
|
||||||
DBWriter.moveQueueItemToTop(selectedItem.getId(), true);
|
|
||||||
return true;
|
|
||||||
case R.id.move_to_bottom_item:
|
|
||||||
DBWriter.moveQueueItemToBottom(selectedItem.getId(), true);
|
|
||||||
case R.id.add_to_queue_item:
|
case R.id.add_to_queue_item:
|
||||||
DBWriter.addQueueItem(context, selectedItem);
|
DBWriter.addQueueItem(context, selectedItem);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue