From d2a8aeeb343ae0be833370f71127da4240f28c64 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Fri, 13 Dec 2013 00:57:18 +0100 Subject: [PATCH] Fixed crash when exiting app during playback. --- src/com/github/nutomic/controldlna/gui/RouteFragment.java | 4 ++++ .../controldlna/mediarouter/MediaRouterPlayService.java | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/com/github/nutomic/controldlna/gui/RouteFragment.java b/src/com/github/nutomic/controldlna/gui/RouteFragment.java index 67d735e..c9a0d93 100644 --- a/src/com/github/nutomic/controldlna/gui/RouteFragment.java +++ b/src/com/github/nutomic/controldlna/gui/RouteFragment.java @@ -463,6 +463,10 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements * Receives information from MediaRouterPlayService about playback status. */ public void receivePlaybackStatus(MediaItemStatus status) { + // Views may not exist if fragment was just created/destroyed. + if (getView() == null) + return; + int currentTime = (int) status.getContentPosition() / 1000; int totalTime = (int) status.getContentDuration() / 1000; diff --git a/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java b/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java index 4485c5a..706fadc 100644 --- a/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java +++ b/src/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java @@ -315,7 +315,9 @@ public class MediaRouterPlayService extends Service { @Override public void onResult(Bundle data) { MediaItemStatus status = MediaItemStatus.fromBundle(data); - + if (status == null) + return; + if (mRouterFragment.get() != null) mRouterFragment.get().receivePlaybackStatus(status); if (status.getPlaybackState() != MediaItemStatus.PLAYBACK_STATE_PENDING &&