Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
polysoft-nafmii
/
polysoft-android
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 2d8eac38
authored
Oct 19, 2021
by
amateur
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
4c8b378e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
13 deletions
app/src/main/java/com/polysoft/nafmii/fragment/WebViewFragment.java
app/src/main/res/layout/fragment_webview.xml
app/src/main/res/layout/webview_error_layout.xml
app/src/main/res/mipmap-mdpi/icon_webview_error.png
app/src/main/res/values/strings.xml
app/src/main/java/com/polysoft/nafmii/fragment/WebViewFragment.java
View file @
2d8eac3
...
@@ -47,6 +47,7 @@ public class WebViewFragment extends Fragment implements WebviewLoadListener {
...
@@ -47,6 +47,7 @@ public class WebViewFragment extends Fragment implements WebviewLoadListener {
private
AVLoadingIndicatorView
mLoading
;
private
AVLoadingIndicatorView
mLoading
;
private
WebviewHandler
mWebviewHandler
;
private
WebviewHandler
mWebviewHandler
;
private
ValueCallback
<
Uri
[]>
filePathCallback
;
private
ValueCallback
<
Uri
[]>
filePathCallback
;
private
View
mErrorLayout
;
public
static
WebViewFragment
newInstance
(
String
url
)
{
public
static
WebViewFragment
newInstance
(
String
url
)
{
Bundle
args
=
new
Bundle
();
Bundle
args
=
new
Bundle
();
...
@@ -68,6 +69,7 @@ public class WebViewFragment extends Fragment implements WebviewLoadListener {
...
@@ -68,6 +69,7 @@ public class WebViewFragment extends Fragment implements WebviewLoadListener {
super
.
onViewCreated
(
view
,
savedInstanceState
);
super
.
onViewCreated
(
view
,
savedInstanceState
);
this
.
mWebviewLayout
=
view
.
findViewById
(
R
.
id
.
webview_layout
);
this
.
mWebviewLayout
=
view
.
findViewById
(
R
.
id
.
webview_layout
);
this
.
mLoading
=
view
.
findViewById
(
R
.
id
.
webview_loading
);
this
.
mLoading
=
view
.
findViewById
(
R
.
id
.
webview_loading
);
this
.
mErrorLayout
=
view
.
findViewById
(
R
.
id
.
webview_error_layout
);
this
.
initWebView
();
this
.
initWebView
();
}
}
...
@@ -97,9 +99,17 @@ public class WebViewFragment extends Fragment implements WebviewLoadListener {
...
@@ -97,9 +99,17 @@ public class WebViewFragment extends Fragment implements WebviewLoadListener {
if
(
null
==
menuBean
||
!
this
.
getTag
().
equals
(
map
.
get
(
"moduleName"
)))
{
if
(
null
==
menuBean
||
!
this
.
getTag
().
equals
(
map
.
get
(
"moduleName"
)))
{
return
;
return
;
}
}
System
.
out
.
println
(
changeRoute
);
IWebview
webview
=
this
.
getWebview
();
IWebview
webview
=
this
.
getWebview
();
JSApi
.
callOnRouteChange
(
webview
.
getWebview
(),
JSON
.
toJSONString
(
map
));
JSApi
.
callOnRouteChange
(
webview
.
getWebview
(),
JSON
.
toJSONString
(
map
));
}
else
if
(
type
==
WebviewLoadListener
.
TYPE_ERROR
)
{
this
.
mLoading
.
hide
();
this
.
mErrorLayout
.
setVisibility
(
View
.
VISIBLE
);
this
.
mErrorLayout
.
findViewById
(
R
.
id
.
webview_error_retry
).
setOnClickListener
((
v
)
->
{
X5WebviewUtils
.
destroy
(
this
.
mWebview
);
this
.
mErrorLayout
.
setVisibility
(
View
.
GONE
);
this
.
mLoading
.
show
();
this
.
initWebView
();
});
}
}
}
}
...
...
app/src/main/res/layout/fragment_webview.xml
View file @
2d8eac3
...
@@ -5,18 +5,6 @@
...
@@ -5,18 +5,6 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
>
<!-- <ImageView-->
<!-- android:visibility="gone"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- app:srcCompat="@mipmap/nav_bg"-->
<!-- tools:ignore="MissingConstraints" />-->
<!-- <include-->
<!-- android:visibility="gone"-->
<!-- android:id="@+id/webview_nav_layout"-->
<!-- layout="@layout/layout_nav" />-->
<LinearLayout
<LinearLayout
android:id=
"@+id/webview_layout"
android:id=
"@+id/webview_layout"
android:layout_width=
"0dp"
android:layout_width=
"0dp"
...
@@ -27,6 +15,21 @@
...
@@ -27,6 +15,21 @@
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
></LinearLayout>
app:layout_constraintTop_toTopOf=
"parent"
></LinearLayout>
<LinearLayout
android:id=
"@+id/webview_error_layout"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/white"
android:gravity=
"center"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<include
layout=
"@layout/webview_error_layout"
/>
</LinearLayout>
<com.wang.avi.AVLoadingIndicatorView
<com.wang.avi.AVLoadingIndicatorView
android:id=
"@+id/webview_loading"
android:id=
"@+id/webview_loading"
style=
"@style/AVLoadingIndicatorView"
style=
"@style/AVLoadingIndicatorView"
...
@@ -41,4 +44,5 @@
...
@@ -41,4 +44,5 @@
app:layout_constraintTop_toTopOf=
"@+id/webview_layout"
app:layout_constraintTop_toTopOf=
"@+id/webview_layout"
tools:ignore=
"MissingConstraints"
/>
tools:ignore=
"MissingConstraints"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
\ No newline at end of file
app/src/main/res/layout/webview_error_layout.xml
0 → 100644
View file @
2d8eac3
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
<ImageView
android:id=
"@+id/imageView"
android:layout_width=
"wrap_content"
android:layout_height=
"130dp"
android:scaleType=
"centerInside"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@mipmap/icon_webview_error"
/>
<TextView
android:id=
"@+id/textView"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"20dp"
android:text=
"页面加载错误,请重新加载"
android:textColor=
"#666"
android:textSize=
"16sp"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/imageView"
/>
<LinearLayout
android:id=
"@+id/webview_error_retry"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"5dp"
android:orientation=
"horizontal"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/textView"
tools:ignore=
"MissingConstraints"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"请点击"
android:textColor=
"#999"
android:textSize=
"14sp"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:autoLink=
"all"
android:paddingRight=
"20dp"
android:text=
"@string/retry"
android:textColor=
"#245fae"
android:textSize=
"14sp"
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
\ No newline at end of file
app/src/main/res/mipmap-mdpi/icon_webview_error.png
0 → 100644
View file @
2d8eac3
36.9 KB
app/src/main/res/values/strings.xml
View file @
2d8eac3
...
@@ -7,4 +7,5 @@
...
@@ -7,4 +7,5 @@
values-round/strings.xml for round devices.
values-round/strings.xml for round devices.
-->
-->
<string
name=
"hello_world"
>
Hello Square World!
</string>
<string
name=
"hello_world"
>
Hello Square World!
</string>
<string
name=
"retry"
><u>
重试
</u></string>
</resources>
</resources>
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment