aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-07-18 19:17:59 -0700
committerScott Jackson <daneren2005@gmail.com>2015-07-18 19:17:59 -0700
commit4c288ccf28d01bd4ff22ebf831074e94db1c917d (patch)
tree1fe8d25a261cf61226d08f1c104cea060c063306 /app
parent441ec41cf93ec70aafba98a3c669ca3b61fd0c45 (diff)
downloaddsub-4c288ccf28d01bd4ff22ebf831074e94db1c917d.tar.gz
dsub-4c288ccf28d01bd4ff22ebf831074e94db1c917d.tar.bz2
dsub-4c288ccf28d01bd4ff22ebf831074e94db1c917d.zip
Make sure revision has changed since event was posted
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadService.java27
1 files changed, 19 insertions, 8 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 cd22fb69..ab757c59 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
@@ -603,10 +603,6 @@ public class DownloadService extends Service {
return downloadFile;
}
- public synchronized void clear() {
- clear(true);
- }
-
public synchronized void clearBackground() {
if(currentDownloading != null && backgroundDownloadList.contains(currentDownloading)) {
currentDownloading.cancelDownload();
@@ -668,6 +664,9 @@ public class DownloadService extends Service {
return downloadList.size();
}
+ public synchronized void clear() {
+ clear(true);
+ }
public synchronized void clear(boolean serialize) {
// Delete podcast if fully listened to
int position = getPlayerPosition();
@@ -2375,43 +2374,55 @@ public class DownloadService extends Service {
}
private void onSongChanged() {
+ final long atRevision = revision;
for(final OnSongChangedListener listener: onSongChangedListeners) {
handler.post(new Runnable() {
@Override
public void run() {
- listener.onSongChanged(currentPlaying, currentPlayingIndex);
+ if(revision == atRevision) {
+ listener.onSongChanged(currentPlaying, currentPlayingIndex);
+ }
}
});
}
}
private void onSongsChanged() {
+ final long atRevision = revision;
for(final OnSongChangedListener listener: onSongChangedListeners) {
handler.post(new Runnable() {
@Override
public void run() {
- listener.onSongsChanged(downloadList, currentPlaying, currentPlayingIndex);
+ if(revision == atRevision) {
+ listener.onSongsChanged(downloadList, currentPlaying, currentPlayingIndex);
+ }
}
});
}
}
private void onSongProgress() {
+ final long atRevision = revision;
final Integer duration = getPlayerDuration();
final boolean isSeekable = isSeekable();
for(final OnSongChangedListener listener: onSongChangedListeners) {
handler.post(new Runnable() {
@Override
public void run() {
- listener.onSongProgress(currentPlaying, cachedPosition, duration, isSeekable);
+ if(revision == atRevision) {
+ listener.onSongProgress(currentPlaying, cachedPosition, duration, isSeekable);
+ }
}
});
}
}
private void onStateUpdate() {
+ final long atRevision = revision;
for(final OnSongChangedListener listener: onSongChangedListeners) {
handler.post(new Runnable() {
@Override
public void run() {
- listener.onStateUpdate(currentPlaying, playerState);
+ if(revision == atRevision) {
+ listener.onStateUpdate(currentPlaying, playerState);
+ }
}
});
}