aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/github/daneren2005/dsub/service/DownloadFile.java10
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java23
2 files changed, 20 insertions, 13 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadFile.java b/src/github/daneren2005/dsub/service/DownloadFile.java
index 646556df..c7b66f8f 100644
--- a/src/github/daneren2005/dsub/service/DownloadFile.java
+++ b/src/github/daneren2005/dsub/service/DownloadFile.java
@@ -319,7 +319,7 @@ public class DownloadFile implements BufferFile {
return "DownloadFile (" + song + ")";
}
- private class DownloadTask extends SilentBackgroundTask {
+ private class DownloadTask extends SilentBackgroundTask<Void> {
private MusicService musicService;
public DownloadTask(Context context) {
@@ -327,7 +327,7 @@ public class DownloadFile implements BufferFile {
}
@Override
- public void doInBackground() {
+ public Void doInBackground() {
InputStream in = null;
FileOutputStream out = null;
@@ -347,7 +347,7 @@ public class DownloadFile implements BufferFile {
if (saveFile.exists()) {
Log.i(TAG, saveFile + " already exists. Skipping.");
- return;
+ return null;
}
if (completeFile.exists()) {
if (save) {
@@ -359,7 +359,7 @@ public class DownloadFile implements BufferFile {
} else {
Log.i(TAG, completeFile + " already exists. Skipping.");
}
- return;
+ return null;
}
if(musicService == null) {
@@ -447,6 +447,8 @@ public class DownloadFile implements BufferFile {
((DownloadService) DownloadService.getInstance()).checkDownloads();
}
}
+
+ return null;
}
@Override
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java
index da542ed7..799b1fb3 100644
--- a/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/src/github/daneren2005/dsub/service/DownloadService.java
@@ -116,8 +116,8 @@ public class DownloadService extends Service {
private int currentPlayingIndex = -1;
private DownloadFile nextPlaying;
private DownloadFile currentDownloading;
- private CancellableTask bufferTask;
- private CancellableTask nextPlayingTask;
+ private SilentBackgroundTask bufferTask;
+ private SilentBackgroundTask nextPlayingTask;
private PlayerState playerState = IDLE;
private PlayerState nextPlayerState = IDLE;
private boolean shufflePlay;
@@ -1659,7 +1659,7 @@ public class DownloadService extends Service {
}
}
- private class BufferTask extends SilentBackgroundTask {
+ private class BufferTask extends SilentBackgroundTask<Void> {
private final DownloadFile downloadFile;
private final int position;
private final long expectedFileSize;
@@ -1667,6 +1667,7 @@ public class DownloadService extends Service {
private final boolean start;
public BufferTask(DownloadFile downloadFile, int position, boolean start) {
+ super(instance);
this.downloadFile = downloadFile;
this.position = position;
partialFile = downloadFile.getPartialFile();
@@ -1682,16 +1683,18 @@ public class DownloadService extends Service {
}
@Override
- public void doInBackground() {
+ public Void doInBackground() {
setPlayerState(DOWNLOADING);
while (!bufferComplete()) {
Util.sleepQuietly(1000L);
if (isCancelled()) {
- return;
+ return null;
}
}
doPlay(downloadFile, position, start);
+
+ return null;
}
private boolean bufferComplete() {
@@ -1708,11 +1711,12 @@ public class DownloadService extends Service {
}
}
- private class CheckCompletionTask extends SilentBackgroundTask {
+ private class CheckCompletionTask extends SilentBackgroundTask<Void> {
private final DownloadFile downloadFile;
private final File partialFile;
public CheckCompletionTask(DownloadFile downloadFile) {
+ super(instance);
this.downloadFile = downloadFile;
if(downloadFile != null) {
partialFile = downloadFile.getPartialFile();
@@ -1722,9 +1726,9 @@ public class DownloadService extends Service {
}
@Override
- public void doInBackground() {
+ public Void doInBackground() {
if(downloadFile == null) {
- return;
+ return null;
}
// Do an initial sleep so this prepare can't compete with main prepare
@@ -1732,7 +1736,7 @@ public class DownloadService extends Service {
while (!bufferComplete()) {
Util.sleepQuietly(5000L);
if (isCancelled()) {
- return;
+ return null;
}
}
@@ -1742,6 +1746,7 @@ public class DownloadService extends Service {
setupNext(downloadFile);
}
});
+ return null;
}
private boolean bufferComplete() {