diff options
author | H. Lehmann <ByteHamster@users.noreply.github.com> | 2019-12-31 13:53:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-31 13:53:04 +0100 |
commit | 0b5bd94ab64e73213590f429bf5a297a9a5b98dd (patch) | |
tree | d3635defb96f08c18275d12b8cc7db8d4df3055e /core | |
parent | 912d2cecee01322a354a073a0865d9881a04f4a8 (diff) | |
parent | d8a1744cd8ee6248a324e45adaeb961c5de244e0 (diff) | |
download | AntennaPod-0b5bd94ab64e73213590f429bf5a297a9a5b98dd.zip |
Merge pull request #3709 from ByteHamster/fix-feed-update-crash
Fixed ArrayIndexOutOfBoundsException when updating feeds
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java index 6e72a762a..c4a06efa2 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java @@ -496,17 +496,22 @@ public final class DBTasks { // item is new item.setFeed(savedFeed); item.setAutoDownload(savedFeed.getPreferences().getAutoDownload()); - savedFeed.getItems().add(idx, item); + + if (idx >= savedFeed.getItems().size()) { + savedFeed.getItems().add(item); + } else { + savedFeed.getItems().add(idx, item); + } // only mark the item new if it was published after or at the same time // as the most recent item // (if the most recent date is null then we can assume there are no items // and this is the first, hence 'new') - if (priorMostRecentDate == null || - priorMostRecentDate.before(item.getPubDate()) || - priorMostRecentDate.equals(item.getPubDate())) { - Log.d(TAG, "Marking item published on " + item.getPubDate() + - " new, prior most recent date = " + priorMostRecentDate); + if (priorMostRecentDate == null + || priorMostRecentDate.before(item.getPubDate()) + || priorMostRecentDate.equals(item.getPubDate())) { + Log.d(TAG, "Marking item published on " + item.getPubDate() + + " new, prior most recent date = " + priorMostRecentDate); item.setNew(); } } else { |