From 8be62b6d0e7b2f5a45b70188dcb4e1891ef2a133 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Fri, 24 Feb 2023 22:08:59 +0100 Subject: [PATCH] Always add feeds from opml, even if download fails (#6347) --- .../antennapod/activity/OpmlImportActivity.java | 11 ++++++++--- .../de/danoeh/antennapod/core/storage/DBTasks.java | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportActivity.java index c8d9f9b31..64a6b6632 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportActivity.java @@ -28,7 +28,7 @@ import de.danoeh.antennapod.core.export.opml.OpmlElement; import de.danoeh.antennapod.core.export.opml.OpmlReader; import de.danoeh.antennapod.core.preferences.ThemeSwitcher; -import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; +import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; import de.danoeh.antennapod.databinding.OpmlSelectionBinding; import de.danoeh.antennapod.model.feed.Feed; @@ -43,6 +43,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -95,9 +96,12 @@ public class OpmlImportActivity extends AppCompatActivity { continue; } OpmlElement element = readElements.get(checked.keyAt(i)); - Feed feed = new Feed(element.getXmlUrl(), null, element.getText()); - DownloadServiceInterface.get().download(this, false, DownloadRequestCreator.create(feed).build()); + Feed feed = new Feed(element.getXmlUrl(), null, + element.getText() != null ? element.getText() : "Unknown podcast"); + feed.setItems(Collections.emptyList()); + DBTasks.updateFeed(this, feed, false); } + DownloadServiceInterface.get().refreshAllFeeds(this, true); }) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) @@ -109,6 +113,7 @@ public class OpmlImportActivity extends AppCompatActivity { startActivity(intent); finish(); }, e -> { + e.printStackTrace(); viewBinding.progressBar.setVisibility(View.GONE); Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); }); 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 bf03ebff1..18f157908 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 @@ -322,7 +322,7 @@ public final class DBTasks { // get the most recent date now, before we start changing the list FeedItem priorMostRecent = savedFeed.getMostRecentItem(); - Date priorMostRecentDate = null; + Date priorMostRecentDate = new Date(); if (priorMostRecent != null) { priorMostRecentDate = priorMostRecent.getPubDate(); }