aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2012-10-17 19:15:53 -0700
committerScott Jackson <daneren2005@gmail.com>2012-10-17 19:15:53 -0700
commit055941814c5d52ee9690347febb4f1c8cd6a962e (patch)
treef272e99192e345feaba1d9f137bbd3503db6b81f
parente679663bae4f904404c69f7b0c4460bad993cd8e (diff)
downloaddsub-055941814c5d52ee9690347febb4f1c8cd6a962e.tar.gz
dsub-055941814c5d52ee9690347febb4f1c8cd6a962e.tar.bz2
dsub-055941814c5d52ee9690347febb4f1c8cd6a962e.zip
Fix background downloading when now playing list is empty
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java43
1 files changed, 22 insertions, 21 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
index 87ffb629..ac989a68 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
@@ -886,6 +886,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
}
protected synchronized void checkDownloads() {
+ Log.d(TAG, "Start");
if (!Util.isExternalStoragePresent() || !lifecycleSupport.isExternalStorageAvailable()) {
return;
}
@@ -901,6 +902,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
if (downloadList.isEmpty() && backgroundDownloadList.isEmpty()) {
return;
}
+ Log.d(TAG, "Past Check");
// Need to download current playing?
if (currentPlaying != null && currentPlaying != currentDownloading && !currentPlaying.isCompleteFileAvailable()) {
@@ -917,32 +919,31 @@ public class DownloadServiceImpl extends Service implements DownloadService {
// Find a suitable target for download.
else if (currentDownloading == null || currentDownloading.isWorkDone() || currentDownloading.isFailed() && (!downloadList.isEmpty() || !backgroundDownloadList.isEmpty())) {
int n = size();
- if (n == 0) {
- return;
- }
int preloaded = 0;
- int start = currentPlaying == null ? 0 : getCurrentPlayingIndex();
- int i = start;
- do {
- DownloadFile downloadFile = downloadList.get(i);
- if (!downloadFile.isWorkDone()) {
- if (downloadFile.shouldSave() || preloaded < Util.getPreloadCount(this)) {
- currentDownloading = downloadFile;
- currentDownloading.download();
- cleanupCandidates.add(currentDownloading);
- break;
- }
- } else if (currentPlaying != downloadFile) {
- preloaded++;
- }
+ if(n != 0) {
+ int start = currentPlaying == null ? 0 : getCurrentPlayingIndex();
+ int i = start;
+ do {
+ DownloadFile downloadFile = downloadList.get(i);
+ if (!downloadFile.isWorkDone()) {
+ if (downloadFile.shouldSave() || preloaded < Util.getPreloadCount(this)) {
+ currentDownloading = downloadFile;
+ currentDownloading.download();
+ cleanupCandidates.add(currentDownloading);
+ break;
+ }
+ } else if (currentPlaying != downloadFile) {
+ preloaded++;
+ }
- i = (i + 1) % n;
- } while (i != start);
+ i = (i + 1) % n;
+ } while (i != start);
+ }
- if((preloaded + 1 == n || preloaded >= Util.getPreloadCount(this)) && !backgroundDownloadList.isEmpty()) {
- for(i = 0; i < backgroundDownloadList.size(); i++) {
+ if((preloaded + 1 == n || preloaded >= Util.getPreloadCount(this) || downloadList.isEmpty()) && !backgroundDownloadList.isEmpty()) {
+ for(int i = 0; i < backgroundDownloadList.size(); i++) {
DownloadFile downloadFile = backgroundDownloadList.get(i);
if(downloadFile.isWorkDone()) {
// Don't need to keep list like active song list