Commit 84364bb0 by 霍志良

feat:底部webview

parent 3c9e7f44
......@@ -90,6 +90,7 @@ dependencies {
implementation 'com.netease.nimlib:nrtc:9.1.1'
api rootProject.ext.dependencies["ydl-user-router"]
implementation rootProject.ext.dependencies["BaseRecyclerViewAdapterHelper"]
api 'com.tencent.tbs.tbssdk:sdk:43903'
if (rootProject.ext.dev_mode){
//开发时使用
......
......@@ -36,7 +36,7 @@ class ExpertConsultServiceListDialog(val mContext: Context, val mList: List<Serv
private var mConsultServiceListView: ExpertConsultServiceView? = null
private var mConsultServiceDetailView: ExpertConsultServiceDetailView? = null
private var mWebviewView: ? = null
private var mWebviewView: ExpertConsultWebview? = null
private var mViewList: ArrayList<View> = ArrayList()
private var mSelectType: String = "全部"
......
package com.yidianling.uikit.custom.widget.expertConsultService.view
import android.app.Activity
import android.content.Context
import android.net.Uri
import android.view.View
import android.widget.RelativeLayout
import com.tencent.smtt.export.external.interfaces.JsResult
import com.tencent.smtt.sdk.*
import com.ydl.utils.WebUrlParamsUtils
import com.ydl.webview.ProgressWebView
import com.ydl.webview.TellData
import com.ydl.webview.WebModularServiceUtils
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.im.R
import com.yidianling.uikit.custom.widget.expertConsultService.callback.ConsultServiceViewCallback
class ExpertConsultWebview : RelativeLayout {
constructor(context: Context) : super(context) {
mContext = context
initView()
}
private var mListener: ConsultServiceViewCallback? = null
private var mContext: Context? = null
private fun initView() {
val mWidth: Int = RxDeviceTool.getScreenWidth(mContext)
val mHeight: Int = LayoutParams.MATCH_PARENT
val params = LayoutParams(
mWidth,
mHeight
)
params.height = mHeight
layoutParams = params
View.inflate(mContext, R.layout.im_expert_consult_webview_view, this)
}
fun webViewInit(wv_content: ProgressWebView) {
val setting: WebSettings = wv_content?.settings!!
//支持js
//支持js
setting.setJavaScriptEnabled(true)
//设置字符编码
//设置字符编码
setting.setDefaultTextEncodingName("GBK")
setting.setDomStorageEnabled(true)
val appCachePath: String = mContext?.getCacheDir()?.getAbsolutePath().toString()
setting.setAppCachePath(appCachePath)
setting.setAllowFileAccessFromFileURLs(true)
setting.setAppCacheEnabled(true)
setting.setAllowFileAccess(true)
setting.setBlockNetworkImage(false)
wv_content!!.scrollBarStyle = View.SCROLLBARS_INSIDE_OVERLAY //滚动条风格,为0指滚动条不占用空间,直接覆盖在网页上
val jtoJHandle = WebModularServiceUtils.getWebService()
.getJavascripHandler(mContext as Activity, tellData = TellData())
wv_content!!.addJavascriptInterface(jtoJHandle, "javascriptHandler")
var jumpurl = "http://192.168.210.152/jy/listenMask?listenerId=257&isFromApp=1"
val url = WebUrlParamsUtils.getSuffix(jumpurl, jtoJHandle.getUriAppendSuffix())
wv_content.loadUrl(url)
// wv_content.loadUrl(jumpUrl)
wv_content.webViewClient = object : WebViewClient() {
override fun shouldOverrideUrlLoading(webview: WebView, url: String?): Boolean {
if (url.isNullOrBlank()) return false
return shouldOverridePayUrl(webview, url)
}
}
wv_content.webChromeClient = object : WebChromeClient() {
override fun onJsAlert(
webView: WebView,
s: String,
s1: String,
jsResult: JsResult
): Boolean {
return super.onJsAlert(webView, s, s1, jsResult)
}
override fun onProgressChanged(view: WebView, newProgress: Int) {
super.onProgressChanged(view, newProgress)
}
override fun onReceivedTitle(view: WebView, title: String) {
super.onReceivedTitle(view, title)
}
// For Android < 3.0
fun openFileChooser(valueCallback: ValueCallback<Uri?>) {
}
// For Android >= 3.0
fun openFileChooser(valueCallback: ValueCallback<*>, acceptType: String?) {
}
//For Android >= 4.1
override fun openFileChooser(
valueCallback: ValueCallback<Uri>,
acceptType: String,
capture: String
) {
}
// For Android >= 5.0
override fun onShowFileChooser(
webView: WebView,
filePathCallback: ValueCallback<Array<Uri>>,
fileChooserParams: FileChooserParams
): Boolean {
return true
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="MissingDefaultResource">
<com.ydl.webview.ProgressWebView
android:id="@+id/wv_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment