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 d642e23c
authored
Nov 03, 2021
by
amateur
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
b64defb3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
17 deletions
app/src/main/java/com/polysoft/nafmii/fragment/home/ModulesFragmentMgr.java
app/src/main/java/com/polysoft/nafmii/utils/SpUtils.java
app/src/main/java/com/polysoft/nafmii/utils/UpdateUtils.java
app/src/main/java/com/polysoft/nafmii/utils/WebVersionUtils.java
app/src/main/java/com/polysoft/nafmii/fragment/home/ModulesFragmentMgr.java
View file @
d642e23
...
@@ -35,9 +35,11 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
...
@@ -35,9 +35,11 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
}
}
public
void
showInitFragment
(
ModulesEnum
[]
modules
)
{
public
void
showInitFragment
(
ModulesEnum
[]
modules
)
{
// for (ModulesEnum module : modules) {
for
(
ModulesEnum
module
:
modules
)
{
// this.findNewModuleFragment(module);
if
(
module
!=
ModulesEnum
.
LEARN
)
{
// }
this
.
findNewModuleFragment
(
module
);
}
}
this
.
showModule
(
modules
[
0
]);
this
.
showModule
(
modules
[
0
]);
}
}
...
...
app/src/main/java/com/polysoft/nafmii/utils/SpUtils.java
View file @
d642e23
...
@@ -12,18 +12,18 @@ public class SpUtils {
...
@@ -12,18 +12,18 @@ public class SpUtils {
// H5版本
// H5版本
public
static
final
String
KEY_H5_VERSION
=
"H5_VERSION"
;
public
static
final
String
KEY_H5_VERSION
=
"H5_VERSION"
;
public
static
void
putBoolean
(
String
key
,
boolean
val
)
{
public
static
boolean
putBoolean
(
String
key
,
boolean
val
)
{
SharedPreferences
.
Editor
edit
=
getSpMgr
().
edit
();
SharedPreferences
.
Editor
edit
=
getSpMgr
().
edit
();
edit
.
putBoolean
(
key
,
val
).
commit
();
return
edit
.
putBoolean
(
key
,
val
).
commit
();
}
}
public
static
boolean
getBoolean
(
String
key
,
boolean
def
)
{
public
static
boolean
getBoolean
(
String
key
,
boolean
def
)
{
return
getSpMgr
().
getBoolean
(
key
,
def
);
return
getSpMgr
().
getBoolean
(
key
,
def
);
}
}
public
static
void
putString
(
String
key
,
String
val
)
{
public
static
boolean
putString
(
String
key
,
String
val
)
{
SharedPreferences
.
Editor
edit
=
getSpMgr
().
edit
();
SharedPreferences
.
Editor
edit
=
getSpMgr
().
edit
();
edit
.
putString
(
key
,
val
).
commit
();
return
edit
.
putString
(
key
,
val
).
commit
();
}
}
public
static
String
getString
(
String
key
,
String
def
)
{
public
static
String
getString
(
String
key
,
String
def
)
{
...
...
app/src/main/java/com/polysoft/nafmii/utils/UpdateUtils.java
View file @
d642e23
...
@@ -20,14 +20,19 @@ public class UpdateUtils {
...
@@ -20,14 +20,19 @@ public class UpdateUtils {
ServerApi
.
postAppVersion
(
new
RequestBack
<
UpdateVersion
>()
{
ServerApi
.
postAppVersion
(
new
RequestBack
<
UpdateVersion
>()
{
@Override
@Override
protected
void
onResponse
(
StateEnum
state
,
UpdateVersion
data
,
String
message
)
{
protected
void
onResponse
(
StateEnum
state
,
UpdateVersion
data
,
String
message
)
{
// 非强制更新是,需要同时进行h5版本更新
if
(
state
!=
StateEnum
.
OK
||
null
==
data
||
!
isMustUpdate
(
data
)
||
!
isUpdateApp
(
data
))
{
if
(
state
==
StateEnum
.
OK
&&
null
!=
data
&&
!
TextUtils
.
isEmpty
(
data
.
getvNumber
()))
{
if
(!
TextUtils
.
isEmpty
(
h5Version
))
{
ExecutorUtils
.
main
(()
->
UpdateDialog
.
show
(
manager
,
data
));
checkH5Version
(
h5Version
);
// 必升版本 不更新h5
if
(
isMustUpdate
(
data
))
{
return
;
}
}
return
;
}
}
ExecutorUtils
.
main
(()
->
UpdateDialog
.
show
(
manager
,
data
));
if
(!
TextUtils
.
isEmpty
(
h5Version
))
{
checkH5Version
(
h5Version
);
}
}
}
});
});
}
}
...
@@ -70,6 +75,7 @@ public class UpdateUtils {
...
@@ -70,6 +75,7 @@ public class UpdateUtils {
if
(!
url
.
startsWith
(
"http"
))
{
if
(!
url
.
startsWith
(
"http"
))
{
url
=
BuildConfig
.
IMG_API
+
url
;
url
=
BuildConfig
.
IMG_API
+
url
;
}
}
WebVersionUtils
.
deleteOldDist
();
File
file
=
WebVersionUtils
.
getDistZip
(
update
.
getvNumber
());
File
file
=
WebVersionUtils
.
getDistZip
(
update
.
getvNumber
());
OkhttpApi
.
doDownload
(
url
,
file
,
new
OkhttpApi
.
IDownListener
()
{
OkhttpApi
.
doDownload
(
url
,
file
,
new
OkhttpApi
.
IDownListener
()
{
@Override
@Override
...
@@ -78,8 +84,7 @@ public class UpdateUtils {
...
@@ -78,8 +84,7 @@ public class UpdateUtils {
try
{
try
{
File
oldDistDir
=
WebVersionUtils
.
getDistDir
();
File
oldDistDir
=
WebVersionUtils
.
getDistDir
();
ZipUtils
.
unZip
(
file
,
file
.
getParentFile
());
ZipUtils
.
unZip
(
file
,
file
.
getParentFile
());
WebVersionUtils
.
setVersion
(
update
.
getvNumber
());
WebVersionUtils
.
setNewVersion
(
update
.
getvNumber
());
FileUtils
.
deletes
(
oldDistDir
.
getParentFile
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
app/src/main/java/com/polysoft/nafmii/utils/WebVersionUtils.java
View file @
d642e23
...
@@ -10,8 +10,19 @@ public class WebVersionUtils {
...
@@ -10,8 +10,19 @@ public class WebVersionUtils {
return
SpUtils
.
getString
(
SpUtils
.
KEY_H5_VERSION
,
BuildConfig
.
H5_VERSION
);
return
SpUtils
.
getString
(
SpUtils
.
KEY_H5_VERSION
,
BuildConfig
.
H5_VERSION
);
}
}
public
static
void
setVersion
(
String
name
)
{
public
static
void
setNewVersion
(
String
version
)
{
SpUtils
.
putString
(
SpUtils
.
KEY_H5_VERSION
,
name
);
SpUtils
.
putString
(
SpUtils
.
KEY_H5_VERSION
,
version
);
}
public
static
void
deleteOldDist
()
{
String
version
=
getVersion
();
File
hotDir
=
FileUtils
.
getHotDir
();
File
[]
files
=
hotDir
.
listFiles
();
for
(
File
file
:
files
)
{
if
(!
version
.
equals
(
file
.
getName
()))
{
FileUtils
.
deletes
(
file
);
}
}
}
}
public
static
File
getIndex
()
{
public
static
File
getIndex
()
{
...
...
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