diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2012-06-17 17:56:39 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2012-06-17 17:56:39 +0200 |
commit | 2f5e0dd0233ff0209e1a70a2a96e03f697bfee72 (patch) | |
tree | 679cb64b53c999136dab8b3c59a7aa0a0fc51bca /src/de/podfetcher/service/DownloadService.java | |
parent | c41a61752f89a3430548b271b6c463decffe5815 (diff) | |
download | AntennaPod-2f5e0dd0233ff0209e1a70a2a96e03f697bfee72.zip |
FeedManager now maintains a list of DownloadStatus entries
Diffstat (limited to 'src/de/podfetcher/service/DownloadService.java')
-rw-r--r-- | src/de/podfetcher/service/DownloadService.java | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/de/podfetcher/service/DownloadService.java b/src/de/podfetcher/service/DownloadService.java index 36b894242..70955d21e 100644 --- a/src/de/podfetcher/service/DownloadService.java +++ b/src/de/podfetcher/service/DownloadService.java @@ -63,8 +63,6 @@ public class DownloadService extends Service { } } - - @Override public int onStartCommand(Intent intent, int flags, int startId) { queryDownloads(); @@ -148,7 +146,8 @@ public class DownloadService extends Service { @Override public void onReceive(Context context, Intent intent) { int status = -1; - + boolean successful = false; + int reason = 0; Log.d(TAG, "Received 'Download Complete' - message."); long downloadId = intent.getLongExtra( DownloadManager.EXTRA_DOWNLOAD_ID, 0); @@ -160,10 +159,10 @@ public class DownloadService extends Service { status = c.getInt(c .getColumnIndex(DownloadManager.COLUMN_STATUS)); } + FeedFile download = requester.getFeedFile(downloadId); + if (download != null) { + if (status == DownloadManager.STATUS_SUCCESSFUL) { - if (status == DownloadManager.STATUS_SUCCESSFUL) { - FeedFile download = requester.getFeedFile(downloadId); - if (download != null) { if (download.getClass() == Feed.class) { handleCompletedFeedDownload(context, (Feed) download); } else if (download.getClass() == FeedImage.class) { @@ -173,16 +172,18 @@ public class DownloadService extends Service { handleCompletedFeedMediaDownload(context, (FeedMedia) download); } + successful = true; + queryDownloads(); + } else if (status == DownloadManager.STATUS_FAILED) { + reason = c.getInt(c + .getColumnIndex(DownloadManager.COLUMN_REASON)); + Log.d(TAG, "reason code is " + reason); + successful = false; } - queryDownloads(); - } else if (status == DownloadManager.STATUS_FAILED) { - int reason = c.getInt(c - .getColumnIndex(DownloadManager.COLUMN_REASON)); - Log.d(TAG, "reason code is " + reason); - + manager.addDownloadStatus(context, new DownloadStatus(download, + reason, successful)); + c.close(); } - - c.close(); } }; |