Exemple #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);
        }
        LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index)
        {
            if (index < 0)
            {
                return(null);
            }
            LoopListViewItem2 item = null;

            if (index == DataSourceMgr.Get.TotalItemCount)
            {
                item = listView.NewListViewItem("ItemPrefab0");
                UpdateLoadingTip(item);
                return(item);
            }
            ItemData itemData = DataSourceMgr.Get.GetItemDataByIndex(index);

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

            if (item.IsInitHandlerCalled == false)
            {
                item.IsInitHandlerCalled = true;
                itemScript.Init();
            }
            if (index == DataSourceMgr.Get.TotalItemCount - 1)
            {
                item.Padding = 0;
            }
            itemScript.SetItemData(itemData, index);
            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);
        }
Exemple #4
0
        LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index)
        {
            if (index < 0 || index >= DataSourceMgr.Get.TotalItemCount)
            {
                return(null);
            }

            ItemData itemData = DataSourceMgr.Get.GetItemDataByIndex(index);

            if (itemData == null)
            {
                return(null);
            }
            //get a new item. Every item can use a different prefab, the parameter of the NewListViewItem is the prefab’name.
            //And all the prefabs should be listed in ItemPrefabList in LoopListView2 Inspector Setting
            LoopListViewItem2 item       = listView.NewListViewItem("ItemPrefab1");
            ListItem5         itemScript = item.GetComponent <ListItem5>();

            if (item.IsInitHandlerCalled == false)
            {
                item.IsInitHandlerCalled = true;
                itemScript.Init();
            }
            itemScript.SetItemData(itemData, index);
            return(item);
        }
        private LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index)
        {
            if (index < 0 || index >= DataSourceMgr.Get.TotalItemCount)
            {
                return((LoopListViewItem2)null);
            }
            ItemData itemDataByIndex = DataSourceMgr.Get.GetItemDataByIndex(index);

            if (itemDataByIndex == null)
            {
                return((LoopListViewItem2)null);
            }
            LoopListViewItem2 loopListViewItem2 = listView.NewListViewItem("ItemPrefab1");
            ListItem5         component         = (ListItem5)((Component)loopListViewItem2).GetComponent <ListItem5>();

            if (!loopListViewItem2.IsInitHandlerCalled)
            {
                loopListViewItem2.IsInitHandlerCalled = true;
                component.Init();
            }
            component.SetItemData(itemDataByIndex, index);
            return(loopListViewItem2);
        }