public override void OnHiddenChanged(bool hidden)
 {
     base.OnHiddenChanged(hidden);
     if (hidden)
     {
         LifecycleManager.OnPause();
     }
     else
     {
         LifecycleManager.OnResume();
     }
 }
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            LifecycleManager.OnResume();

            _isCurrentlyVisible = true;

            if (_foregroundNotificationObserver == null)
            {
                _foregroundNotificationObserver = NSNotificationCenter.DefaultCenter.AddObserver(
                    UIApplication.WillEnterForegroundNotification, (obj) => AppWillEnterForeground());
            }

            if (_backgroundNotificationObserver == null)
            {
                _backgroundNotificationObserver = NSNotificationCenter.DefaultCenter.AddObserver(
                    UIApplication.DidEnterBackgroundNotification, (obj) => AppDidEnterBackground());
            }
        }
Ejemplo n.º 3
0
        public void LifecycleTest()
        {
            _lifecycleManager.Register(_liveDataMock.Object, OnNextMock, OnErrorMock);

            _liveDataMock.Verify(liveData => liveData.Subscribe(
                                     OnNextMock, OnErrorMock, It.IsAny <Action>()), Times.Never);

            _lifecycleManager.OnResume();

            _liveDataMock.Verify(liveData => liveData.Subscribe(
                                     OnNextMock, OnErrorMock, It.IsAny <Action>()), Times.Once);

            _lifecycleManager.OnPause();

            _liveDataMock.Verify(liveData => liveData.Subscribe(
                                     OnNextMock, OnErrorMock, It.IsAny <Action>()), Times.Once);

            _lifecycleManager.OnResume();

            _liveDataMock.Verify(liveData => liveData.Subscribe(
                                     OnNextMock, OnErrorMock, It.IsAny <Action>()), Times.Exactly(2));

            _lifecycleManager.OnPause();

            _liveDataMock.Verify(liveData => liveData.Subscribe(
                                     OnNextMock, OnErrorMock, It.IsAny <Action>()), Times.Exactly(2));

            _lifecycleManager.OnDestroyView();

            _liveDataMock.Verify(liveData => liveData.Subscribe(
                                     OnNextMock, OnErrorMock, It.IsAny <Action>()), Times.Exactly(2));

            _lifecycleManager.OnResume();

            _liveDataMock.Verify(liveData => liveData.Subscribe(
                                     OnNextMock, OnErrorMock, It.IsAny <Action>()), Times.Exactly(2));

            _lifecycleManager.Register(_liveDataMock.Object, OnNextMock, OnErrorMock);

            _liveDataMock.Verify(liveData => liveData.Subscribe(
                                     OnNextMock, OnErrorMock, It.IsAny <Action>()), Times.Exactly(2));

            _lifecycleManager.OnPause();

            _liveDataMock.Verify(liveData => liveData.Subscribe(
                                     OnNextMock, OnErrorMock, It.IsAny <Action>()), Times.Exactly(2));

            _lifecycleManager.OnResume();

            _liveDataMock.Verify(liveData => liveData.Subscribe(
                                     OnNextMock, OnErrorMock, It.IsAny <Action>()), Times.Exactly(3));

            _lifecycleManager.Dispose();

            _liveDataMock.Verify(liveData => liveData.Subscribe(
                                     OnNextMock, OnErrorMock, It.IsAny <Action>()), Times.Exactly(3));

            _liveDataMock.Verify(liveData => liveData.PostValue(It.IsAny <string>()), Times.Never);
        }
 protected override void OnResume()
 {
     base.OnResume();
     LifecycleManager.OnResume();
 }
Ejemplo n.º 5
0
 public override void Show()
 {
     base.Show();
     LifecycleManager.OnResume();
 }