示例#1
0
        public override void updateCellAtIndex(int page)
        {
            LGridPageViewPage pageCell = (LGridPageViewPage)dequeueCell();
            if (pageCell == null)
            {
                pageCell = new LGridPageViewPage();

                List<LGridPageViewCell> gridCells = pageCell.gridCells;
                int beginIdx = page * _cellsMaxCountInPage;
                int endIdx = beginIdx + _cellsMaxCountInPage;

                for (int idx = beginIdx, i = 0; idx < endIdx;++idx,++i )
                {
                    LGridPageViewCell cell = null;
                    if (idx < gridCellsCount)
                    {
                        cell = onGridDataSourceAdapterHandler.Invoke(null, idx);
                        RectTransform rtran = cell.node.GetComponent<RectTransform>();
                        rtran.pivot = Vector2.zero;
                        rtran.sizeDelta = gridCellsSize;
                        cell.idx = idx;
                        cell.node.transform.SetParent(pageCell.node.transform);
                        cell.node.transform.localPosition = _gridCellsPosition[i];
                        cell.node.transform.localScale = new Vector2(1, 1);
                        gridCells.Add(cell);
                    }
                    else
                    {
                        cell = onGridDataSourceAdapterHandler.Invoke(null, INVALID_INDEX);
                        RectTransform rtran = cell.node.GetComponent<RectTransform>();
                        rtran.pivot = Vector2.zero;
                        cell.idx = INVALID_INDEX;
                        cell.node.transform.SetParent(pageCell.node.transform);
                        cell.node.transform.localPosition = _gridCellsPosition[i];
                        cell.node.transform.localScale = new Vector2(1, 1);
                        gridCells.Add(cell);
                    }
                }
            }
            else
            {
                List<LGridPageViewCell> gridCells = pageCell.gridCells;
                int beginIdx = page * _cellsMaxCountInPage;
                int endIdx = beginIdx + _cellsMaxCountInPage;

                for (int idx = beginIdx, i = 0; idx < endIdx; ++idx, ++i)
                {
                    LGridPageViewCell cell = gridCells[i];
                    if (idx < gridCellsCount)
                    {
                        cell.idx = idx;
                        cell = onGridDataSourceAdapterHandler.Invoke(cell, idx);
                    }else
                    {
                        cell.idx = INVALID_INDEX;
                        cell.reset();
                        cell = onGridDataSourceAdapterHandler.Invoke(cell, INVALID_INDEX);
                    }
                }
            }

            pageCell.idx = page;
            RectTransform tran = pageCell.node.GetComponent<RectTransform>();
            switch(direction)
            {
                case ScrollDirection.HORIZONTAL:
                    tran.pivot = Vector2.zero;
                    break;
                default:
                    tran.pivot = new Vector2(0, 1);
                    break;
            }

            tran.sizeDelta = cellsSize;
            pageCell.node.transform.SetParent(container.transform);
            pageCell.node.transform.localScale = new Vector2(1, 1);
            pageCell.node.transform.localPosition = cellPositionFromIndex(page);
            insertSortableCell(pageCell, page);
            indices.Add(page, 1);
        }
示例#2
0
        public override void updateCellAtIndex(int page)
        {
            LGridPageViewPage pageCell = (LGridPageViewPage)dequeueCell();

            if (pageCell == null)
            {
                pageCell = new LGridPageViewPage();

                List <LGridPageViewCell> gridCells = pageCell.gridCells;
                int beginIdx = page * _cellsMaxCountInPage;
                int endIdx   = beginIdx + _cellsMaxCountInPage;

                for (int idx = beginIdx, i = 0; idx < endIdx; ++idx, ++i)
                {
                    LGridPageViewCell cell = null;
                    if (idx < gridCellsCount)
                    {
                        cell = _onGridDataSourceAdapterHandler(null, idx);
                        RectTransform rtran = cell.node.GetComponent <RectTransform>();
                        rtran.pivot     = Vector2.zero;
                        rtran.sizeDelta = gridCellsSize;
                        cell.idx        = idx;
                        cell.node.SetActive(true);
                        cell.node.transform.SetParent(pageCell.node.transform);
                        cell.node.transform.localPosition = _gridCellsPosition[i];
                        cell.node.transform.localScale    = new Vector2(1, 1);
                        gridCells.Add(cell);
                    }
                    else
                    {
                        cell = _onGridDataSourceAdapterHandler(null, INVALID_INDEX);
                        RectTransform rtran = cell.node.GetComponent <RectTransform>();
                        rtran.pivot = Vector2.zero;
                        cell.idx    = INVALID_INDEX;
                        cell.node.SetActive(false);
                        cell.node.transform.SetParent(pageCell.node.transform);
                        cell.node.transform.localPosition = _gridCellsPosition[i];
                        cell.node.transform.localScale    = new Vector2(1, 1);
                        gridCells.Add(cell);
                    }
                }
            }
            else
            {
                List <LGridPageViewCell> gridCells = pageCell.gridCells;
                int beginIdx = page * _cellsMaxCountInPage;
                int endIdx   = beginIdx + _cellsMaxCountInPage;

                for (int idx = beginIdx, i = 0; idx < endIdx; ++idx, ++i)
                {
                    LGridPageViewCell cell = gridCells[i];
                    if (idx < gridCellsCount)
                    {
                        cell.idx = idx;
                        cell     = _onGridDataSourceAdapterHandler(cell, idx);
                        cell.node.SetActive(true);
                    }
                    else
                    {
                        cell.idx = INVALID_INDEX;
                        cell.reset();
                        cell = _onGridDataSourceAdapterHandler(cell, INVALID_INDEX);
                        cell.node.SetActive(false);
                    }
                }
            }

            pageCell.idx = page;
            RectTransform tran = pageCell.node.GetComponent <RectTransform>();

            switch (direction)
            {
            case ScrollDirection.HORIZONTAL:
                tran.pivot = Vector2.zero;
                break;

            default:
                tran.pivot = new Vector2(0, 1);
                break;
            }

            tran.sizeDelta = cellsSize;
            pageCell.node.SetActive(true);
            pageCell.node.transform.SetParent(container.transform);
            pageCell.node.transform.localScale    = new Vector2(1, 1);
            pageCell.node.transform.localPosition = cellPositionFromIndex(page);
            insertSortableCell(pageCell, page);
            indices.Add(page, 1);
        }