private void MoveToBeforeResumeLifecycleState() { lock (_lifecycleStateLock) { if (_currentReactContext != null) { if (_lifecycleState == LifecycleState.BeforeCreate) { // Starting in suspended mode, do a resume/suspend pulse without exiting background _currentReactContext.OnResume(); _currentReactContext.OnSuspend(); } else if (_lifecycleState == LifecycleState.Foreground) { // Shouldn't really happen, but I've seen it once. _currentReactContext.OnEnteredBackground(); _currentReactContext.OnSuspend(); } else if (_lifecycleState == LifecycleState.Background) { _currentReactContext.OnSuspend(); } } _lifecycleState = LifecycleState.Suspended; } }
private void MoveReactContextToCurrentLifecycleState(ReactContext reactContext) { if (_lifecycleState == LifecycleState.Resumed) { reactContext.OnResume(); } }
public void SetContext(ReactContext _reactContext) { lock (_lifecycleStateLock) { if (_currentReactContext != _reactContext) { if (_currentReactContext != null) { // Suspend old context if needed. We don't touch the current lifecycle state. if (_lifecycleState == LifecycleState.Foreground || _lifecycleState == LifecycleState.Background) { if (_lifecycleState == LifecycleState.Foreground) { _currentReactContext.OnEnteredBackground(); } _currentReactContext.OnSuspend(); } } _currentReactContext = _reactContext; if (_currentReactContext != null) { // Bring new context in sync with current lifecycle state if (_lifecycleState == LifecycleState.Foreground || _lifecycleState == LifecycleState.Background) { _currentReactContext.OnResume(); if (_lifecycleState == LifecycleState.Foreground) { _currentReactContext.OnLeavingBackground(); } } } } } }