Bugfixes
This commit is contained in:
parent
5f89e52658
commit
f9cd2e8a2e
5 changed files with 24 additions and 29 deletions
|
|
@ -40,10 +40,10 @@ public class AlbumLoader {
|
|||
}
|
||||
|
||||
public static final Cursor makeAlbumCursor(final Context context) {
|
||||
return makeAlbumCursor(context, null);
|
||||
return makeAlbumCursor(context, null, null);
|
||||
}
|
||||
|
||||
public static final Cursor makeAlbumCursor(final Context context, String selection) {
|
||||
public static final Cursor makeAlbumCursor(final Context context, final String selection, final String[] values) {
|
||||
return context.getContentResolver().query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI,
|
||||
new String[]{
|
||||
/* 0 */
|
||||
|
|
@ -58,11 +58,11 @@ public class AlbumLoader {
|
|||
MediaStore.Audio.AlbumColumns.NUMBER_OF_SONGS,
|
||||
/* 5 */
|
||||
MediaStore.Audio.AlbumColumns.FIRST_YEAR
|
||||
}, selection, null, PreferenceUtils.getInstace(context).getAlbumSortOrder());
|
||||
}, selection, values, PreferenceUtils.getInstace(context).getAlbumSortOrder());
|
||||
}
|
||||
|
||||
public static Album getAlbum(Context context, int albumId) {
|
||||
Cursor cursor = makeAlbumCursor(context, BaseColumns._ID + "=" + albumId);
|
||||
Cursor cursor = makeAlbumCursor(context, BaseColumns._ID + "=?", new String[]{String.valueOf(albumId)});
|
||||
Album album = new Album();
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
final int id = cursor.getInt(0);
|
||||
|
|
@ -82,7 +82,7 @@ public class AlbumLoader {
|
|||
}
|
||||
|
||||
public static List<Album> getAlbums(Context context, String query) {
|
||||
Cursor cursor = makeAlbumCursor(context, MediaStore.Audio.AlbumColumns.ALBUM + " LIKE '%" + query + "%'");
|
||||
Cursor cursor = makeAlbumCursor(context, MediaStore.Audio.AlbumColumns.ALBUM + " LIKE ?", new String[]{"%"+query+"%"});
|
||||
List<Album> albums = new ArrayList<>();
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
do {
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@ public class ArtistLoader {
|
|||
}
|
||||
|
||||
public static final Cursor makeArtistCursor(final Context context) {
|
||||
return makeArtistCursor(context, null);
|
||||
return makeArtistCursor(context, null, null);
|
||||
}
|
||||
|
||||
public static final Cursor makeArtistCursor(final Context context, String selection) {
|
||||
public static final Cursor makeArtistCursor(final Context context, final String selection, final String[] values) {
|
||||
return context.getContentResolver().query(MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI,
|
||||
new String[]{
|
||||
/* 0 */
|
||||
|
|
@ -52,11 +52,11 @@ public class ArtistLoader {
|
|||
MediaStore.Audio.ArtistColumns.NUMBER_OF_ALBUMS,
|
||||
/* 3 */
|
||||
MediaStore.Audio.ArtistColumns.NUMBER_OF_TRACKS
|
||||
}, selection, null, PreferenceUtils.getInstace(context).getArtistSortOrder());
|
||||
}, selection, values, PreferenceUtils.getInstace(context).getArtistSortOrder());
|
||||
}
|
||||
|
||||
public static Artist getArtist(Context context, int artistId) {
|
||||
Cursor cursor = makeArtistCursor(context, BaseColumns._ID + "=" + artistId);
|
||||
Cursor cursor = makeArtistCursor(context, BaseColumns._ID + "=?", new String[]{String.valueOf(artistId)});
|
||||
Artist artist = new Artist();
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
final int id = cursor.getInt(0);
|
||||
|
|
@ -74,7 +74,7 @@ public class ArtistLoader {
|
|||
}
|
||||
|
||||
public static List<Artist> getArtists(Context context, String query) {
|
||||
Cursor cursor = makeArtistCursor(context, MediaStore.Audio.ArtistColumns.ARTIST + " LIKE '%" + query + "%'");
|
||||
Cursor cursor = makeArtistCursor(context, MediaStore.Audio.ArtistColumns.ARTIST + " LIKE ?", new String[]{"%"+query+"%"});
|
||||
List<Artist> artists = new ArrayList<>();
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
do {
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
public class PlaylistLoader {
|
||||
public static Playlist getPlaylist(final Context context, final int playlistID) {
|
||||
public static Playlist getPlaylist(final Context context, final int playlistId) {
|
||||
Playlist playlist = new Playlist();
|
||||
Cursor cursor = makePlaylistCursor(context, BaseColumns._ID + "=" + playlistID);
|
||||
Cursor cursor = makePlaylistCursor(context, BaseColumns._ID + "=?", new String[]{String.valueOf(playlistId)});
|
||||
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
final int id = cursor.getInt(0);
|
||||
|
|
@ -29,7 +29,7 @@ public class PlaylistLoader {
|
|||
|
||||
public static List<Playlist> getAllPlaylists(final Context context) {
|
||||
List<Playlist> playlists = new ArrayList<>();
|
||||
Cursor cursor = makePlaylistCursor(context, null);
|
||||
Cursor cursor = makePlaylistCursor(context, null, null);
|
||||
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
do {
|
||||
|
|
@ -45,13 +45,13 @@ public class PlaylistLoader {
|
|||
return playlists;
|
||||
}
|
||||
|
||||
public static Cursor makePlaylistCursor(final Context context, final String selection) {
|
||||
public static Cursor makePlaylistCursor(final Context context, final String selection, final String[] values) {
|
||||
return context.getContentResolver().query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
|
||||
new String[]{
|
||||
/* 0 */
|
||||
BaseColumns._ID,
|
||||
/* 1 */
|
||||
PlaylistsColumns.NAME
|
||||
}, selection, null, MediaStore.Audio.Playlists.DEFAULT_SORT_ORDER);
|
||||
}, selection, values, MediaStore.Audio.Playlists.DEFAULT_SORT_ORDER);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,10 +41,10 @@ public class SongLoader {
|
|||
}
|
||||
|
||||
public static final Cursor makeSongCursor(final Context context) {
|
||||
return makeSongCursor(context, (MediaStore.Audio.AudioColumns.IS_MUSIC + "=1"));
|
||||
return makeSongCursor(context, MediaStore.Audio.AudioColumns.IS_MUSIC + "=?", new String[]{"1"});
|
||||
}
|
||||
|
||||
public static final Cursor makeSongCursor(final Context context, final String selection) {
|
||||
public static final Cursor makeSongCursor(final Context context, final String selection, final String[] values) {
|
||||
return context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
|
||||
new String[]{
|
||||
/* 0 */
|
||||
|
|
@ -63,11 +63,11 @@ public class SongLoader {
|
|||
MediaStore.Audio.AudioColumns.ARTIST_ID,
|
||||
/* 7 */
|
||||
MediaStore.Audio.AudioColumns.ALBUM_ID
|
||||
}, selection, null, PreferenceUtils.getInstace(context).getSongSortOrder());
|
||||
}, selection, values, PreferenceUtils.getInstace(context).getSongSortOrder());
|
||||
}
|
||||
|
||||
public static List<Song> getSongs(Context context, String query) {
|
||||
Cursor cursor = makeSongCursor(context, MediaStore.Audio.AudioColumns.TITLE + " LIKE '%" + query + "%'");
|
||||
public static List<Song> getSongs(final Context context, final String query) {
|
||||
Cursor cursor = makeSongCursor(context, MediaStore.Audio.AudioColumns.TITLE + " LIKE ?", new String[]{"%"+query+"%"});
|
||||
List<Song> songs = new ArrayList<>();
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
do {
|
||||
|
|
@ -91,8 +91,8 @@ public class SongLoader {
|
|||
return songs;
|
||||
}
|
||||
|
||||
public static Song getSong(Context context, int queryId) {
|
||||
Cursor cursor = makeSongCursor(context, MediaStore.Audio.AudioColumns._ID + "=" + queryId);
|
||||
public static Song getSong(final Context context, final int queryId) {
|
||||
Cursor cursor = makeSongCursor(context, MediaStore.Audio.AudioColumns._ID + "=?", new String[]{String.valueOf(queryId)});
|
||||
Song song = null;
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
final int id = cursor.getInt(0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue