diff options
author | Paul Ganssle <1377457+pganssle@users.noreply.github.com> | 2022-06-09 16:24:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-09 22:24:22 +0200 |
commit | df53c5bfe57e95211fd6e3f90b4c2480cf5f7bf9 (patch) | |
tree | 5c6ba253d4066cff98f369b46ee4528318c759fd /core/src/main | |
parent | fd066a648ba46762267acb9fd1042d1c2f851303 (diff) | |
download | AntennaPod-df53c5bfe57e95211fd6e3f90b4c2480cf5f7bf9.zip |
Convert playback history fragment to lazy loading (#5886)
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java | 23 |
1 files changed, 15 insertions, 8 deletions
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 cffcbf32f..e7e8e9587 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 @@ -46,11 +46,6 @@ public final class DBReader { private static final String TAG = "DBReader"; /** - * Maximum size of the list returned by {@link #getPlaybackHistory()}. - */ - public static final int PLAYBACK_HISTORY_SIZE = 50; - - /** * Maximum size of the list returned by {@link #getDownloadLog()}. */ private static final int DOWNLOAD_LOG_SIZE = 200; @@ -419,11 +414,12 @@ public final class DBReader { * Loads the playback history from the database. A FeedItem is in the playback history if playback of the correpsonding episode * has been completed at least once. * + * @param limit The maximum number of items to return. + * * @return The playback history. The FeedItems are sorted by their media's playbackCompletionDate in descending order. - * The size of the returned list is limited by {@link #PLAYBACK_HISTORY_SIZE}. */ @NonNull - public static List<FeedItem> getPlaybackHistory() { + public static List<FeedItem> getPlaybackHistory(int offset, int limit) { Log.d(TAG, "getPlaybackHistory() called"); PodDBAdapter adapter = PodDBAdapter.getInstance(); @@ -432,7 +428,7 @@ public final class DBReader { Cursor mediaCursor = null; Cursor itemCursor = null; try { - mediaCursor = adapter.getCompletedMediaCursor(PLAYBACK_HISTORY_SIZE); + mediaCursor = adapter.getCompletedMediaCursor(offset, limit); String[] itemIds = new String[mediaCursor.getCount()]; for (int i = 0; i < itemIds.length && mediaCursor.moveToPosition(i); i++) { int index = mediaCursor.getColumnIndex(PodDBAdapter.KEY_FEEDITEM); @@ -454,6 +450,17 @@ public final class DBReader { } } + public static long getPlaybackHistoryLength() { + PodDBAdapter adapter = PodDBAdapter.getInstance(); + adapter.open(); + + try { + return adapter.getCompletedMediaLength(); + } finally { + adapter.close(); + } + } + /** * Loads the download log from the database. * |