feat: 优化代码

pull/182/head
kunfei 5 years ago
parent f5330a07a5
commit 7b34243918
  1. 8
      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> { fun sortUrls(): LinkedHashMap<String, String> {
val sortMap = linkedMapOf<String, String>() val sortMap = linkedMapOf<String, String>()
val sortUrl = sortUrl sortUrl?.split("(&&|\n)+".toRegex())?.forEach { c ->
if (sortUrl.isNullOrEmpty()) {
sortMap[""] = sourceUrl
} else {
sortUrl.split("(&&|\n)+".toRegex()).forEach { c ->
val d = c.split("::") val d = c.split("::")
if (d.size > 1) if (d.size > 1)
sortMap[d[0]] = d[1] sortMap[d[0]] = d[1]
} }
if (sortMap.isEmpty()) {
sortMap[""] = sourceUrl
} }
return sortMap return sortMap
} }

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

Loading…
Cancel
Save