Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

null pointers

  • Loading branch information...
commit 535cbda6cd150f317668c9bc062baaadc387dea6 1 parent c5c3d58
@chrisrhoden chrisrhoden authored
View
1  build.gradle
@@ -24,7 +24,6 @@ android {
}
}
-
//task packageSources(type: Jar) {
// from android.sourceSets.main.allJava
// classifier = 'sources'
View
22 src/main/java/org/prx/playerhater/plugins/NotificationPlugin.java
@@ -98,7 +98,10 @@ public void onAudioStopped() {
mIsVisible = false;
mNotificationManager.cancel(NOTIFICATION_NU);
mNotification = null;
- getBinder().stopForeground(true);
+ ServicePlayerHater binder = getBinder();
+ if (binder != null) {
+ binder.stopForeground(true);
+ }
}
@Override
@@ -120,11 +123,18 @@ public void onArtistChanged(String notificationText) {
@Override
public void onChangesComplete() {
+ ServicePlayerHater binder;
if (mShouldBeVisible && !mIsVisible) {
- getBinder().startForeground(NOTIFICATION_NU, getNotification());
+ binder = getBinder();
+ if (binder != null) {
+ binder.startForeground(NOTIFICATION_NU, getNotification());
+ }
mIsVisible = true;
} else if (mIsVisible && !mShouldBeVisible) {
- getBinder().stopForeground(true);
+ binder = getBinder();
+ if (binder != null) {
+ binder.stopForeground(true);
+ }
} else if (mIsVisible && mShouldBeVisible) {
updateNotification();
}
@@ -135,6 +145,10 @@ protected void updateNotification() {
}
protected ServicePlayerHater getBinder() {
- return (ServicePlayerHater) getPlayerHater();
+ try {
+ return (ServicePlayerHater) getPlayerHater();
+ } catch (IllegalStateException exception) {
+ return null;
+ }
}
}
View
6 src/main/java/org/prx/playerhater/service/PlayerStateWatcher.java
@@ -63,7 +63,11 @@ public synchronized void onStateChanged(Player mediaPlayer, int state) {
boolean willPlay = StatelyPlayer.willPlay(state);
boolean seekable = StatelyPlayer.seekable(state);
state = StatelyPlayer.mediaPlayerState(state);
- setCurrentDuration(mediaPlayer.getDuration());
+ if (mediaPlayer != null) {
+ setCurrentDuration(mediaPlayer.getDuration());
+ } else {
+ setCurrentDuration(0);
+ }
switch (state) {
case StatelyPlayer.END:
Please sign in to comment.
Something went wrong with that request. Please try again.