pull/84/head
kunfei 5 years ago
parent 325228aab6
commit 2639db7b6c
  1. 2
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt
  2. 14
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt

@ -79,7 +79,7 @@ class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_r
"text/html", "text/html",
"utf-8", "utf-8",
url url
)//不想用baseUrl进下一个吧 )//不想用baseUrl进else
} else { } else {
webView.loadData(html, "text/html;charset=utf-8", "utf-8")//经测试可以解决中文乱码 webView.loadData(html, "text/html;charset=utf-8", "utf-8")//经测试可以解决中文乱码
} }

@ -85,12 +85,18 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application),
} }
fun clHtml(content: String): String { fun clHtml(content: String): String {
return """<style> return if (content.contains("<style>|style=".toRegex())) {
img{max-width:100%; width:auto; height:auto;} content
video{object-fit:fill; max-width:100%; width:auto; height:auto;} } else {
"""
<style>
img{max-width:100% !important; width:auto; height:auto;}
video{object-fit:fill; max-width:100% !important; width:auto; height:auto;}
body{word-wrap:break-word; height:auto;max-width: 100%; width:auto;} body{word-wrap:break-word; height:auto;max-width: 100%; width:auto;}
</style> </style>
$content""" $content
""".trimIndent()
}
} }
override fun onInit(status: Int) { override fun onInit(status: Int) {

Loading…
Cancel
Save