diff options
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java | 24 | ||||
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java | 4 |
2 files changed, 25 insertions, 3 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java index 50283da6..46b6b47d 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java +++ b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java @@ -42,17 +42,27 @@ public class RemoteControlClientICS extends RemoteControlClientHelper { } public void unregister(final Context context) { - if (mRemoteControl != null) { - AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); - audioManager.unregisterRemoteControlClient(mRemoteControl); + if(mRemoteControl == null) { + return; } + + AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); + audioManager.unregisterRemoteControlClient(mRemoteControl); } public void setPlaybackState(final int state) { + if(mRemoteControl == null) { + return; + } + mRemoteControl.setPlaybackState(state); } public void updateMetadata(final Context context, final MusicDirectory.Entry currentSong) { + if(mRemoteControl == null) { + return; + } + if(imageLoader == null) { imageLoader = SubsonicActivity.getStaticImageLoader(context); } @@ -72,11 +82,19 @@ public class RemoteControlClientICS extends RemoteControlClientHelper { @Override public void registerRoute(MediaRouter router) { + if(mRemoteControl == null) { + return; + } + router.addRemoteControlClient(mRemoteControl); } @Override public void unregisterRoute(MediaRouter router) { + if(mRemoteControl == null) { + return; + } + router.removeRemoteControlClient(mRemoteControl); } diff --git a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java index c27df2ba..e61e9a47 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java +++ b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java @@ -43,6 +43,10 @@ public class RemoteControlClientJB extends RemoteControlClientICS { @Override public void setPlaybackState(final int state) { + if(mRemoteControl == null) { + return; + } + long position = -1; if(state == RemoteControlClient.PLAYSTATE_PLAYING || state == RemoteControlClient.PLAYSTATE_PAUSED) { position = downloadService.getPlayerPosition(); |