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;
}
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;
}
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);
}
Aggregations