Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2c472457 authored by Paul Keith's avatar Paul Keith
Browse files

Eleven: Deduplicate query selection/sorting logic

* Use the appropriate loaders to make our cursor in MusicUtils
* This fixes the ordering of the songs in the play queue/playlist
  when using the "Play", "Add to queue" and "Add to playlist"
  options from the overflow menu from an album or an artist's
  detailed view to match what is actually displayed

Change-Id: I43c60583de6e0e746627cdd6a8b535e627d90ec1
parent 8f701a34
Loading
Loading
Loading
Loading
+3 −14
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import org.lineageos.eleven.IElevenService;
import org.lineageos.eleven.MusicPlaybackService;
import org.lineageos.eleven.R;
import org.lineageos.eleven.cache.ImageFetcher;
import org.lineageos.eleven.loaders.AlbumSongLoader;
import org.lineageos.eleven.loaders.LastAddedLoader;
import org.lineageos.eleven.loaders.PlaylistLoader;
import org.lineageos.eleven.loaders.PlaylistSongLoader;
@@ -794,14 +795,9 @@ public final class MusicUtils {
     * @return The song list for an artist.
     */
    public static long[] getSongListForArtist(final Context context, final long id) {
        final String[] projection = new String[] {
            BaseColumns._ID
        };
        final String selection = AudioColumns.ARTIST_ID + "=" + id + " AND "
                + AudioColumns.IS_MUSIC + "=1";
        try (Cursor cursor = context.getContentResolver().query(
                MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection, selection, null,
                AudioColumns.ALBUM_KEY + "," + AudioColumns.TRACK)) {
        try (Cursor cursor = SongLoader.makeSongCursor(context, selection)) {
            if (cursor != null) {
                return getSongListForCursor(cursor);
            }
@@ -815,14 +811,7 @@ public final class MusicUtils {
     * @return The song list for an album.
     */
    public static long[] getSongListForAlbum(final Context context, final long id) {
        final String[] projection = new String[] {
            BaseColumns._ID
        };
        final String selection = AudioColumns.ALBUM_ID + "=" + id + " AND " + AudioColumns.IS_MUSIC
                + "=1";
        try (Cursor cursor = context.getContentResolver().query(
                MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection, selection, null,
                AudioColumns.TRACK + ", " + MediaStore.Audio.Media.DEFAULT_SORT_ORDER)) {
        try (Cursor cursor = AlbumSongLoader.makeAlbumSongCursor(context, id)) {
            if (cursor != null) {
                return getSongListForCursor(cursor);
            }