Use nullable attributes in ATOM adapters

This commit is contained in:
Shinokuni 2020-09-19 18:50:23 +02:00
parent 0eb518d692
commit 581de2e1dd
2 changed files with 6 additions and 2 deletions

View File

@ -38,7 +38,7 @@ class ATOMFeedAdapter : XmlAdapter<Feed> {
}
private fun parseLink(konsume: Konsumer, feed: Feed) {
val rel = konsume.attributes["rel"]
val rel = konsume.attributes.getValueOpt("rel")
if (rel == "self")
feed.url = konsume.attributes["href"]

View File

@ -26,7 +26,11 @@ class ATOMItemsAdapter : XmlAdapter<List<Item>> {
"title" -> title = nonNullText()
"id" -> guid = nullableText()
"updated" -> pubDate = DateUtils.stringToLocalDateTime(nonNullText())
"link" -> if (attributes["rel"] == "alternate") link = attributes["href"]
"link" -> {
if (attributes.getValueOpt("rel") == null ||
attributes["rel"] == "alternate")
link = attributes["href"]
}
"author" -> allChildrenAutoIgnore("name") { author = text() }
"summary" -> description = nullableText()
"content" -> content = nullableText()