aboutsummaryrefslogtreecommitdiff
path: root/src/github/daneren2005
diff options
context:
space:
mode:
Diffstat (limited to 'src/github/daneren2005')
-rw-r--r--src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java16
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java5
-rw-r--r--src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java9
3 files changed, 24 insertions, 6 deletions
diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
index 54db1b91..7f267f28 100644
--- a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
+++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
@@ -563,9 +563,9 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
}
// If we had a remote state and it's changed is more recent than our existing state
- if(remoteState != null) {
+ if(remoteState != null && remoteState.changed != null) {
Date localChange = downloadService.getLastStateChanged();
- if(localChange == null || localChange.after(remoteState.changed)) {
+ if(localChange == null || localChange.before(remoteState.changed)) {
playerQueue = remoteState;
}
}
@@ -598,6 +598,18 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
}
}.execute();
}
+ }, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ DownloadService downloadService = getDownloadService();
+ downloadService.serializeQueue(false);
+ return null;
+ }
+ }.execute();
+ }
});
}
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java
index fb899ee8..6767e95e 100644
--- a/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/src/github/daneren2005/dsub/service/DownloadService.java
@@ -1818,8 +1818,11 @@ public class DownloadService extends Service {
}
public synchronized void serializeQueue() {
+ serializeQueue(true);
+ }
+ public synchronized void serializeQueue(boolean serializeRemote) {
if(playerState == PlayerState.PAUSED) {
- lifecycleSupport.serializeDownloadQueue();
+ lifecycleSupport.serializeDownloadQueue(serializeRemote);
}
}
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
index 31844210..ca103332 100644
--- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
+++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
@@ -259,6 +259,9 @@ public class DownloadServiceLifecycleSupport {
}
public void serializeDownloadQueue() {
+ serializeDownloadQueue(true);
+ }
+ public void serializeDownloadQueue(final boolean serializeRemote) {
if(!setup.get()) {
return;
}
@@ -269,7 +272,7 @@ public class DownloadServiceLifecycleSupport {
public void run() {
if(lock.tryLock()) {
try {
- serializeDownloadQueueNow(songs);
+ serializeDownloadQueueNow(songs, serializeRemote);
} finally {
lock.unlock();
}
@@ -278,7 +281,7 @@ public class DownloadServiceLifecycleSupport {
});
}
- public void serializeDownloadQueueNow(List<DownloadFile> songs) {
+ public void serializeDownloadQueueNow(List<DownloadFile> songs, boolean serializeRemote) {
final PlayerQueue state = new PlayerQueue();
for (DownloadFile downloadFile : songs) {
state.songs.add(downloadFile.getSong());
@@ -299,7 +302,7 @@ public class DownloadServiceLifecycleSupport {
FileUtil.serialize(downloadService, state, FILENAME_DOWNLOADS_SER);
// If we are on Subsonic 5.2+, save play queue
- if(ServerInfo.canSavePlayQueue(downloadService) && !Util.isOffline(downloadService) && state.songs.size() > 0) {
+ if(serializeRemote && ServerInfo.canSavePlayQueue(downloadService) && !Util.isOffline(downloadService) && state.songs.size() > 0) {
// Cancel any currently running tasks
if(currentSavePlayQueueTask != null) {
currentSavePlayQueueTask.cancel();