diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2023-07-15 15:55:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-15 15:55:24 +0200 |
commit | 75c3c4cf249b685d4c7ffc88b3db212963659df8 (patch) | |
tree | 2b942885462ef53b5c543dbadb62b79c9a637887 | |
parent | 6999a944bb3c1ce1547832ad15e401ff7cbbbe10 (diff) | |
download | AntennaPod-75c3c4cf249b685d4c7ffc88b3db212963659df8.zip |
Don't allow adding items without media to the queue (#6529)
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java | 3 | ||||
-rw-r--r-- | core/src/test/java/de/danoeh/antennapod/core/storage/DbWriterTest.java | 8 |
2 files changed, 10 insertions, 1 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java index 4815737f4..11e82af27 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java @@ -360,6 +360,9 @@ public class DBWriter { public static Future<?> addQueueItem(final Context context, boolean markAsUnplayed, final FeedItem... items) { LongList itemIds = new LongList(items.length); for (FeedItem item : items) { + if (!item.hasMedia()) { + continue; + } itemIds.add(item.getId()); item.addTag(FeedItem.TAG_QUEUE); } diff --git a/core/src/test/java/de/danoeh/antennapod/core/storage/DbWriterTest.java b/core/src/test/java/de/danoeh/antennapod/core/storage/DbWriterTest.java index 08842e5fb..fb7cad252 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/storage/DbWriterTest.java +++ b/core/src/test/java/de/danoeh/antennapod/core/storage/DbWriterTest.java @@ -298,7 +298,6 @@ public class DbWriterTest { for (int i = 0; i < 10; i++) { FeedItem item = new FeedItem(0, "Item " + i, "Item" + i, "url", new Date(), FeedItem.PLAYED, feed); feed.getItems().add(item); - } PodDBAdapter adapter = PodDBAdapter.getInstance(); @@ -444,6 +443,7 @@ public class DbWriterTest { // create items for (int i = 0; i < 10; i++) { FeedItem item = new FeedItem(0, "Item " + i, "Item" + i, "url", new Date(), FeedItem.PLAYED, feed); + item.setMedia(new FeedMedia(item, "", 0, "")); feed.getItems().add(item); } @@ -522,6 +522,7 @@ public class DbWriterTest { feed.setItems(new ArrayList<>()); for (int i = 0; i < numItems; i++) { FeedItem item = new FeedItem(0, "title " + i, "id " + i, "link " + i, new Date(), FeedItem.PLAYED, feed); + item.setMedia(new FeedMedia(item, "", 0, "")); feed.getItems().add(item); } @@ -548,6 +549,7 @@ public class DbWriterTest { Feed feed = new Feed("url", null, "title"); feed.setItems(new ArrayList<>()); FeedItem item = new FeedItem(0, "title", "id", "link", new Date(), FeedItem.PLAYED, feed); + item.setMedia(new FeedMedia(item, "", 0, "")); feed.getItems().add(item); PodDBAdapter adapter = PodDBAdapter.getInstance(); @@ -572,6 +574,7 @@ public class DbWriterTest { Feed feed = new Feed("url", null, "title"); feed.setItems(new ArrayList<>()); FeedItem item = new FeedItem(0, "title", "id", "link", new Date(), FeedItem.PLAYED, feed); + item.setMedia(new FeedMedia(item, "", 0, "")); feed.getItems().add(item); PodDBAdapter adapter = PodDBAdapter.getInstance(); @@ -714,6 +717,7 @@ public class DbWriterTest { for (int i = 0; i < numItems; i++) { FeedItem item = new FeedItem(0, "title " + i, "id " + i, "link " + i, new Date(), FeedItem.PLAYED, feed); + item.setMedia(new FeedMedia(item, "", 0, "")); feed.getItems().add(item); } @@ -762,6 +766,7 @@ public class DbWriterTest { for (int i = 0; i < numItems; i++) { FeedItem item = new FeedItem(0, "title " + i, "id " + i, "link " + i, new Date(), FeedItem.NEW, feed); + item.setMedia(new FeedMedia(item, "", 0, "")); feed.getItems().add(item); } @@ -788,6 +793,7 @@ public class DbWriterTest { for (int i = 0; i < numItems; i++) { FeedItem item = new FeedItem(0, "title " + i, "id " + i, "link " + i, new Date(), FeedItem.PLAYED, feed); + item.setMedia(new FeedMedia(item, "", 0, "")); feed.getItems().add(item); } |