use of de.danoeh.antennapod.core.syndication.handler.FeedHandler in project AntennaPod by AntennaPod.
the class FeedHandlerTest method runFeedTest.
private Feed runFeedTest(Feed feed, FeedGenerator g, String encoding, long flags) throws IOException, UnsupportedFeedtypeException, SAXException, ParserConfigurationException {
g.writeFeed(feed, outputStream, encoding, flags);
FeedHandler handler = new FeedHandler();
Feed parsedFeed = new Feed(feed.getDownload_url(), feed.getLastUpdate());
parsedFeed.setFile_url(file.getAbsolutePath());
parsedFeed.setDownloaded(true);
handler.parseFeed(parsedFeed);
return parsedFeed;
}
use of de.danoeh.antennapod.core.syndication.handler.FeedHandler in project AntennaPod by AntennaPod.
the class OnlineFeedViewActivity method parseFeed.
private void parseFeed() {
if (feed == null || feed.getFile_url() == null && feed.isDownloaded()) {
throw new IllegalStateException("feed must be non-null and downloaded when parseFeed is called");
}
Log.d(TAG, "Parsing feed");
parser = Observable.create(new Observable.OnSubscribe<FeedHandlerResult>() {
@Override
public void call(Subscriber<? super FeedHandlerResult> subscriber) {
FeedHandler handler = new FeedHandler();
try {
FeedHandlerResult result = handler.parseFeed(feed);
subscriber.onNext(result);
} catch (UnsupportedFeedtypeException e) {
Log.d(TAG, "Unsupported feed type detected");
if (TextUtils.equals("html", e.getRootElement().toLowerCase())) {
showFeedDiscoveryDialog(new File(feed.getFile_url()), feed.getDownload_url());
} else {
subscriber.onError(e);
}
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
subscriber.onError(e);
} finally {
boolean rc = new File(feed.getFile_url()).delete();
Log.d(TAG, "Deleted feed source file. Result: " + rc);
subscriber.onCompleted();
}
}
}).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(result -> {
beforeShowFeedInformation(result.feed);
showFeedInformation(result.feed, result.alternateFeedUrls);
}, error -> {
String errorMsg = DownloadError.ERROR_PARSER_EXCEPTION.getErrorString(OnlineFeedViewActivity.this) + " (" + error.getMessage() + ")";
showErrorDialog(errorMsg);
});
}
Aggregations