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 25760601
authored
Oct 27, 2021
by
amateur
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
c04e0456
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
6 deletions
app/src/main/java/com/polysoft/nafmii/utils/UpdateUtils.java
app/src/main/java/com/polysoft/nafmii/webview/NativeApi.java
app/src/main/res/layout/activity_input_url.xml
app/src/main/java/com/polysoft/nafmii/utils/UpdateUtils.java
View file @
2576060
...
...
@@ -31,6 +31,20 @@ public class UpdateUtils {
});
}
public
static
String
checkVersion
(
FragmentManager
manager
,
UpdateVersion
update
)
{
if
(
null
!=
update
)
{
String
upgradeType
=
update
.
getUpgradeType
();
if
(
"1"
.
equals
(
upgradeType
))
{
// h5
downH5Version
(
update
);
return
""
;
}
else
if
(
"2"
.
equals
(
upgradeType
))
{
ExecutorUtils
.
main
(()
->
UpdateDialog
.
show
(
manager
,
update
));
return
""
;
}
}
return
"参数错误"
;
}
public
static
void
checkH5Version
(
String
h5Version
)
{
ServerApi
.
postH5Version
(
h5Version
,
new
RequestBack
<
UpdateVersion
>()
{
...
...
app/src/main/java/com/polysoft/nafmii/webview/NativeApi.java
View file @
2576060
...
...
@@ -15,6 +15,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.alibaba.fastjson.util.TypeUtils
;
import
com.polysoft.nafmii.bean.MenuBean
;
import
com.polysoft.nafmii.bean.Result
;
import
com.polysoft.nafmii.bean.UpdateVersion
;
import
com.polysoft.nafmii.broadcast.PhotosReceiver
;
import
com.polysoft.nafmii.broadcast.Receiver
;
import
com.polysoft.nafmii.broadcast.WechatReceiver
;
...
...
@@ -115,7 +116,7 @@ public class NativeApi {
ShareBean
bean
=
TypeUtils
.
castToJavaBean
(
data
,
ShareBean
.
class
);
if
(
"2"
.
equals
(
bean
.
getScene
()))
{
// 分享到QQ
QQApi
instance
=
QQApi
.
getInstance
();
mActivity
.
runOnUiThread
(()
->{
mActivity
.
runOnUiThread
(()
->
{
instance
.
share
(
mActivity
,
bean
,
new
QQApi
.
JSShareCallback
(
js
));
});
}
else
{
...
...
@@ -200,7 +201,7 @@ public class NativeApi {
@JavascriptInterface
public
void
nativeEventMessage
(
String
params
)
{
new
JsInterfaceHandler
(
handler
).
parse
(
params
,
(
data
,
js
)
->
{
this
.
mActivity
.
runOnUiThread
(()->
{
this
.
mActivity
.
runOnUiThread
(()
->
{
handler
.
sendEventMessage
(
data
.
toJSONString
());
});
js
.
success
(
null
);
...
...
@@ -224,7 +225,7 @@ public class NativeApi {
name
=
FileUtils
.
getUrlFileName
(
url
);
}
final
String
fileName
=
name
;
this
.
mActivity
.
runOnUiThread
(()->
{
this
.
mActivity
.
runOnUiThread
(()
->
{
FragmentManager
manager
=
this
.
handler
.
getFragmentManager
();
DownloadDialog
.
show
(
manager
,
finalUrl
,
fileName
);
});
...
...
@@ -233,7 +234,6 @@ public class NativeApi {
}
@JavascriptInterface
public
void
nativeCamera
(
String
params
)
{
new
JsInterfaceHandler
(
handler
).
parse
(
params
,
(
data
,
js
)
->
{
...
...
@@ -270,7 +270,7 @@ public class NativeApi {
mActivity
.
runOnUiThread
(()
->
{
String
type
=
data
.
getString
(
"type"
);
if
(
"1"
.
equals
(
type
))
{
Intent
intent
=
new
Intent
();
Intent
intent
=
new
Intent
();
intent
.
setAction
(
"android.intent.action.VIEW"
);
String
linkUrl
=
data
.
getString
(
"linkUrl"
);
linkUrl
=
URLDecoder
.
decode
(
linkUrl
);
...
...
@@ -290,8 +290,27 @@ public class NativeApi {
@JavascriptInterface
public
void
nativeUpdate
(
String
param
)
{
new
JsInterfaceHandler
(
handler
).
parse
(
param
,
(
data
,
js
)
->
{
String
version
=
data
.
getString
(
"h5Version"
);
String
type
=
data
.
getString
(
"type"
);
if
(
"3"
.
equals
(
type
))
{
UpdateVersion
update
=
data
.
getObject
(
"update"
,
UpdateVersion
.
class
);
String
res
=
UpdateUtils
.
checkVersion
(
handler
.
getFragmentManager
(),
update
);
if
(!
TextUtils
.
isEmpty
(
res
))
{
js
.
callJs
(
Result
.
fail
(
res
));
return
;
}
}
else
{
String
version
=
data
.
getString
(
"version"
);
if
(
TextUtils
.
isEmpty
(
version
))
{
js
.
callJs
(
Result
.
fail
(
"参数错误"
));
return
;
}
if
(
"1"
.
equals
(
type
))
{
// 检测版本APP h5版本
UpdateUtils
.
checkVersion
(
handler
.
getFragmentManager
(),
version
);
}
else
if
(
"2"
.
equals
(
type
))
{
// 检测h5版本
UpdateUtils
.
checkH5Version
(
version
);
}
}
js
.
success
(
null
);
});
}
...
...
app/src/main/res/layout/activity_input_url.xml
View file @
2576060
...
...
@@ -56,4 +56,13 @@
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/input_url"
/>
<Button
android:id=
"@+id/button1"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"200dp"
android:text=
"测试"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/input_url"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ 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