sort albums by album -> track
This commit is contained in:
parent
7beb3e6651
commit
5f2b998a98
@ -177,7 +177,7 @@ public class MediaAdapter
|
||||
mFields = new String[] { MediaStore.Audio.Albums.ARTIST, MediaStore.Audio.Albums.ALBUM };
|
||||
// Why is there no artist_key column constant in the album MediaStore? The column does seem to exist.
|
||||
mFieldKeys = new String[] { "artist_key", MediaStore.Audio.Albums.ALBUM_KEY };
|
||||
mSongSort = "album_key,track";
|
||||
mSongSort = MediaUtils.ALBUM_SORT;
|
||||
mSortEntries = new int[] { R.string.name, R.string.artist_album, R.string.year, R.string.number_of_tracks, R.string.date_added };
|
||||
mSortValues = new String[] { "album_key %1$s", "artist_key %1$s,album_key %1$s", "minyear %1$s,album_key %1$s", "numsongs %1$s,album_key %1$s", "_id %1$s" };
|
||||
break;
|
||||
|
@ -87,6 +87,11 @@ public class MediaUtils {
|
||||
*/
|
||||
public static final String DEFAULT_SORT = "artist_key,album_key,track";
|
||||
|
||||
/**
|
||||
* The default sort order for albums. First the album, then tracknumber
|
||||
*/
|
||||
public static final String ALBUM_SORT = "album_key,track";
|
||||
|
||||
/**
|
||||
* Cached random instance.
|
||||
*/
|
||||
@ -135,6 +140,7 @@ public class MediaUtils {
|
||||
{
|
||||
Uri media = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
|
||||
StringBuilder selection = new StringBuilder();
|
||||
String sort = DEFAULT_SORT;
|
||||
|
||||
switch (type) {
|
||||
case TYPE_SONG:
|
||||
@ -145,6 +151,7 @@ public class MediaUtils {
|
||||
break;
|
||||
case TYPE_ALBUM:
|
||||
selection.append(MediaStore.Audio.Media.ALBUM_ID);
|
||||
sort = ALBUM_SORT;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid type specified: " + type);
|
||||
@ -159,7 +166,7 @@ public class MediaUtils {
|
||||
selection.append(select);
|
||||
}
|
||||
|
||||
QueryTask result = new QueryTask(media, projection, selection.toString(), null, DEFAULT_SORT);
|
||||
QueryTask result = new QueryTask(media, projection, selection.toString(), null, sort);
|
||||
result.type = type;
|
||||
return result;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user