From b037a17f2ab0cfa5dfba3125c849f526cb681baf Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sat, 1 Feb 2014 22:24:24 +0100 Subject: [PATCH] Fixed crash on screen rotation in playlist view. --- src/com/github/nutomic/controldlna/gui/RouteFragment.java | 8 +++++--- .../controldlna/mediarouter/MediaRouterPlayService.java | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/com/github/nutomic/controldlna/gui/RouteFragment.java b/src/com/github/nutomic/controldlna/gui/RouteFragment.java index 57df561..6f1dd39 100644 --- a/src/com/github/nutomic/controldlna/gui/RouteFragment.java +++ b/src/com/github/nutomic/controldlna/gui/RouteFragment.java @@ -97,6 +97,8 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements private boolean mPlaying; + private boolean mRestorePlaylistMode; + private RouteAdapter mRouteAdapter; private FileArrayAdapter mPlaylistAdapter; @@ -124,6 +126,8 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements mPlaylistAdapter.add(mMediaRouterPlayService.getService().getPlaylist()); receiveIsPlaying(mMediaRouterPlayService.getService().getCurrentTrack()); applyColors(); + if (mRestorePlaylistMode) + playlistMode(mMediaRouterPlayService.getService().getCurrentRoute()); } public void onServiceDisconnected(ComponentName className) { @@ -203,9 +207,7 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements if (savedInstanceState != null) { mListView.onRestoreInstanceState(savedInstanceState.getParcelable("list_state")); - if (savedInstanceState.getBoolean("route_selected")) - playlistMode(MediaRouter.getInstance(getActivity()) - .getSelectedRoute()); + mRestorePlaylistMode = savedInstanceState.getBoolean("route_selected"); } } diff --git a/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java b/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java index 4790ec6..10a6171 100644 --- a/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java +++ b/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java @@ -156,7 +156,6 @@ public class MediaRouterPlayService extends Service { @Override public void onCreate() { super.onCreate(); - mMediaRouter = MediaRouter.getInstance(this); pollStatus(); } @@ -438,4 +437,7 @@ public class MediaRouterPlayService extends Service { return mRepeat; } + public RouteInfo getCurrentRoute() { + return mCurrentRoute; + } }