aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaneren2005 <daneren2005@gmail.com>2013-09-05 13:14:13 -0700
committerdaneren2005 <daneren2005@gmail.com>2013-09-05 13:14:13 -0700
commit8564e51ba33ef503ebd517aca5818cae6a3153a8 (patch)
treeb7a43aa5ca8ea1c73f6c39fcfdc60f324508d05f /src
parent113c7340b46523246bb08a984859a5808937cf84 (diff)
downloaddsub-8564e51ba33ef503ebd517aca5818cae6a3153a8.tar.gz
dsub-8564e51ba33ef503ebd517aca5818cae6a3153a8.tar.bz2
dsub-8564e51ba33ef503ebd517aca5818cae6a3153a8.zip
While downloading, keep track of number of failures
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/DownloadFile.java12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadFile.java b/src/github/daneren2005/dsub/service/DownloadFile.java
index 5ab7ad70..3d34157d 100644
--- a/src/github/daneren2005/dsub/service/DownloadFile.java
+++ b/src/github/daneren2005/dsub/service/DownloadFile.java
@@ -44,8 +44,8 @@ import org.apache.http.HttpStatus;
* @version $Id$
*/
public class DownloadFile {
-
private static final String TAG = DownloadFile.class.getSimpleName();
+ private static final int MAX_FAILURES = 5;
private final Context context;
private final MusicDirectory.Entry song;
private final File partialFile;
@@ -55,7 +55,7 @@ public class DownloadFile {
private final MediaStoreService mediaStoreService;
private CancellableTask downloadTask;
private boolean save;
- private boolean failed;
+ private int failed = 0;
private int bitRate;
private boolean isPlaying = false;
private boolean saveWhenDone = false;
@@ -98,7 +98,6 @@ public class DownloadFile {
public synchronized void download() {
FileUtil.createDirectoryForParent(saveFile);
- failed = false;
if(!partialFile.exists()) {
bitRate = Util.getMaxBitrate(context);
}
@@ -153,7 +152,10 @@ public class DownloadFile {
}
public boolean isFailed() {
- return failed;
+ return failed > 0;
+ }
+ public boolean isFailedMax() {
+ return failed > MAX_FAILURES;
}
public void delete() {
@@ -319,7 +321,7 @@ public class DownloadFile {
Util.delete(completeFile);
Util.delete(saveFile);
if (!isCancelled()) {
- failed = true;
+ failed++;
Log.w(TAG, "Failed to download '" + song + "'.", x);
}