Always add feeds from opml, even if download fails (#6347)

This commit is contained in:
ByteHamster 2023-02-24 22:08:59 +01:00 committed by GitHub
parent 6d72d7cebf
commit 8be62b6d0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -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();
});

View File

@ -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();
}