Support React Native 0.36.0 and 0.37.0 (#602)

* Upgrade example app to react-native@0.37.0
* Fix crash on restart caused by loadBundle() being called twice
This commit is contained in:
Richard Hua
2016-11-14 22:40:36 -08:00
committed by GitHub
parent 3ccfa67528
commit d9a85c87f3
5 changed files with 14 additions and 18 deletions

View File

@@ -451,17 +451,13 @@ public class CodePushNativeModule extends ReactContextBaseJavaModule {
@Override
public void onHostResume() {
if (installMode == CodePushInstallMode.IMMEDIATE.getValue()) {
loadBundle();
} else {
// Determine how long the app was in the background and ensure
// that it meets the minimum duration amount of time.
long durationInBackground = 0;
if (lastPausedDate != null) {
durationInBackground = (new Date().getTime() - lastPausedDate.getTime()) / 1000;
}
if (durationInBackground >= CodePushNativeModule.this.mMinimumBackgroundDuration) {
// As of RN 36, the resume handler fires immediately if the app is in
// the foreground, so explicitly wait for it to be backgrounded first
if (lastPausedDate != null) {
long durationInBackground = (new Date().getTime() - lastPausedDate.getTime()) / 1000;
if (installMode == CodePushInstallMode.IMMEDIATE.getValue()
|| durationInBackground >= CodePushNativeModule.this.mMinimumBackgroundDuration) {
CodePushUtils.log("Loading bundle on resume");
loadBundle();
}
}