Fixed crash on screen rotation in playlist view.

This commit is contained in:
Felix Ableitner 2014-02-01 22:24:24 +01:00
parent 8b9359ba4f
commit b037a17f2a
2 changed files with 8 additions and 4 deletions

View file

@ -97,6 +97,8 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements
private boolean mPlaying; private boolean mPlaying;
private boolean mRestorePlaylistMode;
private RouteAdapter mRouteAdapter; private RouteAdapter mRouteAdapter;
private FileArrayAdapter mPlaylistAdapter; private FileArrayAdapter mPlaylistAdapter;
@ -124,6 +126,8 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements
mPlaylistAdapter.add(mMediaRouterPlayService.getService().getPlaylist()); mPlaylistAdapter.add(mMediaRouterPlayService.getService().getPlaylist());
receiveIsPlaying(mMediaRouterPlayService.getService().getCurrentTrack()); receiveIsPlaying(mMediaRouterPlayService.getService().getCurrentTrack());
applyColors(); applyColors();
if (mRestorePlaylistMode)
playlistMode(mMediaRouterPlayService.getService().getCurrentRoute());
} }
public void onServiceDisconnected(ComponentName className) { public void onServiceDisconnected(ComponentName className) {
@ -203,9 +207,7 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements
if (savedInstanceState != null) { if (savedInstanceState != null) {
mListView.onRestoreInstanceState(savedInstanceState.getParcelable("list_state")); mListView.onRestoreInstanceState(savedInstanceState.getParcelable("list_state"));
if (savedInstanceState.getBoolean("route_selected")) mRestorePlaylistMode = savedInstanceState.getBoolean("route_selected");
playlistMode(MediaRouter.getInstance(getActivity())
.getSelectedRoute());
} }
} }

View file

@ -156,7 +156,6 @@ public class MediaRouterPlayService extends Service {
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
mMediaRouter = MediaRouter.getInstance(this); mMediaRouter = MediaRouter.getInstance(this);
pollStatus(); pollStatus();
} }
@ -438,4 +437,7 @@ public class MediaRouterPlayService extends Service {
return mRepeat; return mRepeat;
} }
public RouteInfo getCurrentRoute() {
return mCurrentRoute;
}
} }