Save song flags in state

This commit is contained in:
Christopher Eby 2010-04-11 15:27:48 -05:00
parent 635d378c59
commit a13f7a7107
3 changed files with 19 additions and 6 deletions

View File

@ -127,7 +127,7 @@ public class PlaybackService extends Service implements Handler.Callback, MediaP
mPendingSeek = state.savedSeek;
for (int i = 0; i != state.savedIds.length; ++i)
mSongTimeline.add(new Song(state.savedIds[i]));
mSongTimeline.add(new Song(state.savedIds[i], state.savedFlags[i]));
} else {
mSongTimeline = new ArrayList<Song>();
}

View File

@ -29,10 +29,11 @@ import android.util.Log;
public class PlaybackServiceState {
private static final String STATE_FILE = "state";
private static final long STATE_FILE_MAGIC = 0x8a9d3f9fca31L;
private static final long STATE_FILE_MAGIC = 0x8a9d3f2fca31L;
public int savedIndex;
public long[] savedIds;
public int[] savedFlags;
public int savedSeek;
public boolean load(Context context)
@ -45,8 +46,11 @@ public class PlaybackServiceState {
if (n > 0) {
savedIds = new long[n];
for (int i = 0; i != n; ++i)
savedFlags = new int[n];
for (int i = 0; i != n; ++i) {
savedIds[i] = in.readLong();
savedFlags[i] = in.readInt();
}
savedSeek = in.readInt();
return true;
@ -70,12 +74,15 @@ public class PlaybackServiceState {
out.writeInt(index);
int n = songs == null ? 0 : songs.size();
out.writeInt(n);
for (int i = 0; i != n; ++i)
out.writeLong(songs.get(i).id);
for (int i = 0; i != n; ++i) {
Song song = songs.get(i);
out.writeLong(song.id);
out.writeInt(song.flags);
}
out.writeInt(seek);
out.close();
} catch (IOException e) {
Log.w("VanillaMusic", e);
}
}
}
}

View File

@ -58,6 +58,12 @@ public class Song implements Parcelable {
this.id = id;
}
public Song(long id, int flags)
{
this.id = id;
this.flags = flags;
}
public boolean populate(boolean force)
{
if (path != null && !force)