|
|
@ -12,8 +12,8 @@ import io.legado.app.model.analyzeRule.AnalyzeUrl |
|
|
|
import io.legado.app.utils.NetworkUtils |
|
|
|
import io.legado.app.utils.NetworkUtils |
|
|
|
|
|
|
|
|
|
|
|
class ReadRssViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
class ReadRssViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
var rssArticleLiveData = MutableLiveData<RssArticle>() |
|
|
|
var rssSource: RssSource? = null |
|
|
|
val rssSourceLiveData = MutableLiveData<RssSource>() |
|
|
|
val rssArticleLiveData = MutableLiveData<RssArticle>() |
|
|
|
val contentLiveData = MutableLiveData<String>() |
|
|
|
val contentLiveData = MutableLiveData<String>() |
|
|
|
val urlLiveData = MutableLiveData<AnalyzeUrl>() |
|
|
|
val urlLiveData = MutableLiveData<AnalyzeUrl>() |
|
|
|
|
|
|
|
|
|
|
@ -21,10 +21,7 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
execute { |
|
|
|
execute { |
|
|
|
val origin = intent.getStringExtra("origin") |
|
|
|
val origin = intent.getStringExtra("origin") |
|
|
|
val link = intent.getStringExtra("link") |
|
|
|
val link = intent.getStringExtra("link") |
|
|
|
val rssSource = App.db.rssSourceDao().getByKey(origin) |
|
|
|
rssSource = App.db.rssSourceDao().getByKey(origin) |
|
|
|
rssSource?.let { |
|
|
|
|
|
|
|
rssSourceLiveData.postValue(it) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (origin != null && link != null) { |
|
|
|
if (origin != null && link != null) { |
|
|
|
App.db.rssArticleDao().get(origin, link)?.let { rssArticle -> |
|
|
|
App.db.rssArticleDao().get(origin, link)?.let { rssArticle -> |
|
|
|
rssArticleLiveData.postValue(rssArticle) |
|
|
|
rssArticleLiveData.postValue(rssArticle) |
|
|
@ -32,7 +29,7 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
contentLiveData.postValue(rssArticle.description) |
|
|
|
contentLiveData.postValue(rssArticle.description) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
rssSource?.let { |
|
|
|
rssSource?.let { |
|
|
|
val ruleContent = rssSource.ruleContent |
|
|
|
val ruleContent = it.ruleContent |
|
|
|
if (!ruleContent.isNullOrBlank()) { |
|
|
|
if (!ruleContent.isNullOrBlank()) { |
|
|
|
loadContent(rssArticle, ruleContent) |
|
|
|
loadContent(rssArticle, ruleContent) |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -46,7 +43,12 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun loadUrl(rssArticle: RssArticle) { |
|
|
|
private fun loadUrl(rssArticle: RssArticle) { |
|
|
|
val analyzeUrl = AnalyzeUrl(rssArticle.link, baseUrl = rssArticle.origin, useWebView = true) |
|
|
|
val analyzeUrl = AnalyzeUrl( |
|
|
|
|
|
|
|
rssArticle.link, |
|
|
|
|
|
|
|
baseUrl = rssArticle.origin, |
|
|
|
|
|
|
|
useWebView = true, |
|
|
|
|
|
|
|
headerMapF = rssSource?.getHeaderMap() |
|
|
|
|
|
|
|
) |
|
|
|
urlLiveData.postValue(analyzeUrl) |
|
|
|
urlLiveData.postValue(analyzeUrl) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|