Merge pull request #7 from gedoor/master

up
pull/61/head^2
口口吕 5 years ago committed by GitHub
commit 76e80edd17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      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,20 +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( webView.loadDataWithBaseURL(url, html, "text/html", "utf-8", url)
url,
"<style>img{max-width:100%}</style>$content",
"text/html",
"utf-8",
url
)
} else { } else {
webView.loadData( webView.loadData(html, "text/html", "utf-8")
"<style>img{max-width:100%}</style>$content",
"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