Allow to drag images like before

This commit is contained in:
ByteHamster 2020-02-05 17:00:54 +01:00
parent d74b8d06b2
commit 164581c598
3 changed files with 22 additions and 12 deletions

View File

@ -1,5 +1,6 @@
package de.danoeh.antennapod.adapter;
import android.annotation.SuppressLint;
import android.util.Log;
import android.view.ContextMenu;
import android.view.MenuInflater;
@ -54,19 +55,12 @@ public class QueueRecyclerAdapter extends RecyclerView.Adapter<EpisodeItemViewHo
@NonNull
@Override
public EpisodeItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
EpisodeItemViewHolder viewHolder = new EpisodeItemViewHolder(mainActivity.get(), parent);
viewHolder.dragHandle.setOnTouchListener((v1, event) -> {
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
Log.d(TAG, "startDrag()");
itemTouchHelper.startDrag(viewHolder);
}
return false;
});
return viewHolder;
public EpisodeItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new EpisodeItemViewHolder(mainActivity.get(), parent);
}
@Override
@SuppressLint("ClickableViewAccessibility")
public void onBindViewHolder(EpisodeItemViewHolder holder, int pos) {
FeedItem item = itemAccess.getItem(pos);
holder.bind(item);
@ -83,6 +77,22 @@ public class QueueRecyclerAdapter extends RecyclerView.Adapter<EpisodeItemViewHo
activity.loadChildFragment(ItemPagerFragment.newInstance(ids, position));
}
});
View.OnTouchListener startDragTouchListener = (v1, event) -> {
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
Log.d(TAG, "startDrag()");
itemTouchHelper.startDrag(holder);
}
return false;
};
if (!locked) {
holder.dragHandle.setOnTouchListener(startDragTouchListener);
holder.coverHolder.setOnTouchListener(startDragTouchListener);
} else {
holder.dragHandle.setOnTouchListener(null);
holder.coverHolder.setOnTouchListener(null);
}
holder.itemView.setOnCreateContextMenuListener(this);
holder.isInQueue.setVisibility(View.GONE);
holder.hideSeparatorIfNecessary();

View File

@ -110,7 +110,7 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder
isInQueue.setVisibility(item.isTagged(FeedItem.TAG_QUEUE) ? View.VISIBLE : View.GONE);
itemView.setAlpha(item.isPlayed() /*&& makePlayedItemsTransparent*/ ? 0.5f : 1.0f);
ItemActionButton actionButton = ItemActionButton.forItem(item, true);
ItemActionButton actionButton = ItemActionButton.forItem(item, true, true);
actionButton.configure(secondaryActionButton, secondaryActionIcon, activity);
secondaryActionButton.setFocusable(false);

View File

@ -100,7 +100,7 @@
android:layout_width="20dp"
android:layout_height="20dp"
app:srcCompat="?attr/stat_playlist"
tools:srcCompat="@drawable/ic_playlist_grey_24dp"
tools:srcCompat="@drawable/ic_list_grey600_24dp"
android:id="@+id/ivInPlaylist"/>
<TextView