/*
* Copyright (C) 2015 Naman Dwivedi
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package com.naman14.timber.dataloaders;
import android.content.Context;
import com.naman14.timber.models.Song;
import java.util.ArrayList;
import java.util.List;
public class QueueLoader {
private static NowPlayingCursor mCursor;
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;
}
}