pull/35/head^2
kunfei 5 years ago
parent 8a543ef3b7
commit 2144939658
  1. 5
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt

@ -4,9 +4,9 @@ import android.app.Application
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import io.legado.app.App import io.legado.app.App
import io.legado.app.base.BaseViewModel import io.legado.app.base.BaseViewModel
import io.legado.app.model.analyzeRule.AnalyzeUrl
import io.legado.app.model.rss.RssParser import io.legado.app.model.rss.RssParser
import io.legado.app.model.rss.RssParserByRule import io.legado.app.model.rss.RssParserByRule
import java.net.URL
class RssArticlesViewModel(application: Application) : BaseViewModel(application) { class RssArticlesViewModel(application: Application) : BaseViewModel(application) {
@ -19,7 +19,7 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application
rssSource?.let { rssSource?.let {
titleLiveData.postValue(rssSource.sourceName) titleLiveData.postValue(rssSource.sourceName)
} }
val xml = URL(url).readText() AnalyzeUrl(url).getResponseAsync().await().body()?.let { xml ->
if (rssSource == null || rssSource.ruleArticles.isNullOrBlank()) { if (rssSource == null || rssSource.ruleArticles.isNullOrBlank()) {
RssParser.parseXML(xml, url).let { RssParser.parseXML(xml, url).let {
App.db.rssArtivleDao().insert(*it.toTypedArray()) App.db.rssArtivleDao().insert(*it.toTypedArray())
@ -29,6 +29,7 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application
App.db.rssArtivleDao().insert(*it.toTypedArray()) App.db.rssArtivleDao().insert(*it.toTypedArray())
} }
} }
}
}.onFinally { }.onFinally {
onFinally() onFinally()
} }

Loading…
Cancel
Save