Implement getSongByTypeId
This commit is contained in:
parent
1fd0a60fe1
commit
a4ad16832c
@ -405,6 +405,27 @@ public class MediaUtils {
|
||||
sAllSongs = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first matching song (or NULL) of given type + id combination
|
||||
*
|
||||
* @param resolver A ContentResolver to use.
|
||||
* @param type The MediaTye to query
|
||||
* @param id The id of given type to query
|
||||
*/
|
||||
public static Song getSongByTypeId(ContentResolver resolver, int type, long id) {
|
||||
Song song = new Song(-1);
|
||||
QueryTask query = buildQuery(type, id, Song.FILLED_PROJECTION, null);
|
||||
Cursor cursor = query.runQuery(resolver);
|
||||
if (cursor != null) {
|
||||
if (cursor.getCount() > 0) {
|
||||
cursor.moveToPosition(0);
|
||||
song.populate(cursor);
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
return song.id == -1 ? null : song;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a song randomly selected from all the songs in the Android
|
||||
* MediaStore.
|
||||
|
Loading…
x
Reference in New Issue
Block a user