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 739ad685
authored
Jul 21, 2021
by
amateur
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
73f4f731
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
17 deletions
app/src/main/java/com/polysoft/nafmii/fragment/home/ModuleUrlHandle.java
app/src/main/java/com/polysoft/nafmii/fragment/home/ModuleUrlHandle.java
View file @
739ad68
...
...
@@ -2,30 +2,41 @@ package com.polysoft.nafmii.fragment.home;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.text.TextUtils
;
import
com.alibaba.fastjson.JSON
;
import
com.polysoft.nafmii.bean.MenuBean
;
import
com.polysoft.nafmii.constants.Constants
;
import
com.polysoft.nafmii.constants.JsApi
;
import
com.polysoft.nafmii.enums.JSMethodsEnum
;
import
com.polysoft.nafmii.enums.ModulesEnum
;
import
com.polysoft.nafmii.utils.FileUtils
;
import
com.polysoft.nafmii.webview.IWebview
;
import
com.polysoft.nafmii.webview.JavaToJsinterface
;
import
com.polysoft.nafmii.webview.JSApi
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
ModuleUrlHandle
{
private
final
Activity
activity
;
private
IModuleHandle
moduleUrl
,
moduleBean
;
ModuleUrlHandle
(
Activity
activity
)
{
this
.
activity
=
activity
;
}
public
IModuleHandle
getModuleHandle
(
ModulesEnum
module
)
{
return
new
ModuleUrlImpl
(
module
);
if
(
null
==
this
.
moduleUrl
)
{
this
.
moduleUrl
=
new
ModuleUrlImpl
(
module
);
}
return
this
.
moduleUrl
;
}
public
IModuleHandle
getModuleHandle
(
MenuBean
bean
)
{
return
new
ModuleBeanImpl
(
bean
);
if
(
null
==
this
.
moduleBean
)
{
this
.
moduleBean
=
new
ModuleBeanImpl
(
bean
);
}
return
this
.
moduleBean
;
}
public
String
getModuleUrl
(
ModulesEnum
module
)
{
...
...
@@ -34,13 +45,11 @@ public class ModuleUrlHandle {
if
(!
TextUtils
.
isEmpty
(
url
))
{
return
url
;
}
if
(
module
==
ModulesEnum
.
HOME
)
{
return
Constants
.
MODULE_URL_HOME
;
}
else
if
(
module
==
ModulesEnum
.
LEARN
)
{
if
(
module
==
ModulesEnum
.
LEARN
)
{
return
Constants
.
MODULE_URL_LEARN
;
}
return
""
;
String
indexUrl
=
Uri
.
fromFile
(
FileUtils
.
getIndex
()).
toString
();
return
indexUrl
+
module
.
webUrl
;
}
public
interface
IModuleHandle
{
...
...
@@ -50,6 +59,7 @@ public class ModuleUrlHandle {
void
loadUrl
(
IWebview
webview
);
}
static
class
ModuleBeanImpl
implements
IModuleHandle
{
private
final
MenuBean
bean
;
...
...
@@ -66,10 +76,12 @@ public class ModuleUrlHandle {
public
void
loadUrl
(
IWebview
webview
)
{
if
(!
TextUtils
.
isEmpty
(
bean
.
getUrl
()))
{
webview
.
loadUrl
(
bean
.
getUrl
());
}
else
if
(!
TextUtils
.
isEmpty
(
bean
.
getRouteName
()))
{
webview
.
getJsInterface
().
callJs
(
JSMethodsEnum
.
CALL_CHANGE_ROUTE
,
""
);
}
else
if
(!
TextUtils
.
isEmpty
(
bean
.
getRoutePath
()))
{
webview
.
getJsInterface
().
callJs
(
JSMethodsEnum
.
CALL_CHANGE_ROUTE
,
""
);
}
else
if
(!
TextUtils
.
isEmpty
(
bean
.
getRouteName
())
||
!
TextUtils
.
isEmpty
(
bean
.
getRoutePath
()))
{
Map
<
String
,
String
>
map
=
new
HashMap
<>(
2
);
map
.
put
(
"routePath"
,
bean
.
getRoutePath
());
map
.
put
(
"routeName"
,
bean
.
getRouteName
());
JSApi
.
callOnRouteChange
(
webview
.
getWebview
(),
JSON
.
toJSONString
(
map
));
}
}
}
...
...
@@ -91,11 +103,8 @@ public class ModuleUrlHandle {
Intent
intent
=
activity
.
getIntent
();
String
url
=
intent
.
getStringExtra
(
module
.
name
);
if
(!
TextUtils
.
isEmpty
(
url
))
{
JavaToJsinterface
jsInterface
=
webview
.
getJsInterface
();
if
(
module
==
ModulesEnum
.
MEMBER
)
{
webview
.
getJsInterface
().
callJs
(
JSMethodsEnum
.
CALL_CHANGE_ROUTE
,
""
);
}
else
if
(
module
==
ModulesEnum
.
MY
)
{
webview
.
getJsInterface
().
callJs
(
JSMethodsEnum
.
CALL_CHANGE_ROUTE
,
""
);
}
else
{
webview
.
loadUrl
(
url
);
}
...
...
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