From ee69e8c66bf0e734db8770efd9ad512491ce546a Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Fri, 31 Mar 2023 22:07:41 +0200 Subject: Remove from queue section some time after resetting playback position (#6402) --- .../de/danoeh/antennapod/storage/database/PodDBAdapter.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'storage/database') diff --git a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java index 46c731205..74fa6ecc4 100644 --- a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java +++ b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java @@ -999,17 +999,17 @@ public class PodDBAdapter { } public final Cursor getPausedQueueCursor(int limit) { - //playback position > 0 (paused), rank by last played, then rest of queue + final String hasPositionOrRecentlyPlayed = TABLE_NAME_FEED_MEDIA + "." + KEY_POSITION + " >= 1000" + + " OR " + TABLE_NAME_FEED_MEDIA + "." + KEY_LAST_PLAYED_TIME + + " >= " + (System.currentTimeMillis() - 30000); final String query = "SELECT " + KEYS_FEED_ITEM_WITHOUT_DESCRIPTION + ", " + KEYS_FEED_MEDIA + " FROM " + TABLE_NAME_QUEUE + " INNER JOIN " + TABLE_NAME_FEED_ITEMS + " ON " + SELECT_KEY_ITEM_ID + " = " + TABLE_NAME_QUEUE + "." + KEY_FEEDITEM + JOIN_FEED_ITEM_AND_MEDIA - // In the front: Episodes that have a position >1sec, but also the episode that was just started - + " ORDER BY (" + TABLE_NAME_FEED_MEDIA + "." + KEY_POSITION + " >= 1000" - + " OR " + TABLE_NAME_FEED_MEDIA + "." + KEY_LAST_PLAYED_TIME - + " >= " + (System.currentTimeMillis() - 30000) + ") DESC , " - + TABLE_NAME_FEED_MEDIA + "." + KEY_LAST_PLAYED_TIME + " DESC , " + TABLE_NAME_QUEUE + "." + KEY_ID + + " ORDER BY IIF(" + hasPositionOrRecentlyPlayed + + ", " + TABLE_NAME_FEED_MEDIA + "." + KEY_LAST_PLAYED_TIME + ", 0) DESC , " + + TABLE_NAME_QUEUE + "." + KEY_ID + " LIMIT " + limit; return db.rawQuery(query, null); } -- cgit v1.2.3 From a877809bade2a24fe7da992bce29e5e2939981d5 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Fri, 21 Apr 2023 22:19:20 +0200 Subject: Fix queue section not loading (#6447) Apparently some devices do not support the SQLite IIF function. --- .../main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'storage/database') diff --git a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java index 74fa6ecc4..35064b605 100644 --- a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java +++ b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java @@ -1007,8 +1007,8 @@ public class PodDBAdapter { + " INNER JOIN " + TABLE_NAME_FEED_ITEMS + " ON " + SELECT_KEY_ITEM_ID + " = " + TABLE_NAME_QUEUE + "." + KEY_FEEDITEM + JOIN_FEED_ITEM_AND_MEDIA - + " ORDER BY IIF(" + hasPositionOrRecentlyPlayed - + ", " + TABLE_NAME_FEED_MEDIA + "." + KEY_LAST_PLAYED_TIME + ", 0) DESC , " + + " ORDER BY (CASE WHEN " + hasPositionOrRecentlyPlayed + " THEN " + + TABLE_NAME_FEED_MEDIA + "." + KEY_LAST_PLAYED_TIME + " ELSE 0 END) DESC , " + TABLE_NAME_QUEUE + "." + KEY_ID + " LIMIT " + limit; return db.rawQuery(query, null); -- cgit v1.2.3