diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-09-23 08:43:55 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-09-23 08:43:55 -0700 |
commit | 133aa31b1d36b9d7a7885fede29f0d3501e2c9ab (patch) | |
tree | 5ce1dc5211771359840b33f51128af75daca7928 /app/src | |
parent | 5bcff72003aa8922778ab0ca399dfc431d38f744 (diff) | |
download | dsub-133aa31b1d36b9d7a7885fede29f0d3501e2c9ab.tar.gz dsub-133aa31b1d36b9d7a7885fede29f0d3501e2c9ab.tar.bz2 dsub-133aa31b1d36b9d7a7885fede29f0d3501e2c9ab.zip |
Fix some random crashes
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/service/DownloadService.java | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java index f95a2785..6c73e8c1 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java @@ -2470,7 +2470,7 @@ public class DownloadService extends Service { } } - private void onSongChanged() { + private synchronized void onSongChanged() { final long atRevision = revision; for(final OnSongChangedListener listener: onSongChangedListeners) { handler.post(new Runnable() { @@ -2483,14 +2483,16 @@ public class DownloadService extends Service { }); } - mediaPlayerHandler.post(new Runnable() { - @Override - public void run() { - onSongProgress(); - } - }); + if(mediaPlayerHandler != null && !onSongChangedListeners.isEmpty()) { + mediaPlayerHandler.post(new Runnable() { + @Override + public void run() { + onSongProgress(); + } + }); + } } - private void onSongsChanged() { + private synchronized void onSongsChanged() { final long atRevision = revision; for(final OnSongChangedListener listener: onSongChangedListeners) { handler.post(new Runnable() { @@ -2503,7 +2505,7 @@ public class DownloadService extends Service { }); } } - private void onSongProgress() { + private synchronized void onSongProgress() { final long atRevision = revision; final Integer duration = getPlayerDuration(); final boolean isSeekable = isSeekable(); |