Make queue loading more efficient

This commit is contained in:
ByteHamster 2022-08-30 19:46:59 +02:00
parent 836e2199bc
commit 1207660787
1 changed files with 12 additions and 6 deletions

View File

@ -971,9 +971,11 @@ public class PodDBAdapter {
* cursor uses the FEEDITEM_SEL_FI_SMALL selection. * cursor uses the FEEDITEM_SEL_FI_SMALL selection.
*/ */
public final Cursor getQueueCursor() { public final Cursor getQueueCursor() {
final String query = SELECT_FEED_ITEMS_AND_MEDIA final String query = "SELECT " + KEYS_FEED_ITEM_WITHOUT_DESCRIPTION + ", " + KEYS_FEED_MEDIA
+ " INNER JOIN " + TABLE_NAME_QUEUE + " FROM " + TABLE_NAME_QUEUE
+ " INNER JOIN " + TABLE_NAME_FEED_ITEMS
+ " ON " + SELECT_KEY_ITEM_ID + " = " + TABLE_NAME_QUEUE + "." + KEY_FEEDITEM + " ON " + SELECT_KEY_ITEM_ID + " = " + TABLE_NAME_QUEUE + "." + KEY_FEEDITEM
+ JOIN_FEED_ITEM_AND_MEDIA
+ " ORDER BY " + TABLE_NAME_QUEUE + "." + KEY_ID; + " ORDER BY " + TABLE_NAME_QUEUE + "." + KEY_ID;
return db.rawQuery(query, null); return db.rawQuery(query, null);
} }
@ -983,9 +985,11 @@ public class PodDBAdapter {
} }
public Cursor getNextInQueue(final FeedItem item) { public Cursor getNextInQueue(final FeedItem item) {
final String query = SELECT_FEED_ITEMS_AND_MEDIA final String query = "SELECT " + KEYS_FEED_ITEM_WITHOUT_DESCRIPTION + ", " + KEYS_FEED_MEDIA
+ "INNER JOIN " + TABLE_NAME_QUEUE + " FROM " + TABLE_NAME_QUEUE
+ " INNER JOIN " + TABLE_NAME_FEED_ITEMS
+ " ON " + SELECT_KEY_ITEM_ID + " = " + TABLE_NAME_QUEUE + "." + KEY_FEEDITEM + " ON " + SELECT_KEY_ITEM_ID + " = " + TABLE_NAME_QUEUE + "." + KEY_FEEDITEM
+ JOIN_FEED_ITEM_AND_MEDIA
+ " WHERE Queue.ID > (SELECT Queue.ID FROM Queue WHERE Queue.FeedItem = " + " WHERE Queue.ID > (SELECT Queue.ID FROM Queue WHERE Queue.FeedItem = "
+ item.getId() + item.getId()
+ ")" + ")"
@ -996,9 +1000,11 @@ public class PodDBAdapter {
public final Cursor getPausedQueueCursor(int limit) { public final Cursor getPausedQueueCursor(int limit) {
//playback position > 0 (paused), rank by last played, then rest of queue //playback position > 0 (paused), rank by last played, then rest of queue
final String query = SELECT_FEED_ITEMS_AND_MEDIA final String query = "SELECT " + KEYS_FEED_ITEM_WITHOUT_DESCRIPTION + ", " + KEYS_FEED_MEDIA
+ " INNER JOIN " + TABLE_NAME_QUEUE + " FROM " + TABLE_NAME_QUEUE
+ " INNER JOIN " + TABLE_NAME_FEED_ITEMS
+ " ON " + SELECT_KEY_ITEM_ID + " = " + TABLE_NAME_QUEUE + "." + KEY_FEEDITEM + " ON " + SELECT_KEY_ITEM_ID + " = " + TABLE_NAME_QUEUE + "." + KEY_FEEDITEM
+ JOIN_FEED_ITEM_AND_MEDIA
+ " ORDER BY " + TABLE_NAME_FEED_MEDIA + "." + KEY_POSITION + ">0 DESC , " + " ORDER BY " + TABLE_NAME_FEED_MEDIA + "." + KEY_POSITION + ">0 DESC , "
+ TABLE_NAME_FEED_MEDIA + "." + KEY_LAST_PLAYED_TIME + " DESC , " + TABLE_NAME_QUEUE + "." + KEY_ID + TABLE_NAME_FEED_MEDIA + "." + KEY_LAST_PLAYED_TIME + " DESC , " + TABLE_NAME_QUEUE + "." + KEY_ID
+ " LIMIT " + limit; + " LIMIT " + limit;