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

@ -48,8 +48,10 @@ class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_r
private fun initWebView() { private fun initWebView() {
webView.webViewClient = WebViewClient() webView.webViewClient = WebViewClient()
webView.settings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW webView.settings.apply {
webView.settings.domStorageEnabled = true mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
domStorageEnabled = true
}
} }
@SuppressLint("SetJavaScriptEnabled") @SuppressLint("SetJavaScriptEnabled")
@ -81,7 +83,10 @@ class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_r
} }
}) })
viewModel.urlLiveData.observe(this, Observer { 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>() var rssArticleLiveData = MutableLiveData<RssArticle>()
val rssSourceLiveData = MutableLiveData<RssSource>() val rssSourceLiveData = MutableLiveData<RssSource>()
val contentLiveData = MutableLiveData<String>() val contentLiveData = MutableLiveData<String>()
val urlLiveData = MutableLiveData<String>() val urlLiveData = MutableLiveData<AnalyzeUrl>()
fun initData(intent: Intent) { fun initData(intent: Intent) {
execute { execute {
@ -46,7 +46,8 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application) {
} }
private fun loadUrl(rssArticle: RssArticle) { 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) { private fun loadContent(rssArticle: RssArticle, ruleContent: String) {

Loading…
Cancel
Save