Handle randomization of broken songs correctly

The old code didn't update the song in the timeline, which lead to some
interesting issues.
This commit is contained in:
Christopher Eby 2010-07-25 14:03:00 -05:00
parent 7156d11ea1
commit 338974def5
2 changed files with 22 additions and 1 deletions

View File

@ -171,6 +171,27 @@ public class Song implements Parcelable {
albumId = cursor.getLong(5);
}
/**
* Copies the fields from the given Song to this Song.
*
* @param other The Song to copy from.
*/
public void copy(Song other)
{
if (other == null) {
id = -1;
return;
}
id = other.id;
albumId = other.albumId;
path = other.path;
title = other.title;
album = other.album;
artist = other.artist;
flags = other.flags;
}
/**
* Query the MediaStore, if necessary, to fill this Song's fields.
*

View File

@ -329,7 +329,7 @@ public final class SongTimeline {
}
if (song == null || !song.query(false)) {
song = Song.randomSong();
song.copy(Song.randomSong());
if (song == null || !song.query(false))
return null;
}