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 5a619f2c
authored
Sep 03, 2021
by
amateur
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
65a1d282
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
56 additions
and
6 deletions
app/src/main/java/com/polysoft/nafmii/bean/MenuBean.java
app/src/main/java/com/polysoft/nafmii/fragment/home/ModuleUrlHandle.java
app/src/main/java/com/polysoft/nafmii/fragment/home/ModulesFragmentMgr.java
app/src/main/java/com/polysoft/nafmii/webview/HomeWebviewHandler.java
app/src/main/java/com/polysoft/nafmii/webview/JSApi.java
app/src/main/java/com/polysoft/nafmii/webview/NativeApi.java
app/src/main/java/com/polysoft/nafmii/webview/WebviewHandler.java
app/src/main/java/com/polysoft/nafmii/bean/MenuBean.java
View file @
5a619f2
...
@@ -23,6 +23,9 @@ public class MenuBean {
...
@@ -23,6 +23,9 @@ public class MenuBean {
@JSONField
(
name
=
"routeName"
)
@JSONField
(
name
=
"routeName"
)
private
String
routeName
;
private
String
routeName
;
@JSONField
(
name
=
"query"
)
private
Object
query
;
public
boolean
isShow
()
{
public
boolean
isShow
()
{
return
SHOW
.
equals
(
this
.
type
);
return
SHOW
.
equals
(
this
.
type
);
...
@@ -71,4 +74,12 @@ public class MenuBean {
...
@@ -71,4 +74,12 @@ public class MenuBean {
public
void
setRouteName
(
String
routeName
)
{
public
void
setRouteName
(
String
routeName
)
{
this
.
routeName
=
routeName
;
this
.
routeName
=
routeName
;
}
}
public
Object
getQuery
()
{
return
query
;
}
public
void
setQuery
(
Object
query
)
{
this
.
query
=
query
;
}
}
}
app/src/main/java/com/polysoft/nafmii/fragment/home/ModuleUrlHandle.java
View file @
5a619f2
...
@@ -54,8 +54,8 @@ public class ModuleUrlHandle {
...
@@ -54,8 +54,8 @@ public class ModuleUrlHandle {
// }
// }
// Uri uri = Uri.parse(urlStr);
// Uri uri = Uri.parse(urlStr);
// return uri.getScheme() +":"+ uri.getSchemeSpecificPart() + module.webUrl;
// return uri.getScheme() +":"+ uri.getSchemeSpecificPart() + module.webUrl;
//
return "http://10.10.81.189/h5/?"+System.currentTimeMillis() + module.webUrl;
return
"http://10.10.81.189/h5/?"
+
System
.
currentTimeMillis
()
+
module
.
webUrl
;
return
"http://192.168.137.1:8080/"
+
System
.
currentTimeMillis
()
+
module
.
webUrl
;
//
return "http://192.168.137.1:8080/"+System.currentTimeMillis() + module.webUrl;
}
}
return
intent
.
getStringExtra
(
module
.
name
);
return
intent
.
getStringExtra
(
module
.
name
);
}
}
...
@@ -86,9 +86,10 @@ public class ModuleUrlHandle {
...
@@ -86,9 +86,10 @@ public class ModuleUrlHandle {
webview
.
loadUrl
(
bean
.
getUrl
());
webview
.
loadUrl
(
bean
.
getUrl
());
}
else
if
(!
TextUtils
.
isEmpty
(
bean
.
getRouteName
())
}
else
if
(!
TextUtils
.
isEmpty
(
bean
.
getRouteName
())
||
!
TextUtils
.
isEmpty
(
bean
.
getRoutePath
()))
{
||
!
TextUtils
.
isEmpty
(
bean
.
getRoutePath
()))
{
Map
<
String
,
String
>
map
=
new
HashMap
<>(
2
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
2
);
map
.
put
(
"routePath"
,
bean
.
getRoutePath
());
map
.
put
(
"routePath"
,
bean
.
getRoutePath
());
map
.
put
(
"routeName"
,
bean
.
getRouteName
());
map
.
put
(
"routeName"
,
bean
.
getRouteName
());
map
.
put
(
"query"
,
bean
.
getQuery
());
JSApi
.
callOnRouteChange
(
webview
.
getWebview
(),
JSON
.
toJSONString
(
map
));
JSApi
.
callOnRouteChange
(
webview
.
getWebview
(),
JSON
.
toJSONString
(
map
));
}
}
}
}
...
...
app/src/main/java/com/polysoft/nafmii/fragment/home/ModulesFragmentMgr.java
View file @
5a619f2
...
@@ -102,6 +102,9 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
...
@@ -102,6 +102,9 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
if
(!
module
.
fmtKey
.
equals
(
this
.
currentModule
.
fmtKey
))
{
if
(!
module
.
fmtKey
.
equals
(
this
.
currentModule
.
fmtKey
))
{
this
.
showModuleFragment
(
fragment
);
this
.
showModuleFragment
(
fragment
);
if
(
null
!=
fragment
)
{
handle
.
loadUrl
(
fragment
.
getWebview
());
}
}
else
{
}
else
{
handle
.
loadUrl
(
fragment
.
getWebview
());
handle
.
loadUrl
(
fragment
.
getWebview
());
}
}
...
@@ -124,7 +127,7 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
...
@@ -124,7 +127,7 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
FragmentTransaction
transaction
=
this
.
manager
.
beginTransaction
();
FragmentTransaction
transaction
=
this
.
manager
.
beginTransaction
();
WebViewFragment
currentFragment
=
this
.
getCurrentFragment
();
WebViewFragment
currentFragment
=
this
.
getCurrentFragment
();
if
(
null
!=
currentFragment
)
{
if
(
null
!=
currentFragment
)
{
transaction
.
hide
(
currentFragment
)
.
addToBackStack
(
""
)
;
transaction
.
hide
(
currentFragment
);
}
}
transaction
.
show
(
fragment
).
commit
();
transaction
.
show
(
fragment
).
commit
();
}
}
...
...
app/src/main/java/com/polysoft/nafmii/webview/HomeWebviewHandler.java
View file @
5a619f2
...
@@ -4,10 +4,12 @@ import androidx.fragment.app.Fragment;
...
@@ -4,10 +4,12 @@ import androidx.fragment.app.Fragment;
import
androidx.fragment.app.FragmentManager
;
import
androidx.fragment.app.FragmentManager
;
import
com.polysoft.nafmii.bean.MenuBean
;
import
com.polysoft.nafmii.bean.MenuBean
;
import
com.polysoft.nafmii.enums.ModulesEnum
;
import
com.polysoft.nafmii.fragment.WebViewFragment
;
import
com.polysoft.nafmii.fragment.WebViewFragment
;
import
com.tencent.smtt.sdk.WebView
;
import
com.tencent.smtt.sdk.WebView
;
import
com.whaty.nafmii.activity.HomeActivity
;
import
com.whaty.nafmii.activity.HomeActivity
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
public
class
HomeWebviewHandler
extends
WebviewHandler
{
public
class
HomeWebviewHandler
extends
WebviewHandler
{
...
@@ -26,10 +28,14 @@ public class HomeWebviewHandler extends WebviewHandler {
...
@@ -26,10 +28,14 @@ public class HomeWebviewHandler extends WebviewHandler {
public
void
setTextZoom
(
int
zoom
)
{
public
void
setTextZoom
(
int
zoom
)
{
FragmentManager
manager
=
super
.
getFragmentManager
();
FragmentManager
manager
=
super
.
getFragmentManager
();
List
<
Fragment
>
fragments
=
manager
.
getFragments
();
List
<
Fragment
>
fragments
=
manager
.
getFragments
();
String
[]
fmtKeys
=
new
String
[]{
ModulesEnum
.
MY
.
fmtKey
,
ModulesEnum
.
HOME
.
fmtKey
,
ModulesEnum
.
MEMBER
.
fmtKey
};
List
<
String
>
tags
=
Arrays
.
asList
(
fmtKeys
);
for
(
Fragment
fmt
:
fragments
)
{
for
(
Fragment
fmt
:
fragments
)
{
String
tag
=
fmt
.
getTag
();
String
tag
=
fmt
.
getTag
();
IWebview
webview
=
((
WebViewFragment
)
fmt
).
getWebview
();
if
(
tags
.
indexOf
(
tag
)
>
0
)
{
webview
.
getWebview
().
getSettings
().
setTextZoom
(
zoom
);
IWebview
webview
=
((
WebViewFragment
)
fmt
).
getWebview
();
webview
.
getWebview
().
getSettings
().
setTextZoom
(
zoom
);
}
}
}
}
}
}
}
app/src/main/java/com/polysoft/nafmii/webview/JSApi.java
View file @
5a619f2
...
@@ -22,6 +22,10 @@ public class JSApi {
...
@@ -22,6 +22,10 @@ public class JSApi {
callJs
(
webView
,
"onPushMessage"
,
json
);
callJs
(
webView
,
"onPushMessage"
,
json
);
}
}
public
static
void
callOnEventMessage
(
WebView
webView
,
String
json
)
{
callJs
(
webView
,
"onEventMessage"
,
json
);
}
public
static
void
callJs
(
WebView
webView
,
String
methodName
,
String
json
)
{
public
static
void
callJs
(
WebView
webView
,
String
methodName
,
String
json
)
{
String
param
=
JSON
.
toJSONString
(
json
);
String
param
=
JSON
.
toJSONString
(
json
);
...
...
app/src/main/java/com/polysoft/nafmii/webview/NativeApi.java
View file @
5a619f2
...
@@ -165,6 +165,16 @@ public class NativeApi {
...
@@ -165,6 +165,16 @@ public class NativeApi {
}
}
@JavascriptInterface
@JavascriptInterface
public
void
nativeEventMessage
(
String
params
)
{
new
JsInterfaceHandler
(
handler
).
parse
(
params
,
(
data
,
js
)
->
{
this
.
mActivity
.
runOnUiThread
(()->{
handler
.
sendEventMessage
(
data
.
toJSONString
());
});
js
.
success
(
null
);
});
}
@JavascriptInterface
public
void
nativeDownload
(
String
params
)
{
public
void
nativeDownload
(
String
params
)
{
new
JsInterfaceHandler
(
handler
).
parse
(
params
,
(
data
,
js
)
->
{
new
JsInterfaceHandler
(
handler
).
parse
(
params
,
(
data
,
js
)
->
{
String
url
=
data
.
getString
(
"url"
);
String
url
=
data
.
getString
(
"url"
);
...
...
app/src/main/java/com/polysoft/nafmii/webview/WebviewHandler.java
View file @
5a619f2
...
@@ -6,9 +6,12 @@ import androidx.fragment.app.Fragment;
...
@@ -6,9 +6,12 @@ import androidx.fragment.app.Fragment;
import
androidx.fragment.app.FragmentManager
;
import
androidx.fragment.app.FragmentManager
;
import
com.polysoft.nafmii.bean.MenuBean
;
import
com.polysoft.nafmii.bean.MenuBean
;
import
com.polysoft.nafmii.fragment.WebViewFragment
;
import
com.tencent.smtt.sdk.WebView
;
import
com.tencent.smtt.sdk.WebView
;
import
com.whaty.nafmii.activity.HomeActivity
;
import
com.whaty.nafmii.activity.HomeActivity
;
import
java.util.List
;
public
class
WebviewHandler
implements
IWebview
{
public
class
WebviewHandler
implements
IWebview
{
private
static
final
String
TAG
=
WebviewHandler
.
class
.
getName
();
private
static
final
String
TAG
=
WebviewHandler
.
class
.
getName
();
...
@@ -70,6 +73,18 @@ public class WebviewHandler implements IWebview {
...
@@ -70,6 +73,18 @@ public class WebviewHandler implements IWebview {
public
void
setButtomMenu
(
MenuBean
bean
)
{
public
void
setButtomMenu
(
MenuBean
bean
)
{
}
}
public
void
sendEventMessage
(
String
json
)
{
List
<
Fragment
>
fragments
=
this
.
getFragmentManager
().
getFragments
();
for
(
Fragment
fmt
:
fragments
)
{
if
(
fmt
instanceof
WebViewFragment
)
{
WebViewFragment
webFmt
=
(
WebViewFragment
)
fmt
;
IWebview
webview
=
webFmt
.
getWebview
();
JSApi
.
callOnEventMessage
(
webview
.
getWebview
(),
json
);
}
}
}
protected
FragmentManager
getFragmentManager
()
{
protected
FragmentManager
getFragmentManager
()
{
return
this
.
fragment
.
getActivity
().
getSupportFragmentManager
();
return
this
.
fragment
.
getActivity
().
getSupportFragmentManager
();
}
}
...
...
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