private ArrayList<Album> mAlbumsList = Lists.newArrayList();
/**
- * The {@link Cursor} used to run the query.
- */
- private Cursor mCursor;
-
- /**
* Additional selection filter
*/
protected Long mArtistId;
@Override
public List<Album> loadInBackground() {
// Create the Cursor
- mCursor = makeAlbumCursor(getContext(), mArtistId);
+ Cursor cursor = makeAlbumCursor(getContext(), mArtistId);
// Gather the data
- if (mCursor != null && mCursor.moveToFirst()) {
+ if (cursor != null && cursor.moveToFirst()) {
do {
// Copy the album id
- final long id = mCursor.getLong(0);
+ final long id = cursor.getLong(0);
// Copy the album name
- final String albumName = mCursor.getString(1);
+ final String albumName = cursor.getString(1);
// Copy the artist name
- final String artist = mCursor.getString(2);
+ final String artist = cursor.getString(2);
// Copy the number of songs
- final int songCount = mCursor.getInt(3);
+ final int songCount = cursor.getInt(3);
// Copy the release year
- final String year = mCursor.getString(4);
+ final String year = cursor.getString(4);
// as per designer's request, don't show unknown albums
if (MediaStore.UNKNOWN_STRING.equals(albumName)) {
// Create a new album
final Album album = new Album(id, albumName, artist, songCount, year);
- if (mCursor instanceof SortedCursor) {
- album.mBucketLabel = (String)((SortedCursor)mCursor).getExtraData();
+ if (cursor instanceof SortedCursor) {
+ album.mBucketLabel = (String)((SortedCursor) cursor).getExtraData();
}
// Add everything up
mAlbumsList.add(album);
- } while (mCursor.moveToNext());
+ } while (cursor.moveToNext());
}
// Close the cursor
- if (mCursor != null) {
- mCursor.close();
- mCursor = null;
+ if (cursor != null) {
+ cursor.close();
+ cursor = null;
}
return mAlbumsList;
private final ArrayList<Song> mSongList = Lists.newArrayList();
/**
- * The {@link Cursor} used to run the query.
- */
- private Cursor mCursor;
-
- /**
* The Id of the album the songs belong to.
*/
private final Long mAlbumID;
@Override
public List<Song> loadInBackground() {
// Create the Cursor
- mCursor = makeAlbumSongCursor(getContext(), mAlbumID);
+ Cursor cursor = makeAlbumSongCursor(getContext(), mAlbumID);
// Gather the data
- if (mCursor != null && mCursor.moveToFirst()) {
+ if (cursor != null && cursor.moveToFirst()) {
do {
// Copy the song Id
- final long id = mCursor.getLong(0);
+ final long id = cursor.getLong(0);
// Copy the song name
- final String songName = mCursor.getString(1);
+ final String songName = cursor.getString(1);
// Copy the artist name
- final String artist = mCursor.getString(2);
+ final String artist = cursor.getString(2);
// Copy the album name
- final String album = mCursor.getString(3);
+ final String album = cursor.getString(3);
// Copy the duration
- final long duration = mCursor.getLong(4);
+ final long duration = cursor.getLong(4);
// Make the duration label
final int seconds = (int) (duration / 1000);
// Grab the Song Year
- final int year = mCursor.getInt(5);
+ final int year = cursor.getInt(5);
// Create a new song
final Song song = new Song(id, songName, artist, album, mAlbumID, seconds, year);
// Add everything up
mSongList.add(song);
- } while (mCursor.moveToNext());
+ } while (cursor.moveToNext());
}
// Close the cursor
- if (mCursor != null) {
- mCursor.close();
- mCursor = null;
+ if (cursor != null) {
+ cursor.close();
+ cursor = null;
}
return mSongList;
}
private ArrayList<Artist> mArtistsList = Lists.newArrayList();
/**
- * The {@link Cursor} used to run the query.
- */
- private Cursor mCursor;
-
- /**
* Constructor of <code>ArtistLoader</code>
*
* @param context The {@link Context} to use
@Override
public List<Artist> loadInBackground() {
// Create the Cursor
- mCursor = makeArtistCursor(getContext());
+ Cursor cursor = makeArtistCursor(getContext());
// Gather the data
- if (mCursor != null && mCursor.moveToFirst()) {
+ if (cursor != null && cursor.moveToFirst()) {
do {
// Copy the artist id
- final long id = mCursor.getLong(0);
+ final long id = cursor.getLong(0);
// Copy the artist name
- final String artistName = mCursor.getString(1);
+ final String artistName = cursor.getString(1);
// Copy the number of albums
- final int albumCount = mCursor.getInt(2);
+ final int albumCount = cursor.getInt(2);
// Copy the number of songs
- final int songCount = mCursor.getInt(3);
+ final int songCount = cursor.getInt(3);
// as per designer's request, don't show unknown artist
if (MediaStore.UNKNOWN_STRING.equals(artistName)) {
// Create a new artist
final Artist artist = new Artist(id, artistName, songCount, albumCount);
- if (mCursor instanceof SortedCursor) {
- artist.mBucketLabel = (String)((SortedCursor)mCursor).getExtraData();
+ if (cursor instanceof SortedCursor) {
+ artist.mBucketLabel = (String)((SortedCursor) cursor).getExtraData();
}
mArtistsList.add(artist);
- } while (mCursor.moveToNext());
+ } while (cursor.moveToNext());
}
// Close the cursor
- if (mCursor != null) {
- mCursor.close();
- mCursor = null;
+ if (cursor != null) {
+ cursor.close();
+ cursor = null;
}
return mArtistsList;
private final ArrayList<Song> mSongList = Lists.newArrayList();
/**
- * The {@link Cursor} used to run the query.
- */
- private Cursor mCursor;
-
- /**
* Constructor of <code>LastAddedHandler</code>
*
* @param context The {@link Context} to use.
@Override
public List<Song> loadInBackground() {
// Create the xCursor
- mCursor = makeLastAddedCursor(getContext());
+ Cursor cursor = makeLastAddedCursor(getContext());
// Gather the data
- if (mCursor != null && mCursor.moveToFirst()) {
+ if (cursor != null && cursor.moveToFirst()) {
do {
// Copy the song Id
- final long id = mCursor.getLong(0);
+ final long id = cursor.getLong(0);
// Copy the song name
- final String songName = mCursor.getString(1);
+ final String songName = cursor.getString(1);
// Copy the artist name
- final String artist = mCursor.getString(2);
+ final String artist = cursor.getString(2);
// Copy the album id
- final long albumId = mCursor.getLong(3);
+ final long albumId = cursor.getLong(3);
// Copy the album name
- final String album = mCursor.getString(4);
+ final String album = cursor.getString(4);
// Copy the duration
- final long duration = mCursor.getLong(5);
+ final long duration = cursor.getLong(5);
// Convert the duration into seconds
final int durationInSecs = (int) duration / 1000;
// Grab the Song Year
- final int year = mCursor.getInt(6);
+ final int year = cursor.getInt(6);
// Create a new song
final Song song = new Song(id, songName, artist, album, albumId, durationInSecs, year);
// Add everything up
mSongList.add(song);
- } while (mCursor.moveToNext());
+ } while (cursor.moveToNext());
}
// Close the cursor
- if (mCursor != null) {
- mCursor.close();
- mCursor = null;
+ if (cursor != null) {
+ cursor.close();
+ cursor = null;
}
return mSongList;
}
private final ArrayList<Playlist> mPlaylistList = Lists.newArrayList();
/**
- * The {@link Cursor} used to run the query.
- */
- private Cursor mCursor;
-
- /**
* Constructor of <code>PlaylistLoader</code>
*
* @param context The {@link Context} to use
makeDefaultPlaylists();
// Create the Cursor
- mCursor = makePlaylistCursor(getContext());
+ Cursor cursor = makePlaylistCursor(getContext());
// Gather the data
- if (mCursor != null && mCursor.moveToFirst()) {
+ if (cursor != null && cursor.moveToFirst()) {
do {
// Copy the playlist id
- final long id = mCursor.getLong(0);
+ final long id = cursor.getLong(0);
// Copy the playlist name
- final String name = mCursor.getString(1);
+ final String name = cursor.getString(1);
final int songCount = MusicUtils.getSongCountForPlaylist(getContext(), id);
// Add everything up
mPlaylistList.add(playlist);
- } while (mCursor.moveToNext());
+ } while (cursor.moveToNext());
}
// Close the cursor
- if (mCursor != null) {
- mCursor.close();
- mCursor = null;
+ if (cursor != null) {
+ cursor.close();
+ cursor = null;
}
return mPlaylistList;
}
private final ArrayList<Song> mSongList = Lists.newArrayList();
/**
- * The {@link Cursor} used to run the query.
- */
- private Cursor mCursor;
-
- /**
* The Id of the playlist the songs belong to.
*/
private final long mPlaylistID;
final int playlistCount = countPlaylist(getContext(), mPlaylistID);
// Create the Cursor
- mCursor = makePlaylistSongCursor(getContext(), mPlaylistID);
+ Cursor cursor = makePlaylistSongCursor(getContext(), mPlaylistID);
- if (mCursor != null) {
+ if (cursor != null) {
boolean runCleanup = false;
// if the raw playlist count differs from the mapped playlist count (ie the raw mapping
// table vs the mapping table join the audio table) that means the playlist mapping table
// is messed up
- if (mCursor.getCount() != playlistCount) {
+ if (cursor.getCount() != playlistCount) {
Log.w(TAG, "Count Differs - raw is: " + playlistCount + " while cursor is " +
- mCursor.getCount());
+ cursor.getCount());
runCleanup = true;
}
// check if the play order is already messed up by duplicates
- if (!runCleanup && mCursor.moveToFirst()) {
- final int playOrderCol = mCursor.getColumnIndexOrThrow(Playlists.Members.PLAY_ORDER);
+ if (!runCleanup && cursor.moveToFirst()) {
+ final int playOrderCol = cursor.getColumnIndexOrThrow(Playlists.Members.PLAY_ORDER);
int lastPlayOrder = -1;
do {
- int playOrder = mCursor.getInt(playOrderCol);
+ int playOrder = cursor.getInt(playOrderCol);
// if we have duplicate play orders, we need to recreate the playlist
if (playOrder == lastPlayOrder) {
runCleanup = true;
break;
}
lastPlayOrder = playOrder;
- } while (mCursor.moveToNext());
+ } while (cursor.moveToNext());
}
if (runCleanup) {
Log.w(TAG, "Playlist order has flaws - recreating playlist");
// cleanup the playlist
- cleanupPlaylist(getContext(), mPlaylistID, mCursor);
+ cleanupPlaylist(getContext(), mPlaylistID, cursor);
// create a new cursor
- mCursor.close();
- mCursor = makePlaylistSongCursor(getContext(), mPlaylistID);
- if (mCursor != null) {
- Log.d(TAG, "New Count is: " + mCursor.getCount());
+ cursor.close();
+ cursor = makePlaylistSongCursor(getContext(), mPlaylistID);
+ if (cursor != null) {
+ Log.d(TAG, "New Count is: " + cursor.getCount());
}
}
}
// Gather the data
- if (mCursor != null && mCursor.moveToFirst()) {
+ if (cursor != null && cursor.moveToFirst()) {
do {
// Copy the song Id
- final long id = mCursor.getLong(mCursor
+ final long id = cursor.getLong(cursor
.getColumnIndexOrThrow(MediaStore.Audio.Playlists.Members.AUDIO_ID));
// Copy the song name
- final String songName = mCursor.getString(mCursor
+ final String songName = cursor.getString(cursor
.getColumnIndexOrThrow(AudioColumns.TITLE));
// Copy the artist name
- final String artist = mCursor.getString(mCursor
+ final String artist = cursor.getString(cursor
.getColumnIndexOrThrow(AudioColumns.ARTIST));
// Copy the album id
- final long albumId = mCursor.getLong(mCursor
+ final long albumId = cursor.getLong(cursor
.getColumnIndexOrThrow(AudioColumns.ALBUM_ID));
// Copy the album name
- final String album = mCursor.getString(mCursor
+ final String album = cursor.getString(cursor
.getColumnIndexOrThrow(AudioColumns.ALBUM));
// Copy the duration
- final long duration = mCursor.getLong(mCursor
+ final long duration = cursor.getLong(cursor
.getColumnIndexOrThrow(AudioColumns.DURATION));
// Convert the duration into seconds
final int durationInSecs = (int) duration / 1000;
// Grab the Song Year
- final int year = mCursor.getInt(mCursor
+ final int year = cursor.getInt(cursor
.getColumnIndexOrThrow(AudioColumns.YEAR));
// Create a new song
// Add everything up
mSongList.add(song);
- } while (mCursor.moveToNext());
+ } while (cursor.moveToNext());
}
// Close the cursor
- if (mCursor != null) {
- mCursor.close();
- mCursor = null;
+ if (cursor != null) {
+ cursor.close();
+ cursor = null;
}
return mSongList;
}
private final ArrayList<Song> mSongList = Lists.newArrayList();
/**
- * The {@link Cursor} used to run the query.
- */
- private NowPlayingCursor mCursor;
-
- /**
* Constructor of <code>QueueLoader</code>
*
* @param context The {@link Context} to use
@Override
public List<Song> loadInBackground() {
// Create the Cursor
- mCursor = new NowPlayingCursor(getContext());
+ NowPlayingCursor cursor = new NowPlayingCursor(getContext());
// Gather the data
- if (mCursor != null && mCursor.moveToFirst()) {
+ if (cursor != null && cursor.moveToFirst()) {
do {
// Copy the song Id
- final long id = mCursor.getLong(0);
+ final long id = cursor.getLong(0);
// Copy the song name
- final String songName = mCursor.getString(1);
+ final String songName = cursor.getString(1);
// Copy the artist name
- final String artist = mCursor.getString(2);
+ final String artist = cursor.getString(2);
// Copy the album id
- final long albumId = mCursor.getLong(3);
+ final long albumId = cursor.getLong(3);
// Copy the album name
- final String album = mCursor.getString(4);
+ final String album = cursor.getString(4);
// Copy the duration
- final long duration = mCursor.getLong(5);
+ final long duration = cursor.getLong(5);
// Convert the duration into seconds
final int durationInSecs = (int) duration / 1000;
// Copy the year
- final int year = mCursor.getInt(6);
+ final int year = cursor.getInt(6);
// Create a new song
final Song song = new Song(id, songName, artist, album, albumId, durationInSecs, year);
// Add everything up
mSongList.add(song);
- } while (mCursor.moveToNext());
+ } while (cursor.moveToNext());
}
// Close the cursor
- if (mCursor != null) {
- mCursor.close();
- mCursor = null;
+ if (cursor != null) {
+ cursor.close();
+ cursor = null;
}
return mSongList;
}
private final ArrayList<Song> mSongList = Lists.newArrayList();
/**
- * The {@link Cursor} used to run the query.
+ * The query
*/
- private Cursor mCursor;
+ private String mQuery;
/**
* Constructor of <code>SongLoader</code>
*/
public SearchLoader(final Context context, final String query) {
super(context);
- // Create the Cursor
- mCursor = makeSearchCursor(context, query);
+ mQuery = query;
}
/**
@Override
public List<Song> loadInBackground() {
// Gather the data
- if (mCursor != null && mCursor.moveToFirst()) {
+ Cursor cursor = makeSearchCursor(getContext(), mQuery);
+ if (cursor != null && cursor.moveToFirst()) {
do {
// Copy the song Id
long id = -1;
// Copy the song name
- final String songName = mCursor.getString(mCursor
+ final String songName = cursor.getString(cursor
.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE));
// Check for a song Id
if (!TextUtils.isEmpty(songName)) {
- id = mCursor.getLong(mCursor
+ id = cursor.getLong(cursor
.getColumnIndexOrThrow(MediaStore.Audio.Media._ID));
}
// Copy the album name
- final String album = mCursor.getString(mCursor
+ final String album = cursor.getString(cursor
.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
// Copy the album id
- final long albumId = mCursor.getLong(mCursor
+ final long albumId = cursor.getLong(cursor
.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM_ID));
// Check for a album Id
if (id < 0 && !TextUtils.isEmpty(album)) {
- id = mCursor.getLong(mCursor
+ id = cursor.getLong(cursor
.getColumnIndexOrThrow(MediaStore.Audio.Albums._ID));
}
// Copy the artist name
- final String artist = mCursor.getString(mCursor
+ final String artist = cursor.getString(cursor
.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
// Check for a artist Id
if (id < 0 && !TextUtils.isEmpty(artist)) {
- id = mCursor.getLong(mCursor
+ id = cursor.getLong(cursor
.getColumnIndexOrThrow(MediaStore.Audio.Artists._ID));
}
// Add everything up
mSongList.add(song);
- } while (mCursor.moveToNext());
+ } while (cursor.moveToNext());
}
// Close the cursor
- if (mCursor != null) {
- mCursor.close();
- mCursor = null;
+ if (cursor != null) {
+ cursor.close();
+ cursor = null;
}
return mSongList;
}
protected ArrayList<Song> mSongList = Lists.newArrayList();
/**
- * The {@link Cursor} used to run the query.
- */
- protected Cursor mCursor;
-
- /**
* Additional selection filter
*/
protected String mSelection;
@Override
public List<Song> loadInBackground() {
// Create the Cursor
- mCursor = getCursor();
+ Cursor cursor = getCursor();
// Gather the data
- if (mCursor != null && mCursor.moveToFirst()) {
+ if (cursor != null && cursor.moveToFirst()) {
do {
// Copy the song Id
- final long id = mCursor.getLong(0);
+ final long id = cursor.getLong(0);
// Copy the song name
- final String songName = mCursor.getString(1);
+ final String songName = cursor.getString(1);
// Copy the artist name
- final String artist = mCursor.getString(2);
+ final String artist = cursor.getString(2);
// Copy the album id
- final long albumId = mCursor.getLong(3);
+ final long albumId = cursor.getLong(3);
// Copy the album name
- final String album = mCursor.getString(4);
+ final String album = cursor.getString(4);
// Copy the duration
- final long duration = mCursor.getLong(5);
+ final long duration = cursor.getLong(5);
// Convert the duration into seconds
final int durationInSecs = (int) duration / 1000;
// Copy the Year
- final int year = mCursor.getInt(6);
+ final int year = cursor.getInt(6);
// Create a new song
final Song song = new Song(id, songName, artist, album, albumId,
durationInSecs, year);
- if (mCursor instanceof SortedCursor) {
- song.mBucketLabel = (String)((SortedCursor)mCursor).getExtraData();
+ if (cursor instanceof SortedCursor) {
+ song.mBucketLabel = (String)((SortedCursor)cursor).getExtraData();
}
mSongList.add(song);
- } while (mCursor.moveToNext());
+ } while (cursor.moveToNext());
}
// Close the cursor
- if (mCursor != null) {
- mCursor.close();
- mCursor = null;
+ if (cursor != null) {
+ cursor.close();
+ cursor = null;
}
return mSongList;