public override void ViewDidLoad()
        {
            this.View.BackgroundColor = UIColor.White;

            CGRect tmp = this.View.Bounds;

            tmp.Y      = 20;
            tmp.Height = tmp.Height - 20;

            //Origin data in tableview
            dataList = new List <string> ()
            {
                "January", "February", "March", "April"
            };

            //datalist : tableview's datalist
            //Refresh : It's an action which will fire when drag down tableview event actived
            //Refresh : It's an action which will fire when pull up tableview event actived
            DragRefreshTableSource source = new DragRefreshTableSource(dataList, Refresh, MoreData);

            source.ActiveDistance = 60;            //Set an active distance

            ALDragRefreshTableView tableView = new ALDragRefreshTableView(source);

            tableView.Frame     = tmp;
            tableView.RowHeight = 50;
            this.Add(tableView);
        }
Example #2
0
        private void SetSource(DragRefreshTableSource theSource)
        {
            theSource.ThisTableView = this;
            this.Source             = theSource;

            theSource.Scrolling += (locationY) => {
                //Console.WriteLine ("locationY=" + locationY);
                nfloat footerViewActionDis = this.Frame.Height >= this.ContentSize.Height ? locationY : locationY - (this.ContentSize.Height - this.Frame.Height);
                if (footerViewActionDis > 0)
                {
                    if (footerViewActionDis > theSource.ActiveDistance)
                    {
                        if (footerView.Status == HeaderAndFooterStatus.Display && theSource.IsDragging)
                        {
                            footerView.Status = HeaderAndFooterStatus.Actived;
                        }
                    }
                    else
                    {
                        if (footerView.Status == HeaderAndFooterStatus.Actived)
                        {
                            footerView.Status = HeaderAndFooterStatus.Display;
                        }
                    }
                }
                if (locationY < 0)
                {
                    if (locationY < -theSource.ActiveDistance)
                    {
                        if (headerView.Status == HeaderAndFooterStatus.Display && theSource.IsDragging)
                        {
                            headerView.Status = HeaderAndFooterStatus.Actived;
                        }
                    }
                    else
                    {
                        if (headerView.Status == HeaderAndFooterStatus.Actived)
                        {
                            headerView.Status = HeaderAndFooterStatus.Display;
                        }
                    }
                }
            };

            theSource.Loading += (isloading, isHeaderLoding) => {
                if (isloading)
                {
                    this.UserInteractionEnabled = false;
                    if (isHeaderLoding)
                    {
                        headerView.Status = HeaderAndFooterStatus.Loading;
                    }
                    else
                    {
                        footerView.Status = HeaderAndFooterStatus.Loading;
                    }
                }
                else
                {
                    this.UserInteractionEnabled = true;
                    if (isHeaderLoding)
                    {
                        headerView.DefaultText = "last refresh " + DateTime.Now.ToString();
                        headerView.Status      = HeaderAndFooterStatus.Display;
                    }
                    else
                    {
                        footerView.Status = HeaderAndFooterStatus.Display;
                    }
                }
            };
        }
Example #3
0
 public ALDragRefreshTableView(DragRefreshTableSource theSource)
 {
     this.BackgroundColor = UIColor.Clear;
     SetSource(theSource);
 }