Avoid race during fragment creation
onTimelineChanged() is not always called on creation, but setSong() is
This commit is contained in:
parent
62d83dbf32
commit
f4cbd1053e
@ -72,7 +72,9 @@ public class ShowQueueFragment extends Fragment
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
// Check if playback service has already been created
|
// Get playback service if we can and must
|
||||||
|
// This happens eg. during a rotate where the view
|
||||||
|
// was destroyed
|
||||||
if (mService == null && PlaybackService.hasInstance())
|
if (mService == null && PlaybackService.hasInstance())
|
||||||
mService = PlaybackService.get(getActivity());
|
mService = PlaybackService.get(getActivity());
|
||||||
|
|
||||||
@ -210,10 +212,24 @@ public class ShowQueueFragment extends Fragment
|
|||||||
mListView.setSelectionFromTop(currentSongPosition, 0); /* scroll to currently playing song */
|
mListView.setSelectionFromTop(currentSongPosition, 0); /* scroll to currently playing song */
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used Callbacks of TImelineCallback
|
/**
|
||||||
public void onTimelineChanged() {
|
* Called after a song has been set.
|
||||||
if (mService == null)
|
* We are only interested in this call if mService is null
|
||||||
|
* as this signals that the playback service just became ready
|
||||||
|
* (and wasn't during onResume())
|
||||||
|
*/
|
||||||
|
public void setSong(long uptime, Song song) {
|
||||||
|
if (mService == null) {
|
||||||
mService = PlaybackService.get(getActivity());
|
mService = PlaybackService.get(getActivity());
|
||||||
|
onTimelineChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after the timeline changed
|
||||||
|
*/
|
||||||
|
public void onTimelineChanged() {
|
||||||
|
if (mService != null)
|
||||||
refreshSongQueueList(false);
|
refreshSongQueueList(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,8 +242,6 @@ public class ShowQueueFragment extends Fragment
|
|||||||
}
|
}
|
||||||
public void replaceSong(int delta, Song song) {
|
public void replaceSong(int delta, Song song) {
|
||||||
}
|
}
|
||||||
public void setSong(long uptime, Song song) {
|
|
||||||
}
|
|
||||||
public void setState(long uptime, int state) {
|
public void setState(long uptime, int state) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user