From 2c7f2af0fa1076635bdbb11c4c0759b2beb27e8c Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 17 Nov 2019 19:11:29 +0800 Subject: [PATCH] up --- .../io/legado/app/model/analyzeRule/AnalyzeUrl.kt | 5 ++--- .../java/io/legado/app/ui/rss/read/ReadRssActivity.kt | 11 ++++++++--- .../io/legado/app/ui/rss/read/ReadRssViewModel.kt | 5 +++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt index a72ef70ec..3952cf480 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt @@ -38,7 +38,8 @@ class AnalyzeUrl( page: Int? = null, headerMapF: Map? = 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 { diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt index fd493ee3b..3a5dd609a 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt @@ -48,8 +48,10 @@ class ReadRssActivity : VMBaseActivity(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(R.layout.activity_rss_r } }) viewModel.urlLiveData.observe(this, Observer { - webView.loadUrl(it) + webView.settings.apply { + + } + webView.loadUrl(it.url) }) } 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 a4267f57d..02a5ccc89 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 @@ -15,7 +15,7 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application) { var rssArticleLiveData = MutableLiveData() val rssSourceLiveData = MutableLiveData() val contentLiveData = MutableLiveData() - val urlLiveData = MutableLiveData() + val urlLiveData = MutableLiveData() 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) {