From c69b224c65a7960c640b80ad98792ef8f85b4a0a Mon Sep 17 00:00:00 2001 From: Akash Agarwal Date: Sat, 1 Dec 2018 00:35:27 +0530 Subject: [PATCH] Issue 1505: Delete on right swipe --- .../org/schabi/newpipe/player/MainVideoPlayer.java | 5 +++++ .../schabi/newpipe/player/ServicePlayerActivity.java | 5 +++++ .../player/playqueue/PlayQueueItemTouchCallback.java | 10 +++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java index 07a9ac71c..f4fea5165 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java @@ -900,6 +900,11 @@ public final class MainVideoPlayer extends AppCompatActivity public void onMove(int sourceIndex, int targetIndex) { if (playQueue != null) playQueue.move(sourceIndex, targetIndex); } + + @Override + public void onSwiped(int index) { + if(index != -1) playQueue.remove(index); + } }; } diff --git a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java index 94305e6c4..2ec4275fc 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java @@ -375,6 +375,11 @@ public abstract class ServicePlayerActivity extends AppCompatActivity public void onMove(int sourceIndex, int targetIndex) { if (player != null) player.getPlayQueue().move(sourceIndex, targetIndex); } + + @Override + public void onSwiped(int index) { + if (index != -1) player.getPlayQueue().remove(index); + } }; } diff --git a/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueItemTouchCallback.java b/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueItemTouchCallback.java index 6edeff670..26be83b98 100644 --- a/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueItemTouchCallback.java +++ b/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueItemTouchCallback.java @@ -8,11 +8,13 @@ public abstract class PlayQueueItemTouchCallback extends ItemTouchHelper.SimpleC private static final int MAXIMUM_INITIAL_DRAG_VELOCITY = 25; public PlayQueueItemTouchCallback() { - super(ItemTouchHelper.UP | ItemTouchHelper.DOWN, 0); + super(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.RIGHT); } public abstract void onMove(final int sourceIndex, final int targetIndex); + public abstract void onSwiped(int index); + @Override public int interpolateOutOfBoundsScroll(RecyclerView recyclerView, int viewSize, int viewSizeOutOfBounds, int totalSize, @@ -44,9 +46,11 @@ public abstract class PlayQueueItemTouchCallback extends ItemTouchHelper.SimpleC @Override public boolean isItemViewSwipeEnabled() { - return false; + return true; } @Override - public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {} + public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) { + onSwiped(viewHolder.getAdapterPosition()); + } }