aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github/daneren2005/dsub/service/DownloadFile.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/github/daneren2005/dsub/service/DownloadFile.java')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadFile.java24
1 files changed, 21 insertions, 3 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadFile.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadFile.java
index 3febfaea..e4bab798 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/DownloadFile.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadFile.java
@@ -84,6 +84,9 @@ public class DownloadFile implements BufferFile {
public MusicDirectory.Entry getSong() {
return song;
}
+ public boolean isSong() {
+ return song.isSong();
+ }
public Context getContext() {
return context;
@@ -111,7 +114,7 @@ public class DownloadFile implements BufferFile {
}
} else if(song.getSuffix() != null && (song.getTranscodedSuffix() == null || song.getSuffix().equals(song.getTranscodedSuffix()))) {
// If just downsampling, don't try to upsample (ie: 128 kpbs -> 192 kpbs)
- if(song.getBitRate() != null && br > song.getBitRate()) {
+ if(song.getBitRate() != null && (br == 0 || br > song.getBitRate())) {
br = song.getBitRate();
}
}
@@ -379,6 +382,20 @@ public class DownloadFile implements BufferFile {
return "DownloadFile (" + song + ")";
}
+ // Don't do this. Causes infinite loop if two instances of same song
+ /*@Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ DownloadFile downloadFile = (DownloadFile) o;
+ return Util.equals(this.getSong(), downloadFile.getSong());
+ }*/
+
private class DownloadTask extends SilentBackgroundTask<Void> {
private MusicService musicService;
@@ -515,8 +532,9 @@ public class DownloadFile implements BufferFile {
}
// Only run these if not interrupted, ie: cancelled
- if(!isCancelled()) {
- new CacheCleaner(context, DownloadService.getInstance()).cleanSpace();
+ DownloadService downloadService = DownloadService.getInstance();
+ if(downloadService != null && !isCancelled()) {
+ new CacheCleaner(context, downloadService).cleanSpace();
checkDownloads();
}