diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesRecycleAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesRecycleAdapter.java index 1fa4b7c48..d749b0313 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesRecycleAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesRecycleAdapter.java @@ -35,6 +35,7 @@ import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.util.Converter; import de.danoeh.antennapod.core.util.DateUtils; +import de.danoeh.antennapod.core.util.LongList; import de.danoeh.antennapod.core.util.NetworkUtils; import de.danoeh.antennapod.fragment.ItemFragment; import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler; @@ -328,8 +329,8 @@ public class AllEpisodesRecycleAdapter extends RecyclerView.Adapter downloaderList; @@ -249,10 +250,10 @@ public class ItemFragment extends Fragment { inflater.inflate(R.menu.feeditem_options, menu); popupMenu = menu; if (item.hasMedia()) { - FeedItemMenuHandler.onPrepareMenu(getActivity(), popupMenuInterface, item, true, queue); + FeedItemMenuHandler.onPrepareMenu(popupMenuInterface, item, true, queue, favorites); } else { // these are already available via button1 and button2 - FeedItemMenuHandler.onPrepareMenu(getActivity(), popupMenuInterface, item, true, queue, + FeedItemMenuHandler.onPrepareMenu(popupMenuInterface, item, true, queue, favorites, R.id.mark_read_item, R.id.visit_website_item); } } @@ -457,6 +458,12 @@ public class ItemFragment extends Fragment { } } + public void onEventMainThread(FavoritesEvent event) { + if(event.item.getId() == itemID) { + load(); + } + } + public void onEventMainThread(FeedItemEvent event) { Log.d(TAG, "onEventMainThread() called with: " + "event = [" + event + "]"); for(FeedItem item : event.items) { @@ -500,8 +507,9 @@ public class ItemFragment extends Fragment { .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(result -> { - item = result.first; - queue = result.second; + item = (FeedItem) result[0]; + queue = (LongList) result[1]; + favorites = (LongList) result[2]; if (!itemsLoaded) { itemsLoaded = true; onFragmentLoaded(); @@ -513,14 +521,25 @@ public class ItemFragment extends Fragment { }); } - private Pair loadInBackground() { - FeedItem data1 = DBReader.getFeedItem(itemID); - if (data1 != null) { - Timeline t = new Timeline(getActivity(), data1); + private Object[] loadInBackground() { + FeedItem feedItem = DBReader.getFeedItem(itemID); + if (feedItem != null) { + Timeline t = new Timeline(getActivity(), feedItem); webviewData = t.processShownotes(false); } - LongList data2 = DBReader.getQueueIDList(); - return Pair.create(data1, data2); + LongList queue; + if(feedItem.isTagged(FeedItem.TAG_QUEUE)) { + queue = LongList.of(feedItem.getId()); + } else { + queue = new LongList(0); + } + LongList favorites; + if(feedItem.isTagged(FeedItem.TAG_FAVORITE)) { + favorites = LongList.of(feedItem.getId()); + } else { + favorites = new LongList(0); + } + return new Object[] { feedItem, queue, favorites }; } } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java index 43f22a587..b3f6c3534 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java @@ -568,6 +568,20 @@ public class QueueFragment extends Fragment { public LongList getQueueIds() { return queue != null ? LongList.of(FeedItemUtil.getIds(queue)) : new LongList(0); } + + @Override + public LongList getFavoritesIds() { + LongList favoritesIds = new LongList(); + if(queue == null) { + return favoritesIds; + } + for(FeedItem item : queue) { + if(item.isTagged(FeedItem.TAG_FAVORITE)) { + favoritesIds.add(item.getId()); + } + } + return favoritesIds; + } }; private EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() { diff --git a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java index 55f522dfe..58fe8afbf 100644 --- a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java @@ -140,9 +140,13 @@ public class FeedItemMenuHandler { * @param excludeIds Menu item that should be excluded * @return true if selectedItem is not null. */ - public static boolean onPrepareMenu(Context context, MenuInterface mi, FeedItem selectedItem, - boolean showExtendedMenu, LongList queueAccess, int... excludeIds) { - boolean rc = onPrepareMenu(context, mi, selectedItem, showExtendedMenu, queueAccess); + public static boolean onPrepareMenu(MenuInterface mi, + FeedItem selectedItem, + boolean showExtendedMenu, + LongList queueAccess, + LongList favorites, + int... excludeIds) { + boolean rc = onPrepareMenu(mi, selectedItem, showExtendedMenu, queueAccess, favorites); if (rc && excludeIds != null) { for (int id : excludeIds) { mi.setItemVisibility(id, false);