content: package de.danoeh.antennapod.ui.swipeactions;
  
  import android.content.Context;
  
  import androidx.fragment.app.Fragment;
  
  import de.danoeh.antennapod.R;
  import de.danoeh.antennapod.event.MessageEvent;
  import de.danoeh.antennapod.storage.database.DBWriter;
  import de.danoeh.antennapod.model.feed.FeedItem;
  import de.danoeh.antennapod.model.feed.FeedItemFilter;
  import org.greenrobot.eventbus.EventBus;
  
  public class AddToQueueSwipeAction implements SwipeAction {
  
      @Override
      public String getId() {
          return ADD_TO_QUEUE;
      }
  
      @Override
      public int getActionIcon() {
          return R.drawable.ic_playlist_play;
      }
  
      @Override
      public int getActionColor() {
          return R.attr.colorAccent;
      }
  
      @Override
      public String getTitle(Context context) {
          return context.getString(R.string.add_to_queue_label);
      }
  
      @Override
      public void performAction(FeedItem item, Fragment fragment, FeedItemFilter filter) {
          if (item.isTagged(FeedItem.TAG_QUEUE)) {
              new RemoveFromQueueSwipeAction().performAction(item, fragment, filter);
          } else if (item.getMedia() == null) {
              EventBus.getDefault().post(new MessageEvent(fragment.getString(R.string.no_media_label)));
          } else {
              DBWriter.addQueueItem(fragment.requireContext(), item);
          }
      }
  
      @Override
      public boolean willRemove(FeedItemFilter filter, FeedItem item) {
          if (item.getMedia() == null) {
              return false;
          }
          return filter.showNotQueued || filter.showNew;
      }
  }
  