pull/35/head^2
kunfei 5 years ago
parent cbb2ef24ae
commit 439b78c6ca
  1. 3
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesActivity.kt
  2. 6
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt

@ -25,6 +25,9 @@ class RssArticlesActivity : VMBaseActivity<RssArticlesViewModel>(R.layout.activi
override fun onActivityCreated(savedInstanceState: Bundle?) {
initView()
viewModel.titleLiveData.observe(this, Observer {
title_bar.title = it
})
intent.getStringExtra("url")?.let {
initData(it)
viewModel.loadContent(it) {

@ -1,6 +1,7 @@
package io.legado.app.ui.rss.article
import android.app.Application
import androidx.lifecycle.MutableLiveData
import io.legado.app.App
import io.legado.app.base.BaseViewModel
import io.legado.app.model.rss.RssParser
@ -10,9 +11,14 @@ import java.net.URL
class RssArticlesViewModel(application: Application) : BaseViewModel(application) {
val titleLiveData = MutableLiveData<String>()
fun loadContent(url: String, onFinally: () -> Unit) {
execute {
val rssSource = App.db.rssSourceDao().getByKey(url)
rssSource?.let {
titleLiveData.postValue(rssSource.sourceName)
}
val xml = URL(url).readText()
if (rssSource == null || rssSource.ruleArticles.isNullOrBlank()) {
RssParser.parseXML(xml, url).let {

Loading…
Cancel
Save