diff options
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/adapter')
-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); |