Search in sources :

Example 1 with EpisodeItemViewHolder

use of de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder in project AntennaPod by AntennaPod.

the class NewEpisodesFragment method onCreateView.

@NonNull
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = super.onCreateView(inflater, container, savedInstanceState);
    emptyView.setTitle(R.string.no_new_episodes_head_label);
    emptyView.setMessage(R.string.no_new_episodes_label);
    ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.RIGHT) {

        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
            return false;
        }

        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {
            EpisodeItemViewHolder holder = (EpisodeItemViewHolder) viewHolder;
            FeedItemMenuHandler.removeNewFlagWithUndo(NewEpisodesFragment.this, holder.getFeedItem());
        }
    };
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
    itemTouchHelper.attachToRecyclerView(recyclerView);
    return root;
}
Also used : ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) EpisodeItemViewHolder(de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder) EpisodeItemViewHolder(de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder) RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) NonNull(androidx.annotation.NonNull)

Example 2 with EpisodeItemViewHolder

use of de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder in project AntennaPod by AntennaPod.

the class FavoriteEpisodesFragment method onCreateView.

@NonNull
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = super.onCreateView(inflater, container, savedInstanceState);
    emptyView.setIcon(R.drawable.ic_star);
    emptyView.setTitle(R.string.no_fav_episodes_head_label);
    emptyView.setMessage(R.string.no_fav_episodes_label);
    ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) {

        @Override
        public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
            return false;
        }

        @Override
        public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int swipeDir) {
            EpisodeItemViewHolder holder = (EpisodeItemViewHolder) viewHolder;
            Log.d(TAG, String.format("remove(%s)", holder.getFeedItem().getId()));
            if (disposable != null) {
                disposable.dispose();
            }
            FeedItem item = holder.getFeedItem();
            if (item != null) {
                DBWriter.removeFavoriteItem(item);
                ((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.removed_item, Snackbar.LENGTH_LONG).setAction(getString(R.string.undo), v -> DBWriter.addFavoriteItem(item));
            }
        }
    };
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
    itemTouchHelper.attachToRecyclerView(recyclerView);
    return root;
}
Also used : ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) EpisodeItemViewHolder(de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder) EpisodeItemViewHolder(de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder) FeedItem(de.danoeh.antennapod.model.feed.FeedItem) NonNull(androidx.annotation.NonNull) RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) NonNull(androidx.annotation.NonNull)

Example 3 with EpisodeItemViewHolder

use of de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder in project AntennaPod by AntennaPod.

the class SwipeActions method onSwiped.

@Override
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int swipeDir) {
    if (!actions.hasActions()) {
        // open settings dialog if no prefs are set
        new SwipeActionsDialog(fragment.requireContext(), tag).show(this::reloadPreference);
        return;
    }
    FeedItem item = ((EpisodeItemViewHolder) viewHolder).getFeedItem();
    (swipeDir == ItemTouchHelper.RIGHT ? actions.right : actions.left).performAction(item, fragment, filter);
}
Also used : EpisodeItemViewHolder(de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder) FeedItem(de.danoeh.antennapod.model.feed.FeedItem) SwipeActionsDialog(de.danoeh.antennapod.dialog.SwipeActionsDialog)

Aggregations

EpisodeItemViewHolder (de.danoeh.antennapod.view.viewholder.EpisodeItemViewHolder)3 View (android.view.View)2 NonNull (androidx.annotation.NonNull)2 ItemTouchHelper (androidx.recyclerview.widget.ItemTouchHelper)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 FeedItem (de.danoeh.antennapod.model.feed.FeedItem)2 SwipeActionsDialog (de.danoeh.antennapod.dialog.SwipeActionsDialog)1