pull/35/head^2
kunfei 5 years ago
parent 9dffaf39b4
commit 18e6d179a7
  1. 12
      app/src/main/java/io/legado/app/data/entities/RssArticle.kt
  2. 3
      app/src/main/java/io/legado/app/model/rss/RssParser.kt

@ -1,6 +1,7 @@
package io.legado.app.data.entities package io.legado.app.data.entities
import androidx.room.Entity import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey import androidx.room.PrimaryKey
@ -9,7 +10,7 @@ data class RssArticle(
var origin: String = "", var origin: String = "",
var time: Long = System.currentTimeMillis(), var time: Long = System.currentTimeMillis(),
@PrimaryKey @PrimaryKey
var guid: String? = null, var guid: String = "",
var title: String? = null, var title: String? = null,
var author: String? = null, var author: String? = null,
var link: String? = null, var link: String? = null,
@ -17,5 +18,10 @@ data class RssArticle(
var description: String? = null, var description: String? = null,
var content: String? = null, var content: String? = null,
var image: String? = null, var image: String? = null,
var categories: MutableList<String> = mutableListOf() var categories: String? = null
) ) {
@Ignore
var categoryList: MutableList<String> = mutableListOf()
}

@ -42,7 +42,7 @@ object RssParser {
xmlPullParser.name.equals(RSSKeywords.RSS_ITEM_AUTHOR, true) -> xmlPullParser.name.equals(RSSKeywords.RSS_ITEM_AUTHOR, true) ->
if (insideItem) currentArticle.author = xmlPullParser.nextText().trim() if (insideItem) currentArticle.author = xmlPullParser.nextText().trim()
xmlPullParser.name.equals(RSSKeywords.RSS_ITEM_CATEGORY, true) -> xmlPullParser.name.equals(RSSKeywords.RSS_ITEM_CATEGORY, true) ->
if (insideItem) currentArticle.categories.add(xmlPullParser.nextText().trim()) if (insideItem) currentArticle.categoryList.add(xmlPullParser.nextText().trim())
xmlPullParser.name.equals(RSSKeywords.RSS_ITEM_THUMBNAIL, true) -> xmlPullParser.name.equals(RSSKeywords.RSS_ITEM_THUMBNAIL, true) ->
if (insideItem) currentArticle.image = if (insideItem) currentArticle.image =
xmlPullParser.getAttributeValue(null, RSSKeywords.RSS_ITEM_URL) xmlPullParser.getAttributeValue(null, RSSKeywords.RSS_ITEM_URL)
@ -92,6 +92,7 @@ object RssParser {
) { ) {
// The item is correctly parsed // The item is correctly parsed
insideItem = false insideItem = false
currentArticle.categories = currentArticle.categoryList.joinToString(",")
articleList.add(currentArticle) articleList.add(currentArticle)
currentArticle = RssArticle() currentArticle = RssArticle()
} }

Loading…
Cancel
Save