Example #1
0
        private bool UpdateLayout()
        {
            HashSet <DataType> remain = new HashSet <DataType>();

            foreach (var p in ChildrenInUse)
            {
                remain.Add(p.Key);
            }
            bool answer = false;

            SVmain.BatchBegin();
            treap.Query(treap.Count, new Action <Treap <DataType> .TreapNode>((o) =>
            {
                MyAbsoluteLayout.SetLayoutBounds(LBend, BarsLayoutMethod(o.QueryYOffset()).Item1);
                ALmain.HeightRequest = o.QueryYOffset() + treap.itemHeight;
            }));
            if (treap.Count > 0)
            {
                double difference = 0;
                int    l = UponIndex(), r = DownIndex();
                for (int i = l; i <= r; i++)
                {
                    treap.Query(i, new Action <Treap <DataType> .TreapNode>((o) =>
                    {
                        var targetBound  = BarsLayoutMethod(o.QueryYOffset());
                        GenericView view = null;
                        if (ChildrenInUse.ContainsKey(o.data))
                        {
                            view = ChildrenInUse[o.data];
                            remain.Remove(o.data);
                            if (i == (l + r) / 2 && view.Bounds != null)
                            {
                                difference = targetBound.Item1.Y - view.Bounds.Y;
                            }
                        }
                        else if (!answer)
                        {
                            answer = true;
                            view   = GetGenericView();
                            view.Reset(o.data);
                            ChildrenInUse[o.data] = view;
                        }
                        if (view != null)
                        {
                            MyAbsoluteLayout.SetLayoutBounds(view, targetBound.Item1);
                        }
                    }));
                }
                if (difference != 0)
                {
                    SVmain.MyScrollY += difference;
                    //SVmain.ScrollToAsync(SVmain.ScrollX, SVmain.ScrollY + difference /** 1.05*/, false);
                }
            }
            foreach (var d in remain)
            {
                var v = ChildrenInUse[d];
                ChildrenInUse.Remove(d);
                v.Reset(null);
                v.IsVisible = false;
                AvaiableChildrenPool.Push(v);
            }
            SVmain.BatchCommit();
            return(answer);
        }