LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index)
        {
            if (index < 0 || index >= ChatMsgDataSourceMgr.Get.TotalItemCount)
            {
                return(null);
            }

            ChatMsg itemData = ChatMsgDataSourceMgr.Get.GetChatMsgByIndex(index);

            if (itemData == null)
            {
                return(null);
            }
            LoopListViewItem2 item = null;

            if (itemData.mPersonId == 0)
            {
                item = listView.NewListViewItem("ItemPrefab1");
            }
            else
            {
                item = listView.NewListViewItem("ItemPrefab2");
            }
            ListItem4 itemScript = item.GetComponent <ListItem4>();

            if (item.IsInitHandlerCalled == false)
            {
                item.IsInitHandlerCalled = true;
                itemScript.Init();
            }
            itemScript.SetItemData(itemData, index);
            return(item);
        }
Ejemplo n.º 2
0
        private LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index)
        {
            if (index < 0 || index >= ChatMsgDataSourceMgr.Get.TotalItemCount)
            {
                return((LoopListViewItem2)null);
            }
            ChatMsg chatMsgByIndex = ChatMsgDataSourceMgr.Get.GetChatMsgByIndex(index);

            if (chatMsgByIndex == null)
            {
                return((LoopListViewItem2)null);
            }
            LoopListViewItem2 loopListViewItem2 = chatMsgByIndex.mPersonId != 0 ? listView.NewListViewItem("ItemPrefab2") : listView.NewListViewItem("ItemPrefab1");
            ListItem4         component         = (ListItem4)((Component)loopListViewItem2).GetComponent <ListItem4>();

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