aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-12-10 07:54:04 -0800
committerScott Jackson <daneren2005@gmail.com>2013-12-10 07:54:04 -0800
commit1ec1bd6386ed3e0b62d28522f02232018386772f (patch)
tree4608d7539d38e8cbc87d4a8160fe1bc17812de71 /src
parenta0c2a21f81e2af5a03a51e1c25e99fcbe6b07839 (diff)
downloaddsub-1ec1bd6386ed3e0b62d28522f02232018386772f.tar.gz
dsub-1ec1bd6386ed3e0b62d28522f02232018386772f.tar.bz2
dsub-1ec1bd6386ed3e0b62d28522f02232018386772f.zip
Fix DownloadFile not using sync's service to download
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/DownloadFile.java14
-rw-r--r--src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java2
-rw-r--r--src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java2
-rw-r--r--src/github/daneren2005/dsub/service/sync/SubsonicSyncAdapter.java2
4 files changed, 14 insertions, 6 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadFile.java b/src/github/daneren2005/dsub/service/DownloadFile.java
index 434773c3..3c896693 100644
--- a/src/github/daneren2005/dsub/service/DownloadFile.java
+++ b/src/github/daneren2005/dsub/service/DownloadFile.java
@@ -54,7 +54,7 @@ public class DownloadFile {
private final File saveFile;
private final MediaStoreService mediaStoreService;
- private CancellableTask downloadTask;
+ private DownloadTask downloadTask;
private boolean save;
private boolean failedDownload = false;
private int failed = 0;
@@ -105,8 +105,9 @@ public class DownloadFile {
preDownload();
downloadTask.start();
}
- public synchronized void downloadNow() {
+ public synchronized void downloadNow(MusicService musicService) {
preDownload();
+ downloadTask.setMusicService(musicService);
downloadTask.execute();
}
@@ -250,6 +251,7 @@ public class DownloadFile {
}
private class DownloadTask extends CancellableTask {
+ private MusicService musicService;
@Override
public void execute() {
@@ -287,7 +289,9 @@ public class DownloadFile {
return;
}
- MusicService musicService = MusicServiceFactory.getMusicService(context);
+ if(musicService == null) {
+ musicService = MusicServiceFactory.getMusicService(context);
+ }
// Some devices seem to throw error on partial file which doesn't exist
boolean compare;
@@ -377,6 +381,10 @@ public class DownloadFile {
return "DownloadTask (" + song + ")";
}
+ public void setMusicService(MusicService musicService) {
+ this.musicService = musicService;
+ }
+
private void downloadAndSaveCoverArt(MusicService musicService) throws Exception {
try {
if (song.getCoverArt() != null) {
diff --git a/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java
index a709384b..dc754015 100644
--- a/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java
+++ b/src/github/daneren2005/dsub/service/sync/PlaylistSyncAdapter.java
@@ -57,7 +57,7 @@ public class PlaylistSyncAdapter extends SubsonicSyncAdapter {
for(MusicDirectory.Entry entry: playlist.getChildren()) {
DownloadFile file = new DownloadFile(context, entry, true);
while(!file.isSaved() && !file.isFailedMax()) {
- file.downloadNow();
+ file.downloadNow(musicService);
}
}
} catch(Exception e) {
diff --git a/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java
index d2f13a5b..f9311390 100644
--- a/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java
+++ b/src/github/daneren2005/dsub/service/sync/PodcastSyncAdapter.java
@@ -75,7 +75,7 @@ public class PodcastSyncAdapter extends SubsonicSyncAdapter {
if(entry.getId() != null && "completed".equals(((PodcastEpisode)entry).getStatus()) && !existingEpisodes.contains(entry.getId())) {
DownloadFile file = new DownloadFile(context, entry, true);
while(!file.isSaved() && !file.isFailedMax()) {
- file.downloadNow();
+ file.downloadNow(musicService);
}
// Only add if actualy downloaded correctly
if(file.isSaved()) {
diff --git a/src/github/daneren2005/dsub/service/sync/SubsonicSyncAdapter.java b/src/github/daneren2005/dsub/service/sync/SubsonicSyncAdapter.java
index c8e050e1..ee157771 100644
--- a/src/github/daneren2005/dsub/service/sync/SubsonicSyncAdapter.java
+++ b/src/github/daneren2005/dsub/service/sync/SubsonicSyncAdapter.java
@@ -122,7 +122,7 @@ public class SubsonicSyncAdapter extends AbstractThreadedSyncAdapter {
if (!song.isVideo()) {
DownloadFile file = new DownloadFile(context, song, save);
while(!file.isCompleteFileAvailable() && !file.isFailedMax()) {
- file.downloadNow();
+ file.downloadNow(musicService);
}
}
}