diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2024-04-05 19:20:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-05 19:20:27 +0200 |
commit | 92ab575b150ab49ca85e0ac994558142e49c9e68 (patch) | |
tree | 422dcd76895a4ba06ed02723ff61351435c0fe49 /model/src/main | |
parent | 2143ab135182434911d4554a8ef08115eaa0d2d0 (diff) | |
download | AntennaPod-92ab575b150ab49ca85e0ac994558142e49c9e68.zip |
Delete core module (#7060)
Diffstat (limited to 'model/src/main')
-rw-r--r-- | model/src/main/java/de/danoeh/antennapod/model/feed/Chapter.java | 14 | ||||
-rw-r--r-- | model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java | 14 |
2 files changed, 28 insertions, 0 deletions
diff --git a/model/src/main/java/de/danoeh/antennapod/model/feed/Chapter.java b/model/src/main/java/de/danoeh/antennapod/model/feed/Chapter.java index 3f4116f9c..3683a2a44 100644 --- a/model/src/main/java/de/danoeh/antennapod/model/feed/Chapter.java +++ b/model/src/main/java/de/danoeh/antennapod/model/feed/Chapter.java @@ -1,5 +1,7 @@ package de.danoeh.antennapod.model.feed; +import java.util.List; + public class Chapter { private long id; /** Defines starting point in milliseconds. */ @@ -74,4 +76,16 @@ public class Chapter { public void setId(long id) { this.id = id; } + + public static int getAfterPosition(List<Chapter> chapters, int playbackPosition) { + if (chapters == null || chapters.isEmpty()) { + return -1; + } + for (int i = 0; i < chapters.size(); i++) { + if (chapters.get(i).getStart() > playbackPosition) { + return i - 1; + } + } + return chapters.size() - 1; + } } diff --git a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java b/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java index 9cc71eb1d..df4cc8f9c 100644 --- a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java +++ b/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java @@ -3,6 +3,7 @@ package de.danoeh.antennapod.model.feed; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -205,6 +206,19 @@ public class FeedItem implements Serializable { return link; } + /** + * Get the link for the feed item for the purpose of Share. + * It falls backs to the feed's link if the item has no link. + */ + public String getLinkWithFallback() { + if (StringUtils.isNotBlank(link)) { + return link; + } else if (StringUtils.isNotBlank(getFeed().getLink())) { + return getFeed().getLink(); + } + return null; + } + public void setLink(String link) { this.link = link; } |