summaryrefslogtreecommitdiff
path: root/storage/database
diff options
context:
space:
mode:
authorByteHamster <info@bytehamster.com>2023-05-05 19:42:51 +0200
committerByteHamster <info@bytehamster.com>2023-05-05 19:43:45 +0200
commitf8be7d596d098e534039908ade8270e13168fd23 (patch)
treeaa168885671cf49293c8a5eec088f0fedfaaa54b /storage/database
parent967e289f91f51d0b5a91fdd598c3f42bd995299a (diff)
parentb063f0508f6e6439509f22769374c57f77cb499f (diff)
downloadAntennaPod-f8be7d596d098e534039908ade8270e13168fd23.zip
Merge branch 'master' into develop
Diffstat (limited to 'storage/database')
-rw-r--r--storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java12
1 files changed, 6 insertions, 6 deletions
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 1de47f769..40933e8d1 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
@@ -1012,17 +1012,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 (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);
}