public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            ViewDidLoadCalled.Raise(this);

            var loadableViewModel = ViewModel as LoadableViewModel;

            if (loadableViewModel != null)
            {
                _refreshControl = new UIRefreshControl();
                RefreshControl  = _refreshControl;
                _refreshControl.ValueChanged += HandleRefreshRequested;
                loadableViewModel.Bind(x => x.IsLoading, x =>
                {
                    if (x)
                    {
                        MonoTouch.Utilities.PushNetworkActive();
                        _refreshControl.BeginRefreshing();

                        if (!_manualRefreshRequested)
                        {
                            UIView.Animate(0.25, 0f, UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.CurveEaseOut,
                                           () => TableView.ContentOffset = new CoreGraphics.CGPoint(0, -_refreshControl.Frame.Height), null);
                        }

                        if (ToolbarItems != null)
                        {
                            foreach (var t in ToolbarItems)
                            {
                                t.Enabled = false;
                            }
                        }
                    }
                    else
                    {
                        MonoTouch.Utilities.PopNetworkActive();

                        // Stupid bug...
                        BeginInvokeOnMainThread(() => {
                            UIView.Animate(0.25, 0.0, UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.CurveEaseOut,
                                           () => TableView.ContentOffset = new CoreGraphics.CGPoint(0, 0), null);
                            _refreshControl.EndRefreshing();
                        });

                        if (ToolbarItems != null)
                        {
                            foreach (var t in ToolbarItems)
                            {
                                t.Enabled = true;
                            }
                        }

                        _manualRefreshRequested = false;
                    }
                });
            }
        }
예제 #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            ViewDidLoadCalled.Raise(this);

            var loadableViewModel = ViewModel as LoadableViewModel;

            if (loadableViewModel != null)
            {
                RefreshControl = new UIRefreshControl();
                OnActivation(d =>
                {
                    d(loadableViewModel.Bind(x => x.IsLoading, true).Subscribe(x =>
                    {
                        if (x)
                        {
                            NetworkActivity.PushNetworkActive();
                            RefreshControl.BeginRefreshing();

                            if (!_manualRefreshRequested)
                            {
                                UIView.Animate(0.25, 0f, UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.CurveEaseOut,
                                               () => TableView.ContentOffset = new CoreGraphics.CGPoint(0, -RefreshControl.Frame.Height), null);
                            }

                            foreach (var t in (ToolbarItems ?? Enumerable.Empty <UIBarButtonItem>()))
                            {
                                t.Enabled = false;
                            }
                        }
                        else
                        {
                            NetworkActivity.PopNetworkActive();

                            if (RefreshControl.Refreshing)
                            {
                                // Stupid bug...
                                BeginInvokeOnMainThread(() =>
                                {
                                    UIView.Animate(0.25, 0.0, UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.CurveEaseOut,
                                                   () => TableView.ContentOffset = new CoreGraphics.CGPoint(0, 0), null);
                                    RefreshControl.EndRefreshing();
                                });
                            }

                            foreach (var t in (ToolbarItems ?? Enumerable.Empty <UIBarButtonItem>()))
                            {
                                t.Enabled = true;
                            }

                            _manualRefreshRequested = false;
                        }
                    }));
                });
            }
        }
 public override void ViewDidLoad()
 {
     base.ViewDidLoad();
     ViewDidLoadCalled.Raise(this);
 }
예제 #4
0
        //        public override void ViewWillDisappear(bool animated)
//		{
//            base.ViewWillDisappear(animated);
//            ViewWillDisappearCalled.Raise(this, animated);
//        }
//
//        public override void ViewDidAppear(bool animated)
//        {
//            base.ViewDidAppear(animated);
//            ViewDidDisappearCalled.Raise(this, animated);
//        }
//
//        public override void ViewWillAppear(bool animated)
//        {
//            base.ViewWillAppear(animated);
//            ViewWillAppearCalled.Raise(this, animated);
//        }
//
//        public override void ViewDidDisappear(bool animated)
//        {
//            base.ViewDidDisappear(animated);
//            ViewDidAppearCalled.Raise(this, animated);
//        }
//
        public virtual void ViewDidLoad()
        {
            ViewDidLoadCalled.Raise(this);
        }
 protected override void ViewDidLoad()
 {
     base.ViewDidLoad();
     ViewDidLoadCalled.Raise(this);
 }