pull/49/head
kunfei 5 years ago
parent 594676426c
commit 2c7f2af0fa
  1. 5
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt
  2. 11
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt
  3. 5
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt

@ -38,7 +38,8 @@ class AnalyzeUrl(
page: Int? = null,
headerMapF: Map<String, String>? = null,
baseUrl: String? = null,
book: BaseBook? = null
book: BaseBook? = null,
var useWebView: Boolean = false
) {
companion object {
private val pagePattern = Pattern.compile("<(.*?)>")
@ -57,8 +58,6 @@ class AnalyzeUrl(
private var bodyTxt: String? = null
private var body: RequestBody? = null
private var method = RequestMethod.GET
var useWebView: Boolean = false
private set
init {
baseUrl?.let {

@ -48,8 +48,10 @@ class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_r
private fun initWebView() {
webView.webViewClient = WebViewClient()
webView.settings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
webView.settings.domStorageEnabled = true
webView.settings.apply {
mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
domStorageEnabled = true
}
}
@SuppressLint("SetJavaScriptEnabled")
@ -81,7 +83,10 @@ class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_r
}
})
viewModel.urlLiveData.observe(this, Observer {
webView.loadUrl(it)
webView.settings.apply {
}
webView.loadUrl(it.url)
})
}

@ -15,7 +15,7 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application) {
var rssArticleLiveData = MutableLiveData<RssArticle>()
val rssSourceLiveData = MutableLiveData<RssSource>()
val contentLiveData = MutableLiveData<String>()
val urlLiveData = MutableLiveData<String>()
val urlLiveData = MutableLiveData<AnalyzeUrl>()
fun initData(intent: Intent) {
execute {
@ -46,7 +46,8 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application) {
}
private fun loadUrl(rssArticle: RssArticle) {
urlLiveData.postValue(NetworkUtils.getAbsoluteURL(rssArticle.origin, rssArticle.link))
val analyzeUrl = AnalyzeUrl(rssArticle.link, baseUrl = rssArticle.origin, useWebView = true)
urlLiveData.postValue(analyzeUrl)
}
private fun loadContent(rssArticle: RssArticle, ruleContent: String) {

Loading…
Cancel
Save