mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-01-31 10:54:50 +01:00
Merge pull request #5453 from ByteHamster/harder-drag
Make it harder to accidentally drag episodes in the queue
This commit is contained in:
commit
c52cf51857
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user