pull/37/head
kunfei 5 years ago
parent 3de1fcdba3
commit db6ea924fc
  1. 12
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt

@ -4,6 +4,7 @@ import android.os.Bundle
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.VMBaseActivity import io.legado.app.base.VMBaseActivity
import io.legado.app.utils.NetworkUtils
import io.legado.app.utils.getViewModel import io.legado.app.utils.getViewModel
import kotlinx.android.synthetic.main.activity_rss_read.* import kotlinx.android.synthetic.main.activity_rss_read.*
@ -19,14 +20,17 @@ class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_r
} }
private fun initLiveData() { private fun initLiveData() {
viewModel.contentLiveData.observe(this, Observer { viewModel.contentLiveData.observe(this, Observer { content ->
viewModel.rssArticle?.let {
val url = NetworkUtils.getAbsoluteURL(it.origin, it.link ?: "")
webView.loadDataWithBaseURL( webView.loadDataWithBaseURL(
viewModel.rssArticle?.link, url,
"<style>img{max-width:100%}</style>$it", "<style>img{max-width:100%}</style>$content",
"text/html", "text/html",
"utf-8", "utf-8",
viewModel.rssArticle?.link url
) )
}
}) })
viewModel.urlLiveData.observe(this, Observer { viewModel.urlLiveData.observe(this, Observer {
webView.loadUrl(it) webView.loadUrl(it)

Loading…
Cancel
Save