summaryrefslogtreecommitdiff
path: root/event/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'event/src/main')
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/EpisodeDownloadEvent.java12
-rw-r--r--event/src/main/java/de/danoeh/antennapod/event/FeedItemEvent.java10
2 files changed, 22 insertions, 0 deletions
diff --git a/event/src/main/java/de/danoeh/antennapod/event/EpisodeDownloadEvent.java b/event/src/main/java/de/danoeh/antennapod/event/EpisodeDownloadEvent.java
index c9790d18a..28cbc234c 100644
--- a/event/src/main/java/de/danoeh/antennapod/event/EpisodeDownloadEvent.java
+++ b/event/src/main/java/de/danoeh/antennapod/event/EpisodeDownloadEvent.java
@@ -1,7 +1,9 @@
package de.danoeh.antennapod.event;
import de.danoeh.antennapod.model.download.DownloadStatus;
+import de.danoeh.antennapod.model.feed.FeedItem;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -15,4 +17,14 @@ public class EpisodeDownloadEvent {
public Set<String> getUrls() {
return map.keySet();
}
+
+ public static int indexOfItemWithDownloadUrl(List<FeedItem> items, String downloadUrl) {
+ for (int i = 0; i < items.size(); i++) {
+ FeedItem item = items.get(i);
+ if (item != null && item.getMedia() != null && item.getMedia().getDownloadUrl().equals(downloadUrl)) {
+ return i;
+ }
+ }
+ return -1;
+ }
}
diff --git a/event/src/main/java/de/danoeh/antennapod/event/FeedItemEvent.java b/event/src/main/java/de/danoeh/antennapod/event/FeedItemEvent.java
index 125d113d6..e21764971 100644
--- a/event/src/main/java/de/danoeh/antennapod/event/FeedItemEvent.java
+++ b/event/src/main/java/de/danoeh/antennapod/event/FeedItemEvent.java
@@ -22,4 +22,14 @@ public class FeedItemEvent {
public static FeedItemEvent updated(FeedItem... items) {
return new FeedItemEvent(Arrays.asList(items));
}
+
+ public static int indexOfItemWithId(List<FeedItem> items, long id) {
+ for (int i = 0; i < items.size(); i++) {
+ FeedItem item = items.get(i);
+ if (item != null && item.getId() == id) {
+ return i;
+ }
+ }
+ return -1;
+ }
}