|
|
@@ -0,0 +1,153 @@
|
|
|
+package cn.muchinfo.rma.view.base.home
|
|
|
+
|
|
|
+import android.graphics.Picture
|
|
|
+import android.os.Bundle
|
|
|
+import android.widget.LinearLayout
|
|
|
+import cn.muchinfo.rma.R
|
|
|
+import cn.muchinfo.rma.global.data.SiteColumnDetailData
|
|
|
+import cn.muchinfo.rma.global.toShowTime
|
|
|
+import cn.muchinfo.rma.view.autoWidget.*
|
|
|
+import cn.muchinfo.rma.view.autoWidget.utils.HtmlUtils
|
|
|
+import cn.muchinfo.rma.view.base.BaseActivity
|
|
|
+import cn.muchinfo.rma.view.base.app.Constant
|
|
|
+import cn.muchinfo.rma.view.base.future.trade.itemView
|
|
|
+import com.blankj.utilcode.util.*
|
|
|
+import com.tencent.smtt.sdk.WebChromeClient
|
|
|
+import com.tencent.smtt.sdk.WebSettings
|
|
|
+import com.tencent.smtt.sdk.WebView
|
|
|
+import com.tencent.smtt.sdk.WebViewClient
|
|
|
+import org.jetbrains.anko.custom.ankoView
|
|
|
+import org.jetbrains.anko.matchParent
|
|
|
+import org.jetbrains.anko.textView
|
|
|
+import org.jetbrains.anko.verticalLayout
|
|
|
+import org.jetbrains.anko.wrapContent
|
|
|
+
|
|
|
+/**
|
|
|
+ * 资讯详情
|
|
|
+ */
|
|
|
+class InformationDetailsActivity : BaseActivity<HomeViewModel>(){
|
|
|
+
|
|
|
+ lateinit var itemView1: X5WebView
|
|
|
+
|
|
|
+ //传过来的详情
|
|
|
+ val data by lazy { intent.getParcelableExtra<SiteColumnDetailData>("data") as SiteColumnDetailData }
|
|
|
+
|
|
|
+ override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
+ super.onCreate(savedInstanceState)
|
|
|
+ verticalLayout {
|
|
|
+ background = resources.getDrawable(R.color.main_hit_bg_color)
|
|
|
+ topBar {
|
|
|
+ commonLeftButton()
|
|
|
+ commonTitle {
|
|
|
+ text = "资讯详情"
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = data.title
|
|
|
+ textSizeAuto = 36
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ topMargin = autoSize(30)
|
|
|
+ }
|
|
|
+
|
|
|
+ textView {
|
|
|
+ text = data.publishdate
|
|
|
+ textSizeAuto = 26
|
|
|
+ textColorInt = R.color.rma_hint_text_color_ccc
|
|
|
+ }.lparams(wrapContent, wrapContent){
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ topMargin = autoSize(15)
|
|
|
+ }
|
|
|
+
|
|
|
+ itemView()
|
|
|
+
|
|
|
+ ankoView({ X5WebView(context) }, theme = 0) {
|
|
|
+ itemView1 = this
|
|
|
+ var isLoadingOver = false
|
|
|
+
|
|
|
+ try {
|
|
|
+ val newContent = HtmlUtils.replaceHtmlTag(data.context, "img", "src", "src=\"" + SPUtils.getInstance().getString(Constant.openApiUrl), "\"")
|
|
|
+ loadData(newContent, "text/html", "utf-8")
|
|
|
+// Handler().postDelayed({
|
|
|
+// loadDataWithBaseURL(null, HtmlFormat.getNewContent(newContent),"text/html","utf-8",null)
|
|
|
+// },100)
|
|
|
+
|
|
|
+ } catch (e: Exception) {
|
|
|
+ e.printStackTrace()
|
|
|
+ }
|
|
|
+ settings.layoutAlgorithm = WebSettings.LayoutAlgorithm.SINGLE_COLUMN
|
|
|
+ settings.cacheMode = WebSettings.LOAD_NO_CACHE
|
|
|
+ settings.setUserAgentString("user-agent-string")
|
|
|
+ settings.setBuiltInZoomControls(false)
|
|
|
+ settings.setSupportZoom(false)
|
|
|
+ settings.setDisplayZoomControls(false)
|
|
|
+ setWebChromeClient(object : WebChromeClient() {
|
|
|
+ override fun onReceivedTitle(view: WebView?, title: String?) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onProgressChanged(webView: WebView, progress: Int) {
|
|
|
+ if ((progress >= 100)) {
|
|
|
+ isLoadingOver = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ setWebViewClient(object : WebViewClient(){
|
|
|
+ override fun onPageFinished(view: WebView?, p1: String?) {
|
|
|
+ super.onPageFinished(view, p1)
|
|
|
+ //修改图片大小
|
|
|
+ val screenWidth = ScreenUtils.getScreenWidth().toString()
|
|
|
+// val width = SizeUtils.dp2px(50f).toString()
|
|
|
+// val width2 = SizeUtils.px2dp(screenWidth.toFloat()).toString()
|
|
|
+ LogUtils.eTag("contentHeight111112",screenWidth)
|
|
|
+ val javascript = "javascript:function ResizeImages() {" +
|
|
|
+ "var myimg,oldwidth;" +
|
|
|
+ "var maxwidth = document.body.clientWidth;" +
|
|
|
+ "for(i=0;i <document.images.length;i++){" +
|
|
|
+ "myimg = document.images[i];" +
|
|
|
+ "if(myimg.width > "+screenWidth+"){" +
|
|
|
+ "oldwidth = myimg.width;" +
|
|
|
+ "myimg.width ="+screenWidth+";" +
|
|
|
+ "}" +
|
|
|
+ "}" +
|
|
|
+ "}";
|
|
|
+ view?.loadUrl(javascript);
|
|
|
+ view?.loadUrl("javascript:ResizeImages();")
|
|
|
+
|
|
|
+ itemView1.layoutParams = LinearLayout.LayoutParams(matchParent, autoSize(view?.contentHeight?.div(0.9)?.toFloat()!!))
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+// setWebChromeClient(object : WebChromeClient(){
|
|
|
+// override fun onProgressChanged(p0: WebView?, p1: Int) {
|
|
|
+// super.onProgressChanged(p0, p1)
|
|
|
+// if (p1 == 100){
|
|
|
+// LogUtils.eTag("contentHeight111113", p0?.contentHeight)
|
|
|
+// itemView1.layoutParams = LinearLayout.LayoutParams(matchParent, autoSize(p0?.contentHeight?.div(0.9)?.toFloat()!!))
|
|
|
+// }
|
|
|
+// }
|
|
|
+// })
|
|
|
+
|
|
|
+// setPictureListener(object : WebView.PictureListener {
|
|
|
+// var previousHeight = 0
|
|
|
+// override fun onNewPicture(p0: WebView?, p1: Picture?) {
|
|
|
+// val hight = p0?.contentHeight
|
|
|
+// if (isLoadingOver) {
|
|
|
+// previousHeight = hight ?: 0
|
|
|
+//// itemView1.layoutParams = LinearLayout.LayoutParams(matchParent, autoSize(SizeUtils.dp2px(previousHeight.toFloat().times(scale))))
|
|
|
+//// itemView1.layoutParams = LinearLayout.LayoutParams(matchParent, autoSize(previousHeight.times(scale).times(0.85)))
|
|
|
+// LogUtils.eTag("contentHeight11111", "scale=====" + scale + "-------" + previousHeight.toString() + "======" + SizeUtils.dp2px(previousHeight?.toFloat()
|
|
|
+// ?: 0f))
|
|
|
+// isLoadingOver = false
|
|
|
+// }
|
|
|
+// if (previousHeight == hight) return
|
|
|
+// }
|
|
|
+//
|
|
|
+// })
|
|
|
+ }.lparams(matchParent, wrapContent)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|