aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-05-12 08:34:49 -0700
committerScott Jackson <daneren2005@gmail.com>2015-05-12 08:34:49 -0700
commit1bab06f14458468b3d0e7e12ec87c0af7bcea678 (patch)
tree82648a12ca3ba1b7f14e43114182db919ee14cee /app/src
parent5946fbdd19ea48a68633d4750920a40fb8f2e961 (diff)
downloaddsub-1bab06f14458468b3d0e7e12ec87c0af7bcea678.tar.gz
dsub-1bab06f14458468b3d0e7e12ec87c0af7bcea678.tar.bz2
dsub-1bab06f14458468b3d0e7e12ec87c0af7bcea678.zip
Fix crashes if trying to use before properly initialized
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientICS.java24
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientJB.java4
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();