예제 #1
0
        LoopStaggeredGridViewItem OnGetItemByIndex(LoopStaggeredGridView listView, int index)
        {
            if (index < 0)
            {
                return(null);
            }
            ItemData itemData = DataSourceMgr.Get.GetItemDataByIndex(index);

            if (itemData == null)
            {
                return(null);
            }
            LoopStaggeredGridViewItem item = listView.NewListViewItem("ItemPrefab1");
            ListItem5 itemScript           = item.GetComponent <ListItem5>();

            if (item.IsInitHandlerCalled == false)
            {
                item.IsInitHandlerCalled = true;
                itemScript.Init();
            }

            itemScript.SetItemData(itemData, index);

            float itemWidth = 390 + mItemWidthArrayForDemo[index % mItemWidthArrayForDemo.Length] * 10f;

            item.CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, itemWidth);

            return(item);
        }
        private LoopStaggeredGridViewItem OnGetItemByIndex(
            LoopStaggeredGridView listView,
            int index)
        {
            if (index < 0)
            {
                return((LoopStaggeredGridViewItem)null);
            }
            ItemData itemDataByIndex = DataSourceMgr.Get.GetItemDataByIndex(index);

            if (itemDataByIndex == null)
            {
                return((LoopStaggeredGridViewItem)null);
            }
            LoopStaggeredGridViewItem staggeredGridViewItem = listView.NewListViewItem("ItemPrefab0");
            ListItem5 component = (ListItem5)((Component)staggeredGridViewItem).GetComponent <ListItem5>();

            if (!staggeredGridViewItem.IsInitHandlerCalled)
            {
                staggeredGridViewItem.IsInitHandlerCalled = true;
                component.Init();
            }
            component.SetItemData(itemDataByIndex, index);
            float num = (float)(300.0 + (double)this.mItemHeightArrayForDemo[index % this.mItemHeightArrayForDemo.Length] * 10.0);

            staggeredGridViewItem.CachedRectTransform.SetSizeWithCurrentAnchors((RectTransform.Axis) 1, num);
            return(staggeredGridViewItem);
        }