summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/service/download/DownloadService.java
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2013-02-25 10:47:37 +0100
committerdaniel oeh <daniel.oeh@gmail.com>2013-02-25 10:47:37 +0100
commit955d296638b240d8bbf4be8cce4b27485ac4c517 (patch)
tree16a35b7a9493495a8e5f7a87ed646a2d166c7fe0 /src/de/danoeh/antennapod/service/download/DownloadService.java
parentf9e00f72a0dfeea3e5b9db8a522f7251e158dc7d (diff)
downloadAntennaPod-955d296638b240d8bbf4be8cce4b27485ac4c517.zip
Implemented EventDistributor
Diffstat (limited to 'src/de/danoeh/antennapod/service/download/DownloadService.java')
-rw-r--r--src/de/danoeh/antennapod/service/download/DownloadService.java36
1 files changed, 7 insertions, 29 deletions
diff --git a/src/de/danoeh/antennapod/service/download/DownloadService.java b/src/de/danoeh/antennapod/service/download/DownloadService.java
index d42e7ebc0..712c15a77 100644
--- a/src/de/danoeh/antennapod/service/download/DownloadService.java
+++ b/src/de/danoeh/antennapod/service/download/DownloadService.java
@@ -51,6 +51,7 @@ import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.DownloadActivity;
import de.danoeh.antennapod.activity.DownloadLogActivity;
import de.danoeh.antennapod.asynctask.DownloadStatus;
+import de.danoeh.antennapod.feed.EventDistributor;
import de.danoeh.antennapod.feed.Feed;
import de.danoeh.antennapod.feed.FeedFile;
import de.danoeh.antennapod.feed.FeedImage;
@@ -77,7 +78,6 @@ public class DownloadService extends Service {
/** Extra for ACTION_CANCEL_DOWNLOAD */
public static final String EXTRA_DOWNLOAD_URL = "downloadUrl";
- public static final String ACTION_DOWNLOAD_HANDLED = "action.de.danoeh.antennapod.service.download_handled";
/**
* Sent by the DownloadService when the content of the downloads list
* changes.
@@ -89,12 +89,6 @@ public class DownloadService extends Service {
/** Extra for ACTION_ENQUEUE_DOWNLOAD intent. */
public static final String EXTRA_REQUEST = "request";
- // Download types for ACTION_DOWNLOAD_HANDLED
- public static final String EXTRA_DOWNLOAD_TYPE = "extra.de.danoeh.antennapod.service.downloadType";
- public static final int DOWNLOAD_TYPE_FEED = 1;
- public static final int DOWNLOAD_TYPE_MEDIA = 2;
- public static final int DOWNLOAD_TYPE_IMAGE = 3;
-
private CopyOnWriteArrayList<DownloadStatus> completedDownloads;
private ExecutorService syncExecutor;
@@ -462,7 +456,7 @@ public class DownloadService extends Service {
Log.e(TAG, "Download failed");
saveDownloadStatus(status);
}
- sendDownloadHandledIntent(getDownloadType(download));
+ sendDownloadHandledIntent();
downloadsBeingHandled -= 1;
}
}
@@ -504,24 +498,8 @@ public class DownloadService extends Service {
manager.addDownloadStatus(this, status);
}
- /** Returns correct value for EXTRA_DOWNLOAD_TYPE. */
- private int getDownloadType(FeedFile f) {
- if (f.getClass() == Feed.class) {
- return DOWNLOAD_TYPE_FEED;
- } else if (f.getClass() == FeedImage.class) {
- return DOWNLOAD_TYPE_IMAGE;
- } else if (f.getClass() == FeedMedia.class) {
- return DOWNLOAD_TYPE_MEDIA;
- } else {
- return 0;
- }
- }
-
- private void sendDownloadHandledIntent(int type) {
- Intent intent = new Intent(ACTION_DOWNLOAD_HANDLED);
- intent.putExtra(EXTRA_DOWNLOAD_TYPE, type);
-
- sendBroadcast(intent);
+ private void sendDownloadHandledIntent() {
+ EventDistributor.getInstance().sendDownloadHandledBroadcast();
}
/**
@@ -726,7 +704,7 @@ public class DownloadService extends Service {
saveDownloadStatus(new DownloadStatus(savedFeed,
savedFeed.getHumanReadableIdentifier(), reason, successful,
reasonDetailed));
- sendDownloadHandledIntent(DOWNLOAD_TYPE_FEED);
+ sendDownloadHandledIntent();
downloadsBeingHandled -= 1;
handler.post(new Runnable() {
@@ -803,7 +781,7 @@ public class DownloadService extends Service {
image.setDownloaded(true);
saveDownloadStatus(status);
- sendDownloadHandledIntent(DOWNLOAD_TYPE_IMAGE);
+ sendDownloadHandledIntent();
manager.setFeedImage(DownloadService.this, image);
if (image.getFeed() != null) {
manager.setFeed(DownloadService.this, image.getFeed());
@@ -867,7 +845,7 @@ public class DownloadService extends Service {
}
saveDownloadStatus(status);
- sendDownloadHandledIntent(DOWNLOAD_TYPE_MEDIA);
+ sendDownloadHandledIntent();
if (chaptersRead) {
manager.setFeedItem(DownloadService.this, media.getItem());
} else {