pull/61/head^2
kunfei 5 years ago
parent 1f5ec0d839
commit 4fdc262089
  1. 5
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt
  2. 13
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt

@ -59,10 +59,11 @@ class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_r
viewModel.rssArticle?.let { viewModel.rssArticle?.let {
upJavaScriptEnable() upJavaScriptEnable()
val url = NetworkUtils.getAbsoluteURL(it.origin, it.link) val url = NetworkUtils.getAbsoluteURL(it.origin, it.link)
val html = viewModel.clHtml(content)
if (viewModel.rssSource?.loadWithBaseUrl == true) { if (viewModel.rssSource?.loadWithBaseUrl == true) {
webView.loadDataWithBaseURL(url, content, "text/html", "utf-8", url) webView.loadDataWithBaseURL(url, html, "text/html", "utf-8", url)
} else { } else {
webView.loadData(content, "text/html", "utf-8") webView.loadData(html, "text/html", "utf-8")
} }
} }
}) })

@ -77,6 +77,19 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application) {
} }
} }
fun clHtml(content: String): String {
return """
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<style>img{max-width:100% !important; width:auto; height:auto;}</style>
</head>
<body style:"height:auto;max-width: 100%; width:auto;">
$content
</body></html>
"""
}
interface CallBack { interface CallBack {
fun upStarMenu() fun upStarMenu()
} }

Loading…
Cancel
Save