diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesActivity.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesActivity.kt index b332ecc0e..f72a98048 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesActivity.kt @@ -25,6 +25,9 @@ class RssArticlesActivity : VMBaseActivity(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) { diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt index 39f0f22e2..a4ddecf4d 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt @@ -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() + 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 {