1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-09-16 10:21:37 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee

Check bundlejs before switch

This commit is contained in:
sunnylqm
2020-01-09 17:45:44 +08:00
parent 5a5884c8fa
commit fa754ef8a2
2 changed files with 9 additions and 5 deletions

View File

@@ -106,8 +106,8 @@ public class UpdateContext {
private SharedPreferences sp;
public void switchVersion(String hashName) {
if (!new File(rootDir, hashName).exists()) {
throw new Error("Hash name not found, must download first.");
if (!new File(rootDir, hashName+"/index.bundlejs").exists()) {
throw new Error("Bundle version " + hashName + " not found.");
}
String lastVersion = getCurrentVersion();
SharedPreferences.Editor editor = sp.edit();

View File

@@ -123,8 +123,8 @@ public class UpdateModule extends ReactContextBaseJavaModule{
UiThreadUtil.runOnUiThread(new Runnable() {
@Override
public void run() {
updateContext.switchVersion(hash);
try {
updateContext.switchVersion(hash);
Activity activity = getCurrentActivity();
Application application = activity.getApplication();
ReactInstanceManager instanceManager = ((ReactApplication) application).getReactNativeHost().getReactInstanceManager();
@@ -147,7 +147,7 @@ public class UpdateModule extends ReactContextBaseJavaModule{
}
} catch (Throwable err) {
Log.e("pushy", "Failed to restart application", err);
Log.e("pushy", "switchVersion failed", err);
}
}
});
@@ -160,7 +160,11 @@ public class UpdateModule extends ReactContextBaseJavaModule{
UiThreadUtil.runOnUiThread(new Runnable() {
@Override
public void run() {
updateContext.switchVersion(hash);
try {
updateContext.switchVersion(hash);
} catch (Throwable err) {
Log.e("pushy", "switchVersionLater failed", err);
}
}
});
}