feat(webview): 添加 onProgressChanged 回调,支持页面加载进度监听
这个提交包含在:
父节点
30ce89afcc
当前提交
0ec173677d
@ -18,6 +18,8 @@ data class XWebViewConfig(
|
||||
val onMessage: ((String) -> Unit)? = null,
|
||||
/** 页面加载失败时回调。errorCode / description / failingUrl 对应 WebViewClient.onReceivedError 参数。 */
|
||||
val onPageError: ((errorCode: Int, description: String, failingUrl: String) -> Unit)? = null,
|
||||
/** 页面加载进度回调(0-100)。 */
|
||||
val onProgressChanged: ((Int) -> Unit)? = null,
|
||||
)
|
||||
|
||||
interface XWebViewController {
|
||||
|
||||
@ -548,6 +548,11 @@ fun XWebViewView(
|
||||
}
|
||||
|
||||
webChromeClient = object : WebChromeClient() {
|
||||
override fun onProgressChanged(view: WebView?, newProgress: Int) {
|
||||
super.onProgressChanged(view, newProgress)
|
||||
mainHandler.post { config.onProgressChanged?.invoke(newProgress) }
|
||||
}
|
||||
|
||||
override fun onPermissionRequest(request: PermissionRequest) {
|
||||
if (PermissionRequest.RESOURCE_VIDEO_CAPTURE in request.resources) {
|
||||
if (ContextCompat.checkSelfPermission(ctx, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户