From 2fbf6e94eb26534d47a460d7b234b1bc4701c7d7 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 8 Oct 2019 15:18:55 +0800 Subject: [PATCH] up --- .../io/legado/app/ui/rss/read/ReadRssViewModel.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt index db4191674..dcb363c9b 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt @@ -8,6 +8,7 @@ import io.legado.app.base.BaseViewModel import io.legado.app.data.entities.RssArticle import io.legado.app.model.analyzeRule.AnalyzeRule import io.legado.app.model.analyzeRule.AnalyzeUrl +import io.legado.app.utils.NetworkUtils class ReadRssViewModel(application: Application) : BaseViewModel(application) { @@ -29,22 +30,26 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application) { if (!ruleContent.isNullOrBlank()) { loadContent(rssArticle, ruleContent) } else { - urlLiveData.postValue(rssArticle.link) + loadUrl(rssArticle) } - } ?: let { - urlLiveData.postValue(rssArticle.link) - } + } ?: loadUrl(rssArticle) } } } } + } + private fun loadUrl(rssArticle: RssArticle) { + rssArticle.link?.let { + urlLiveData.postValue(NetworkUtils.getAbsoluteURL(rssArticle.origin, it)) + } } private fun loadContent(rssArticle: RssArticle, ruleContent: String) { execute { rssArticle.link?.let { - AnalyzeUrl(it).getResponseAsync().await().body()?.let { body -> + AnalyzeUrl(it, baseUrl = rssArticle.origin).getResponseAsync().await().body() + ?.let { body -> AnalyzeRule().apply { setContent(body) getString(ruleContent)?.let { content ->