diff options
author | Tony Tam <149837+tonytamsf@users.noreply.github.com> | 2023-11-17 13:33:16 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-17 22:33:16 +0100 |
commit | c7d6cd358cb9c7c14a92dc3b35eabf8695d35999 (patch) | |
tree | 6950d96092149334eb506705bfd7b86d25ac41fa /core | |
parent | 0bb4870820cfe279e56f02d453c532ebb5074d6a (diff) | |
download | AntennaPod-c7d6cd358cb9c7c14a92dc3b35eabf8695d35999.zip |
Honor sort in episode list view in Android Auto (#6756)
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java | 6 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java | 9 |
2 files changed, 10 insertions, 5 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java index 5c8dead81..9242ea2c1 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java @@ -89,7 +89,6 @@ import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedItemFilter; import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.model.feed.FeedPreferences; -import de.danoeh.antennapod.model.feed.SortOrder; import de.danoeh.antennapod.model.playback.MediaType; import de.danoeh.antennapod.model.playback.Playable; import de.danoeh.antennapod.playback.base.PlaybackServiceMediaPlayer; @@ -429,10 +428,11 @@ public class PlaybackService extends MediaBrowserServiceCompat { new FeedItemFilter(FeedItemFilter.DOWNLOADED), UserPreferences.getDownloadsSortedOrder()); } else if (parentId.equals(getResources().getString(R.string.episodes_label))) { feedItems = DBReader.getEpisodes(0, MAX_ANDROID_AUTO_EPISODES_PER_FEED, - new FeedItemFilter(FeedItemFilter.UNPLAYED), SortOrder.DATE_NEW_OLD); + new FeedItemFilter(FeedItemFilter.UNPLAYED), UserPreferences.getAllEpisodesSortOrder()); } else if (parentId.startsWith("FeedId:")) { long feedId = Long.parseLong(parentId.split(":")[1]); - feedItems = DBReader.getFeedItemList(DBReader.getFeed(feedId)); + Feed feed = DBReader.getFeed(feedId); + feedItems = DBReader.getFeedItemList(feed, FeedItemFilter.unfiltered(), feed.getSortOrder()); } else if (parentId.equals(getString(R.string.recently_played_episodes))) { Playable playable = PlaybackPreferences.createInstanceFromPreferences(this); if (playable instanceof FeedMedia) { diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java index d83557b0c..1b1027c49 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java @@ -15,9 +15,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import de.danoeh.antennapod.core.util.FeedItemPermutors; import de.danoeh.antennapod.core.util.LongList; import de.danoeh.antennapod.core.util.comparator.DownloadResultComparator; -import de.danoeh.antennapod.core.util.comparator.FeedItemPubdateComparator; import de.danoeh.antennapod.core.util.comparator.PlaybackCompletionDateComparator; import de.danoeh.antennapod.model.feed.Chapter; import de.danoeh.antennapod.model.feed.Feed; @@ -170,13 +170,18 @@ public final class DBReader { } public static List<FeedItem> getFeedItemList(final Feed feed, final FeedItemFilter filter) { + return getFeedItemList(feed, filter, SortOrder.DATE_NEW_OLD); + } + + public static List<FeedItem> getFeedItemList(final Feed feed, final FeedItemFilter filter, SortOrder sortOrder) { Log.d(TAG, "getFeedItemList() called with: " + "feed = [" + feed + "]"); PodDBAdapter adapter = PodDBAdapter.getInstance(); adapter.open(); try (Cursor cursor = adapter.getItemsOfFeedCursor(feed, filter)) { List<FeedItem> items = extractItemlistFromCursor(adapter, cursor); - Collections.sort(items, new FeedItemPubdateComparator()); + FeedItemPermutors.getPermutor(sortOrder).reorder(items); + feed.setItems(items); for (FeedItem item : items) { item.setFeed(feed); } |