Commit d642e23c by amateur

1

1 parent b64defb3
...@@ -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]);
} }
......
...@@ -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) {
......
...@@ -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();
} }
......
...@@ -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() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!