Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
IBMS
/
nativeview
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d3cd1707
authored
Feb 23, 2022
by
huangzhicong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善webview的设置
parent
e7cc5313
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
app/src/main/java/com/maxrocky/nativeview/fragment/MainFragment.kt
+28
-0
No files found.
app/src/main/java/com/maxrocky/nativeview/fragment/MainFragment.kt
View file @
d3cd1707
...
@@ -2,6 +2,7 @@ package com.maxrocky.nativeview.fragment
...
@@ -2,6 +2,7 @@ package com.maxrocky.nativeview.fragment
import
android.annotation.SuppressLint
import
android.annotation.SuppressLint
import
android.net.Uri
import
android.net.Uri
import
android.net.http.SslError
import
android.os.Bundle
import
android.os.Bundle
import
android.util.Log
import
android.util.Log
import
android.view.LayoutInflater
import
android.view.LayoutInflater
...
@@ -70,6 +71,16 @@ class MainFragment : Fragment() {
...
@@ -70,6 +71,16 @@ class MainFragment : Fragment() {
message
:
String
?,
message
:
String
?,
result
:
JsResult
?
result
:
JsResult
?
):
Boolean
=
false
):
Boolean
=
false
override
fun
onConsoleMessage
(
message
:
String
?,
lineNumber
:
Int
,
sourceID
:
String
?)
{
super
.
onConsoleMessage
(
message
,
lineNumber
,
sourceID
)
Log
.
d
(
TAG
,
"onConsoleMessage: $message\nlineNumber: $lineNumber\nsourceID: $sourceID"
)
}
override
fun
onConsoleMessage
(
consoleMessage
:
ConsoleMessage
?):
Boolean
{
Log
.
d
(
TAG
,
"onConsoleMessage: ${consoleMessage?.message()}\nmessageLevel: ${consoleMessage?.messageLevel()}\nlineNumber: ${consoleMessage?.lineNumber()}\nsourceID: ${consoleMessage?.sourceId()}"
)
return
super
.
onConsoleMessage
(
consoleMessage
)
}
}
}
wv
.
webViewClient
=
object
:
WebViewClient
()
{
wv
.
webViewClient
=
object
:
WebViewClient
()
{
override
fun
shouldOverrideUrlLoading
(
view
:
WebView
?,
url
:
String
?):
Boolean
{
override
fun
shouldOverrideUrlLoading
(
view
:
WebView
?,
url
:
String
?):
Boolean
{
...
@@ -84,9 +95,26 @@ class MainFragment : Fragment() {
...
@@ -84,9 +95,26 @@ class MainFragment : Fragment() {
Log
.
d
(
TAG
,
"shouldOverrideUrlLoading new: ${request?.url}"
)
Log
.
d
(
TAG
,
"shouldOverrideUrlLoading new: ${request?.url}"
)
return
super
.
shouldOverrideUrlLoading
(
view
,
request
)
return
super
.
shouldOverrideUrlLoading
(
view
,
request
)
}
}
override
fun
onReceivedSslError
(
view
:
WebView
?,
handler
:
SslErrorHandler
?,
error
:
SslError
?
)
{
handler
?.
proceed
()
}
}
}
wv
.
settings
.
apply
{
wv
.
settings
.
apply
{
javaScriptEnabled
=
true
javaScriptEnabled
=
true
javaScriptCanOpenWindowsAutomatically
=
true
cacheMode
=
WebSettings
.
LOAD_NO_CACHE
domStorageEnabled
=
true
databaseEnabled
=
true
allowFileAccess
=
true
setSupportZoom
(
true
)
builtInZoomControls
=
true
layoutAlgorithm
=
WebSettings
.
LayoutAlgorithm
.
NORMAL
useWideViewPort
=
true
}
}
wv
.
addJavascriptInterface
(
WebInterface
(),
"maxrocky"
)
wv
.
addJavascriptInterface
(
WebInterface
(),
"maxrocky"
)
var
url
=
arguments
?.
getString
(
ARG_URL
)
var
url
=
arguments
?.
getString
(
ARG_URL
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment