Пример #1
0
        protected void innerClear(Stack <IListItemRender> willCleanChildren)
        {
            IListItemRender item;
            int             length = willCleanChildren.Count;

            while (willCleanChildren.Count > 0)
            {
                item = willCleanChildren.Pop();

                if (item is MonoBehaviour)
                {
                    SAListItemRender view = item as SAListItemRender;
                    view.SetActive(false);
                }
                else
                {
                    SASkinBase view = item as SASkinBase;
                    view.SetActive(false);
                }

                bindItemEvent(item, false);
                _caches.Push(item);
            }
        }
Пример #2
0
        protected virtual void renderList()
        {
            IntVector2 v     = getRenderListRange();
            int        start = v.x;
            int        end   = v.y;

            int oldChildLen = _childrenList.Count;

            if (oldChildLen > 0)
            {
                for (int j = oldChildLen - 1; j > -1; j--)
                {
                    _oldChildrenList.Push(_childrenList[j]);
                }
                _childrenList.Clear();
            }

            IListItemRender item;

            currentStartIndex = start;
            for (int i = start; i < end; i++)
            {
                if (oldChildLen > 0)
                {
                    oldChildLen--;
                    item = _oldChildrenList.Pop();
                }
                else if (_caches.Count > 0)
                {
                    item = _caches.Pop();
                    if (item is MonoBehaviour)
                    {
                        SAListItemRender view = item as SAListItemRender;
                        view.SetActive(true);
                    }
                    else
                    {
                        SASkinBase view = item as SASkinBase;
                        view.SetActive(true);
                    }
                }
                else
                {
                    item = (IListItemRender)_itemFacotry.newInstance();
                    addItemToContainer(item);
                }

                item.index = i;
                if (item is IPageListRef)
                {
                    ((IPageListRef)item).ownerPageList = this;
                }
                layout(item, i);
                bindItemEvent(item, true);
                bindItemData(item, getItemData(i));
                _childrenList.Add(item);
                Refresh();
            }

            if (oldChildLen > 0)
            {
                innerClear(_oldChildrenList);
            }
        }