use of com.naman14.timber.models.Song in project Timber by naman14.
the class QueueLoader method getQueueSongs.
public static List<Song> getQueueSongs(Context context) {
final ArrayList<Song> mSongList = new ArrayList<>();
mCursor = new NowPlayingCursor(context);
if (mCursor != null && mCursor.moveToFirst()) {
do {
final long id = mCursor.getLong(0);
final String songName = mCursor.getString(1);
final String artist = mCursor.getString(2);
final long albumId = mCursor.getLong(3);
final String album = mCursor.getString(4);
final int duration = mCursor.getInt(5);
final long artistid = mCursor.getInt(7);
final int tracknumber = mCursor.getInt(6);
final Song song = new Song(id, albumId, artistid, songName, artist, album, duration, tracknumber);
mSongList.add(song);
} while (mCursor.moveToNext());
}
if (mCursor != null) {
mCursor.close();
mCursor = null;
}
return mSongList;
}
use of com.naman14.timber.models.Song in project Timber by naman14.
the class AlbumSongLoader method getSongsForAlbum.
public static ArrayList<Song> getSongsForAlbum(Context context, long albumID) {
Cursor cursor = makeAlbumSongCursor(context, albumID);
ArrayList arrayList = new ArrayList();
if ((cursor != null) && (cursor.moveToFirst()))
do {
long id = cursor.getLong(0);
String title = cursor.getString(1);
String artist = cursor.getString(2);
String album = cursor.getString(3);
int duration = cursor.getInt(4);
int trackNumber = cursor.getInt(5);
/*This fixes bug where some track numbers displayed as 100 or 200*/
while (trackNumber >= 1000) {
//When error occurs the track numbers have an extra 1000 or 2000 added, so decrease till normal.
trackNumber -= 1000;
}
long artistId = cursor.getInt(6);
long albumId = albumID;
arrayList.add(new Song(id, albumId, artistId, title, artist, album, duration, trackNumber));
} while (cursor.moveToNext());
if (cursor != null)
cursor.close();
return arrayList;
}
use of com.naman14.timber.models.Song in project Timber by naman14.
the class LastAddedLoader method getLastAddedSongs.
public static List<Song> getLastAddedSongs(Context context) {
ArrayList<Song> mSongList = new ArrayList<>();
mCursor = makeLastAddedCursor(context);
if (mCursor != null && mCursor.moveToFirst()) {
do {
long id = mCursor.getLong(0);
String title = mCursor.getString(1);
String artist = mCursor.getString(2);
String album = mCursor.getString(3);
int duration = mCursor.getInt(4);
int trackNumber = mCursor.getInt(5);
long artistId = mCursor.getInt(6);
long albumId = mCursor.getLong(7);
final Song song = new Song(id, albumId, artistId, title, artist, album, duration, trackNumber);
mSongList.add(song);
} while (mCursor.moveToNext());
}
if (mCursor != null) {
mCursor.close();
mCursor = null;
}
return mSongList;
}
use of com.naman14.timber.models.Song in project Timber by naman14.
the class SongLoader method getSongFromPath.
public static Song getSongFromPath(String songPath, Context context) {
ContentResolver cr = context.getContentResolver();
Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
String selection = MediaStore.Audio.Media.DATA;
String[] selectionArgs = { songPath };
String[] projection = new String[] { "_id", "title", "artist", "album", "duration", "track", "artist_id", "album_id" };
String sortOrder = MediaStore.Audio.Media.TITLE + " ASC";
Cursor cursor = cr.query(uri, projection, selection + "=?", selectionArgs, sortOrder);
if (cursor != null && cursor.getCount() > 0) {
Song song = getSongForCursor(cursor);
cursor.close();
return song;
} else
return new Song();
}
use of com.naman14.timber.models.Song in project Timber by naman14.
the class SongLoader method getSongForCursor.
public static Song getSongForCursor(Cursor cursor) {
Song song = new Song();
if ((cursor != null) && (cursor.moveToFirst())) {
long id = cursor.getLong(0);
String title = cursor.getString(1);
String artist = cursor.getString(2);
String album = cursor.getString(3);
int duration = cursor.getInt(4);
int trackNumber = cursor.getInt(5);
long artistId = cursor.getInt(6);
long albumId = cursor.getLong(7);
song = new Song(id, albumId, artistId, title, artist, album, duration, trackNumber);
}
if (cursor != null)
cursor.close();
return song;
}
Aggregations