diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2012-09-21 12:33:55 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2012-09-21 12:33:55 +0200 |
commit | 0459f9129976d8628878b09078e404eeaa2127ec (patch) | |
tree | 2f91931b15413b77d3913d0b81618f477c2c31ec /src/de/danoeh | |
parent | b2aed41e8ce8094e741950256459951a59a92bae (diff) | |
download | AntennaPod-0459f9129976d8628878b09078e404eeaa2127ec.zip |
Excluded cancelled downloads from the download service report and the
download log
Diffstat (limited to 'src/de/danoeh')
3 files changed, 22 insertions, 12 deletions
diff --git a/src/de/danoeh/antennapod/asynctask/DownloadStatus.java b/src/de/danoeh/antennapod/asynctask/DownloadStatus.java index 3ec5344a0..3d63026eb 100644 --- a/src/de/danoeh/antennapod/asynctask/DownloadStatus.java +++ b/src/de/danoeh/antennapod/asynctask/DownloadStatus.java @@ -51,6 +51,7 @@ public class DownloadStatus { protected long size; protected int statusMsg; protected boolean done; + protected boolean cancelled; public DownloadStatus(FeedFile feedfile, String title) { this.feedfile = feedfile; @@ -58,9 +59,9 @@ public class DownloadStatus { } /** Constructor for restoring Download status entries from DB. */ - public DownloadStatus(long id, String title, FeedFile feedfile, int feedfileType, - boolean successful, int reason, Date completionDate, - String reasonDetailed) { + public DownloadStatus(long id, String title, FeedFile feedfile, + int feedfileType, boolean successful, int reason, + Date completionDate, String reasonDetailed) { progressPercent = 100; soFar = 0; size = 0; @@ -79,7 +80,8 @@ public class DownloadStatus { /** Constructor for creating new completed downloads. */ public DownloadStatus(FeedFile feedfile, String title, int reason, boolean successful, String reasonDetailed) { - this(0, title, feedfile, feedfile.getTypeAsInt(), successful, reason, new Date(), reasonDetailed); + this(0, title, feedfile, feedfile.getTypeAsInt(), successful, reason, + new Date(), reasonDetailed); } public FeedFile getFeedFile() { @@ -174,4 +176,12 @@ public class DownloadStatus { return feedfileType; } + public boolean isCancelled() { + return cancelled; + } + + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; + } + }
\ No newline at end of file diff --git a/src/de/danoeh/antennapod/service/download/DownloadService.java b/src/de/danoeh/antennapod/service/download/DownloadService.java index 4160eec05..734fab1ac 100644 --- a/src/de/danoeh/antennapod/service/download/DownloadService.java +++ b/src/de/danoeh/antennapod/service/download/DownloadService.java @@ -281,7 +281,8 @@ public class DownloadService extends Service { FeedFile feedfile = requester.getDownload(request.source); if (feedfile != null) { - DownloadStatus status = new DownloadStatus(feedfile, feedfile.getHumanReadableIdentifier()); + DownloadStatus status = new DownloadStatus(feedfile, + feedfile.getHumanReadableIdentifier()); Downloader downloader = getDownloader(status); if (downloader != null) { downloads.add(downloader); @@ -325,7 +326,6 @@ public class DownloadService extends Service { DownloadStatus status = downloader.getStatus(); status.setCompletionDate(new Date()); boolean successful = status.isSuccessful(); - int reason = status.getReason(); FeedFile download = status.getFeedFile(); if (download != null) { @@ -338,13 +338,12 @@ public class DownloadService extends Service { handleCompletedFeedMediaDownload(status); } } else { - if (!successful - && reason != DownloadError.ERROR_DOWNLOAD_CANCELLED) { - Log.e(TAG, "Download failed"); - } download.setFile_url(null); download.setDownloaded(false); - saveDownloadStatus(status); + if (!successful && !status.isCancelled()) { + Log.e(TAG, "Download failed"); + saveDownloadStatus(status); + } sendDownloadHandledIntent(getDownloadType(download)); downloadsBeingHandled -= 1; } @@ -428,7 +427,7 @@ public class DownloadService extends Service { createReport = true; } successfulDownloads++; - } else { + } else if (!status.isCancelled()){ if (status.getFeedFile().getClass() != FeedImage.class) { createReport = true; } diff --git a/src/de/danoeh/antennapod/service/download/HttpDownloader.java b/src/de/danoeh/antennapod/service/download/HttpDownloader.java index 8348ca3ce..c2b913571 100644 --- a/src/de/danoeh/antennapod/service/download/HttpDownloader.java +++ b/src/de/danoeh/antennapod/service/download/HttpDownloader.java @@ -133,6 +133,7 @@ public class HttpDownloader extends Downloader { status.setReason(DownloadError.ERROR_DOWNLOAD_CANCELLED); status.setDone(true); status.setSuccessful(false); + status.setCancelled(true); } } |