mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-12 17:08:58 +08:00
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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user