aboutsummaryrefslogtreecommitdiff
path: root/src/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-03-18 18:16:25 -0700
committerScott Jackson <daneren2005@gmail.com>2015-03-18 18:16:25 -0700
commit5f91cd3038577351752d25daadbdfdc16d595bc2 (patch)
tree5214eaa0d79437b2b488062cb739b3a675a8b3f3 /src/github
parent7e0f41a05329eb37d2e7c3de9ceb8ac9f4472ff4 (diff)
downloaddsub-5f91cd3038577351752d25daadbdfdc16d595bc2.tar.gz
dsub-5f91cd3038577351752d25daadbdfdc16d595bc2.tar.bz2
dsub-5f91cd3038577351752d25daadbdfdc16d595bc2.zip
Serialize queue when user presses cancel so they don't keep getting the prompt if they don't play anything else
Diffstat (limited to 'src/github')
-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();