diff options
author | ByteHamster <info@bytehamster.com> | 2021-10-05 21:48:49 +0200 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2021-10-05 21:55:38 +0200 |
commit | da07d5dad323cc2341b2b81895c590b4ffea22c2 (patch) | |
tree | 7e9c65d13f01b0b84c2d040f61724e7d2af4f115 /app/src | |
parent | 160401ad13778e9f611fde864910e55339a3f921 (diff) | |
download | AntennaPod-da07d5dad323cc2341b2b81895c590b4ffea22c2.zip |
Make it harder to accidentally drag episodes in the queue
Only the drag handle and the first half of the cover can be dragged,
before it was the whole cover.
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/adapter/QueueRecyclerAdapter.java | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/QueueRecyclerAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/QueueRecyclerAdapter.java index 6055582a3..383d670f1 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/QueueRecyclerAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/QueueRecyclerAdapter.java @@ -7,6 +7,7 @@ import android.view.MenuInflater; import android.view.MotionEvent; import android.view.View; +import androidx.core.view.ViewCompat; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.core.preferences.UserPreferences; @@ -37,22 +38,32 @@ public class QueueRecyclerAdapter extends EpisodeItemListAdapter { @Override @SuppressLint("ClickableViewAccessibility") protected void afterBindViewHolder(EpisodeItemViewHolder holder, int pos) { - View.OnTouchListener startDragTouchListener = (v1, event) -> { - if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { - Log.d(TAG, "startDrag()"); - swipeActions.startDrag(holder); - } - return false; - }; - if (!dragDropEnabled || inActionMode()) { holder.dragHandle.setVisibility(View.GONE); holder.dragHandle.setOnTouchListener(null); holder.coverHolder.setOnTouchListener(null); } else { holder.dragHandle.setVisibility(View.VISIBLE); - holder.dragHandle.setOnTouchListener(startDragTouchListener); - holder.coverHolder.setOnTouchListener(startDragTouchListener); + holder.dragHandle.setOnTouchListener((v1, event) -> { + if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { + Log.d(TAG, "startDrag()"); + swipeActions.startDrag(holder); + } + return false; + }); + holder.coverHolder.setOnTouchListener((v1, event) -> { + if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { + boolean isLtr = ViewCompat.getLayoutDirection(holder.itemView) == ViewCompat.LAYOUT_DIRECTION_LTR; + float factor = isLtr ? 1 : -1; + if (factor * event.getX() < factor * 0.5 * v1.getWidth()) { + Log.d(TAG, "startDrag()"); + swipeActions.startDrag(holder); + } else { + Log.d(TAG, "Ignoring drag in right half of the image"); + } + } + return false; + }); } holder.isInQueue.setVisibility(View.GONE); |