Commit d642e23c by amateur

1

1 parent b64defb3
......@@ -35,9 +35,11 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
}
public void showInitFragment(ModulesEnum[] modules) {
// for (ModulesEnum module : modules) {
// this.findNewModuleFragment(module);
// }
for (ModulesEnum module : modules) {
if (module != ModulesEnum.LEARN) {
this.findNewModuleFragment(module);
}
}
this.showModule(modules[0]);
}
......
......@@ -12,18 +12,18 @@ public class SpUtils {
// H5版本
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();
edit.putBoolean(key, val).commit();
return edit.putBoolean(key, val).commit();
}
public static boolean getBoolean(String key, boolean 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();
edit.putString(key, val).commit();
return edit.putString(key, val).commit();
}
public static String getString(String key, String def) {
......
......@@ -20,14 +20,19 @@ public class UpdateUtils {
ServerApi.postAppVersion(new RequestBack<UpdateVersion>() {
@Override
protected void onResponse(StateEnum state, UpdateVersion data, String message) {
// 非强制更新是,需要同时进行h5版本更新
if (state != StateEnum.OK || null == data || !isMustUpdate(data) || !isUpdateApp(data)) {
if (!TextUtils.isEmpty(h5Version)) {
checkH5Version(h5Version);
if (state == StateEnum.OK && null != data && !TextUtils.isEmpty(data.getvNumber())) {
ExecutorUtils.main(() -> UpdateDialog.show(manager, data));
// 必升版本 不更新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 {
if (!url.startsWith("http")) {
url = BuildConfig.IMG_API + url;
}
WebVersionUtils.deleteOldDist();
File file = WebVersionUtils.getDistZip(update.getvNumber());
OkhttpApi.doDownload(url, file, new OkhttpApi.IDownListener() {
@Override
......@@ -78,8 +84,7 @@ public class UpdateUtils {
try {
File oldDistDir = WebVersionUtils.getDistDir();
ZipUtils.unZip(file, file.getParentFile());
WebVersionUtils.setVersion(update.getvNumber());
FileUtils.deletes(oldDistDir.getParentFile());
WebVersionUtils.setNewVersion(update.getvNumber());
} catch (Exception e) {
e.printStackTrace();
}
......
......@@ -10,8 +10,19 @@ public class WebVersionUtils {
return SpUtils.getString(SpUtils.KEY_H5_VERSION, BuildConfig.H5_VERSION);
}
public static void setVersion(String name) {
SpUtils.putString(SpUtils.KEY_H5_VERSION, name);
public static void setNewVersion(String version) {
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() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!