diff options
author | GitStart <1501599+gitstart@users.noreply.github.com> | 2023-02-22 20:04:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-22 20:04:04 +0100 |
commit | 25ddd73f244dc6444ed052942d763384f5c58cac (patch) | |
tree | f0b032d95c166df3c06092b83aafb3147bbcd2f5 /core/src/main | |
parent | 50eb1e9cf93c81e4eec440934feb9ad30bda85b4 (diff) | |
download | AntennaPod-25ddd73f244dc6444ed052942d763384f5c58cac.zip |
Add sort option to episodes screen (#6286)
Diffstat (limited to 'core/src/main')
3 files changed, 7 insertions, 5 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/export/favorites/FavoritesWriter.java b/core/src/main/java/de/danoeh/antennapod/core/export/favorites/FavoritesWriter.java index 092329229..5ccfc93fe 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/export/favorites/FavoritesWriter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/export/favorites/FavoritesWriter.java @@ -18,6 +18,7 @@ import de.danoeh.antennapod.core.export.ExportWriter; import de.danoeh.antennapod.model.feed.Feed; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.core.storage.DBReader; +import de.danoeh.antennapod.model.feed.SortOrder; /** Writes saved favorites to file. */ public class FavoritesWriter implements ExportWriter { @@ -43,7 +44,7 @@ public class FavoritesWriter implements ExportWriter { String feedTemplate = IOUtils.toString(feedTemplateStream, UTF_8); List<FeedItem> allFavorites = DBReader.getRecentlyPublishedEpisodes(0, Integer.MAX_VALUE, - new FeedItemFilter(FeedItemFilter.IS_FAVORITE)); + new FeedItemFilter(FeedItemFilter.IS_FAVORITE), SortOrder.DATE_NEW_OLD); Map<Long, List<FeedItem>> favoriteByFeed = getFeedMap(allFavorites); writer.append(templateParts[0]); 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 176a78f0f..36a056c5d 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 @@ -52,6 +52,7 @@ import de.danoeh.antennapod.event.playback.PlaybackServiceEvent; import de.danoeh.antennapod.event.PlayerErrorEvent; import de.danoeh.antennapod.event.playback.SleepTimerUpdatedEvent; import de.danoeh.antennapod.model.feed.FeedItemFilter; +import de.danoeh.antennapod.model.feed.SortOrder; import de.danoeh.antennapod.playback.base.PlaybackServiceMediaPlayer; import de.danoeh.antennapod.playback.base.PlayerStatus; import de.danoeh.antennapod.playback.cast.CastPsmp; @@ -417,7 +418,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { } else if (parentId.equals(getResources().getString(R.string.episodes_label))) { feedItems = DBReader.getRecentlyPublishedEpisodes(0, MAX_ANDROID_AUTO_EPISODES_PER_FEED, - new FeedItemFilter(FeedItemFilter.UNPLAYED)); + new FeedItemFilter(FeedItemFilter.UNPLAYED), SortOrder.DATE_NEW_OLD); } else if (parentId.startsWith("FeedId:")) { long feedId = Long.parseLong(parentId.split(":")[1]); feedItems = DBReader.getFeedItemList(DBReader.getFeed(feedId)); 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 4641e366c..62b1db3cb 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 @@ -366,12 +366,12 @@ public final class DBReader { * @param filter The filter describing which episodes to filter out. */ @NonNull - public static List<FeedItem> getRecentlyPublishedEpisodes(int offset, int limit, FeedItemFilter filter) { + public static List<FeedItem> getRecentlyPublishedEpisodes(int offset, int limit, + FeedItemFilter filter, SortOrder sortOrder) { Log.d(TAG, "getRecentlyPublishedEpisodes() called with: offset=" + offset + ", limit=" + limit); - PodDBAdapter adapter = PodDBAdapter.getInstance(); adapter.open(); - try (Cursor cursor = adapter.getRecentlyPublishedItemsCursor(offset, limit, filter)) { + try (Cursor cursor = adapter.getRecentlyPublishedItemsCursor(offset, limit, filter, sortOrder)) { List<FeedItem> items = extractItemlistFromCursor(adapter, cursor); loadAdditionalFeedItemListData(items); return items; |