feat: 优化代码

pull/182/head
kunfei 5 years ago
parent f5330a07a5
commit 7b34243918
  1. 14
      app/src/main/java/io/legado/app/data/entities/RssSource.kt
  2. 3
      app/src/main/java/io/legado/app/model/Debug.kt

@ -102,15 +102,13 @@ data class RssSource(
fun sortUrls(): LinkedHashMap<String, String> {
val sortMap = linkedMapOf<String, String>()
val sortUrl = sortUrl
if (sortUrl.isNullOrEmpty()) {
sortUrl?.split("(&&|\n)+".toRegex())?.forEach { c ->
val d = c.split("::")
if (d.size > 1)
sortMap[d[0]] = d[1]
}
if (sortMap.isEmpty()) {
sortMap[""] = sourceUrl
} else {
sortUrl.split("(&&|\n)+".toRegex()).forEach { c ->
val d = c.split("::")
if (d.size > 1)
sortMap[d[0]] = d[1]
}
}
return sortMap
}

@ -54,7 +54,8 @@ object Debug {
cancelDebug()
debugSource = rssSource.sourceUrl
log(debugSource, "︾开始解析")
Rss.getArticles(rssSource, null)
val sort = rssSource.sortUrls().entries.first()
Rss.getArticles(sort.key, sort.value, rssSource, null)
.onSuccess {
if (it.articles.isEmpty()) {
log(debugSource, "⇒列表页解析成功,为空")

Loading…
Cancel
Save