Skip to content

Commit

Permalink
null pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
cqr committed Aug 1, 2014
1 parent c5c3d58 commit 535cbda
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
1 change: 0 additions & 1 deletion build.gradle
Expand Up @@ -24,7 +24,6 @@ android {
}
}


//task packageSources(type: Jar) {
// from android.sourceSets.main.allJava
// classifier = 'sources'
Expand Down
22 changes: 18 additions & 4 deletions src/main/java/org/prx/playerhater/plugins/NotificationPlugin.java
Expand Up @@ -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
Expand All @@ -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();
}
Expand All @@ -135,6 +145,10 @@ protected void updateNotification() {
}

protected ServicePlayerHater getBinder() {
return (ServicePlayerHater) getPlayerHater();
try {
return (ServicePlayerHater) getPlayerHater();
} catch (IllegalStateException exception) {
return null;
}
}
}
Expand Up @@ -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:
Expand Down

0 comments on commit 535cbda

Please sign in to comment.