Пример #1
0
        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");
            ListItem2 itemScript = item.GetComponent <ListItem2>();

            if (item.IsInitHandlerCalled == false)
            {
                item.IsInitHandlerCalled = true;
                itemScript.Init();
            }
            if (index == DataSourceMgr.Get.TotalItemCount - 1)
            {
                item.Padding = 0;
            }
            itemScript.SetItemData(itemData, index);
            return(item);
        }
Пример #2
0
        void UpdateLoadingTip(LoopListViewItem2 item)
        {
            if (item == null)
            {
                return;
            }
            ListItem0 itemScript0 = item.GetComponent <ListItem0>();

            if (itemScript0 == null)
            {
                return;
            }
            if (mLoadingTipStatus == LoadingTipStatus.None)
            {
                itemScript0.mRoot.SetActive(false);
                item.CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0);
            }
            else if (mLoadingTipStatus == LoadingTipStatus.WaitRelease)
            {
                itemScript0.mRoot.SetActive(true);
                itemScript0.mText.text = "Release to Load More";
                itemScript0.mArrow.SetActive(true);
                itemScript0.mWaitingIcon.SetActive(false);
                item.CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, mLoadingTipItemHeight);
            }
            else if (mLoadingTipStatus == LoadingTipStatus.WaitLoad)
            {
                itemScript0.mRoot.SetActive(true);
                itemScript0.mArrow.SetActive(false);
                itemScript0.mWaitingIcon.SetActive(true);
                itemScript0.mText.text = "Loading ...";
                item.CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, mLoadingTipItemHeight);
            }
        }
Пример #3
0
        void OnMonthSnapTargetFinished(LoopListView2 listView, LoopListViewItem2 item)
        {
            LoopListViewItem2 item0      = mLoopListViewDay.GetShownItemByIndex(0);
            ListItem7         itemScript = item0.GetComponent <ListItem7>();
            int index = itemScript.Value - 1;

            mLoopListViewDay.RefreshAllShownItemWithFirstIndex(index);
        }
Пример #4
0
 void OnListViewSnapTargetChanged(LoopListView2 listView, int targetIndex)
 {
     for (int i = 0; i < listView.ShownItemCount; ++i)
     {
         LoopListViewItem2 item2      = listView.GetShownItemByIndex(i);
         ListItem7         itemScript = item2.GetComponent <ListItem7>();
         itemScript.OnListViewSnapTargetChanged(i == targetIndex);
     }
 }
        LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index)
        {
            if (index < 0)
            {
                return(null);
            }

            TreeViewItemCountData countData = mTreeItemCountMgr.QueryTreeItemByTotalIndex(index);

            if (countData == null)
            {
                return(null);
            }
            int treeItemIndex = countData.mTreeItemIndex;
            TreeViewItemData treeViewItemData = TreeViewDataSourceMgr.Get.GetItemDataByIndex(treeItemIndex);

            if (index == countData.mBeginIndex)
            {
                LoopListViewItem2 item       = listView.NewListViewItem("ItemPrefab1");
                ListItem12        itemScript = item.GetComponent <ListItem12>();
                if (item.IsInitHandlerCalled == false)
                {
                    item.IsInitHandlerCalled = true;
                    itemScript.Init();
                    itemScript.SetClickCallBack(this.OnExpandClicked);
                }
                item.UserIntData1     = treeItemIndex;
                item.UserIntData2     = 0;
                itemScript.mText.text = treeViewItemData.mName;
                itemScript.SetItemData(treeItemIndex, countData.mIsExpand);
                return(item);
            }
            else
            {
                int      childIndex = index - countData.mBeginIndex - 1;
                ItemData itemData   = treeViewItemData.GetChild(childIndex);
                if (itemData == null)
                {
                    return(null);
                }
                LoopListViewItem2 item       = listView.NewListViewItem("ItemPrefab2");
                ListItem13        itemScript = item.GetComponent <ListItem13>();
                if (item.IsInitHandlerCalled == false)
                {
                    item.IsInitHandlerCalled = true;
                    itemScript.Init();
                }
                item.UserIntData1 = treeItemIndex;
                item.UserIntData2 = childIndex;
                itemScript.SetItemData(itemData, treeItemIndex, childIndex);
                return(item);
            }
        }
Пример #6
0
 void LateUpdate()
 {
     mLoopListViewHour.UpdateAllShownItemSnapData();
     for (int i = 0; i < mLoopListViewHour.ShownItemCount; ++i)
     {
         LoopListViewItem2 item       = mLoopListViewHour.GetShownItemByIndex(i);
         ListItem7         itemScript = item.GetComponent <ListItem7>();
         float             scale      = 1 - Mathf.Abs(item.DistanceWithViewPortSnapCenter) / 700f;
         scale = Mathf.Clamp(scale, 0.4f, 1);
         itemScript.SetScale(scale);
     }
 }
Пример #7
0
        void UpdateLoadingTip1(LoopListViewItem2 item)
        {
            if (item == null)
            {
                return;
            }
            item.CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, mLoopListView.ViewPortWidth);
            ListItem17 itemScript0 = item.GetComponent <ListItem17>();

            if (itemScript0 == null)
            {
                return;
            }
            if (mLoadingTipStatus1 == LoadingTipStatus.None)
            {
                itemScript0.mRoot1.SetActive(false);
                itemScript0.mRoot.SetActive(false);
                item.CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0);
            }
            else if (mLoadingTipStatus1 == LoadingTipStatus.WaitContinureDrag)
            {
                itemScript0.mRoot1.SetActive(true);
                itemScript0.mRoot.SetActive(false);
                item.CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0);
            }
            else if (mLoadingTipStatus1 == LoadingTipStatus.WaitRelease)
            {
                itemScript0.mRoot1.SetActive(false);
                itemScript0.mRoot.SetActive(true);
                itemScript0.mText.text = "Release to Refresh";
                itemScript0.mArrow.SetActive(true);
                itemScript0.mWaitingIcon.SetActive(false);
                item.CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, mLoadingTipItemHeight1);
            }
            else if (mLoadingTipStatus1 == LoadingTipStatus.WaitLoad)
            {
                itemScript0.mRoot1.SetActive(false);
                itemScript0.mRoot.SetActive(true);
                itemScript0.mArrow.SetActive(false);
                itemScript0.mWaitingIcon.SetActive(true);
                itemScript0.mText.text = "Loading ...";
                item.CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, mLoadingTipItemHeight1);
            }
            else if (mLoadingTipStatus1 == LoadingTipStatus.Loaded)
            {
                itemScript0.mRoot1.SetActive(false);
                itemScript0.mRoot.SetActive(true);
                itemScript0.mArrow.SetActive(false);
                itemScript0.mWaitingIcon.SetActive(false);
                itemScript0.mText.text = "Refreshed Success";
                item.CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, mLoadingTipItemHeight1);
            }
        }
Пример #8
0
        LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int row)
        {
            if (row < 0)
            {
                return(null);
            }

            LoopListViewItem2 item = null;

            if (row == 0)
            {
                item = listView.NewListViewItem("ItemPrefab0");
                UpdateLoadingTip1(item);
                return(item);
            }
            if (row == GetMaxRowCount() + 1)
            {
                item = listView.NewListViewItem("ItemPrefab1");
                UpdateLoadingTip2(item);
                return(item);
            }
            int itemRow = row - 1;

            item = listView.NewListViewItem("ItemPrefab2");
            ListItem6 itemScript = item.GetComponent <ListItem6>();

            if (item.IsInitHandlerCalled == false)
            {
                item.IsInitHandlerCalled = true;
                itemScript.Init();
            }
            for (int i = 0; i < mItemCountPerRow; ++i)
            {
                int itemIndex = itemRow * mItemCountPerRow + i;
                if (itemIndex >= DataSourceMgr.Get.TotalItemCount)
                {
                    itemScript.mItemList[i].gameObject.SetActive(false);
                    continue;
                }
                ItemData itemData = DataSourceMgr.Get.GetItemDataByIndex(itemIndex);
                if (itemData != null)
                {
                    itemScript.mItemList[i].gameObject.SetActive(true);
                    itemScript.mItemList[i].SetItemData(itemData, itemIndex);
                }
                else
                {
                    itemScript.mItemList[i].gameObject.SetActive(false);
                }
            }
            return(item);
        }
Пример #9
0
        void OnHourSnapTargetChanged(LoopListView2 listView, LoopListViewItem2 item)
        {
            int index = listView.GetIndexInShownItemList(item);

            if (index < 0)
            {
                return;
            }
            ListItem7 itemScript = item.GetComponent <ListItem7>();

            mCurSelectedHour = itemScript.Value;
            OnListViewSnapTargetChanged(listView, index);
        }
Пример #10
0
        LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index)
        {
            if (index < 0)
            {
                return(null);
            }
            LoopListViewItem2 item = null;

            if (index == DataSourceMgr.Get.TotalItemCount)
            {
                item = listView.NewListViewItem("ItemPrefab0");
                if (item.IsInitHandlerCalled == false)
                {
                    item.IsInitHandlerCalled = true;
                    ListItem11 itemScript0 = item.GetComponent <ListItem11>();
                    itemScript0.mRootButton.onClick.AddListener(OnLoadMoreBtnClicked);
                }
                UpdateLoadingTip(item);
                return(item);
            }
            ItemData itemData = DataSourceMgr.Get.GetItemDataByIndex(index);

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

            if (item.IsInitHandlerCalled == false)
            {
                item.IsInitHandlerCalled = true;
                itemScript.Init();
            }
            itemScript.SetItemData(itemData, index);
            return(item);
        }
Пример #11
0
        void LateUpdate()
        {
            mLoopListView.UpdateAllShownItemSnapData();
            int count = mLoopListView.ShownItemCount;

            for (int i = 0; i < count; ++i)
            {
                LoopListViewItem2 item       = mLoopListView.GetShownItemByIndex(i);
                ListItem2         itemScript = item.GetComponent <ListItem2>();
                float             scale      = 1 - Mathf.Abs(item.DistanceWithViewPortSnapCenter) / 700f;
                scale = Mathf.Clamp(scale, 0.4f, 1);
                itemScript.mContentRootObj.GetComponent <CanvasGroup>().alpha = scale;
                itemScript.mContentRootObj.transform.localScale = new Vector3(scale, scale, 1);
            }
        }
Пример #12
0
        void OnListViewSnapTargetChanged(LoopListView2 listView, int targetIndex)
        {
            int count = listView.ShownItemCount;

            for (int i = 0; i < count; ++i)
            {
                LoopListViewItem2 item2      = listView.GetShownItemByIndex(i);
                ListItem7         itemScript = item2.GetComponent <ListItem7>();
                if (i == targetIndex)
                {
                    itemScript.mText.color = Color.red;
                }
                else
                {
                    itemScript.mText.color = Color.black;
                }
            }
        }
Пример #13
0
        LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index)
        {
            Debug.Log(index);
            if (index < 0)
            {
                return(null);
            }
            LoopListViewItem2 item = null;

            if (index == 0)
            {
                item = listView.NewListViewItem("ItemPrefab___0");
                UpdateLoadingTip(item);
                return(item);
            }
            //index == DataSourceMgr.Get.TotalItemCount &&
            if (DataSourceMgr.Get.GetItemDataByIndex(index) == null)
            {
                Debug.Log("  total   " + index);
                item = listView.NewListViewItem("ItemPrefab___0");
                UpdateLoadingTip(item);
                return(item);
            }

            int      itemIndex = index - 1;
            ItemData itemData  = DataSourceMgr.Get.GetItemDataByIndex(itemIndex);

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

            if (item.IsInitHandlerCalled == false)
            {
                item.IsInitHandlerCalled = true;
                itemScript.Init();
            }
            itemScript.SetItemData(itemData, itemIndex);
            return(item);
        }
Пример #14
0
        LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int pageIndex)
        {
            if (pageIndex < 0 || pageIndex >= mPageCount)
            {
                return(null);
            }

            LoopListViewItem2 item       = listView.NewListViewItem("ItemPrefab1");
            ListItem14        itemScript = item.GetComponent <ListItem14>();

            if (item.IsInitHandlerCalled == false)
            {
                item.IsInitHandlerCalled = true;
                itemScript.Init();
            }
            List <ListItem14Elem> elemList = itemScript.mElemItemList;
            int count         = elemList.Count;
            int picBeginIndex = pageIndex * count;
            int i             = 0;

            for (; i < count; ++i)
            {
                ItemData itemData = DataSourceMgr.Get.GetItemDataByIndex(picBeginIndex + i);
                if (itemData == null)
                {
                    break;
                }
                ListItem14Elem elem = elemList[i];
                elem.mRootObj.SetActive(true);
                elem.mIcon.sprite = ResManager.Get.GetSpriteByName(itemData.mIcon);
                elem.mName.text   = itemData.mName;
            }
            if (i < count)
            {
                for (; i < count; ++i)
                {
                    elemList[i].mRootObj.SetActive(false);
                }
            }
            return(item);
        }
Пример #15
0
        //更新item数据
        LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index)
        {
            if (index < 0)
            {
                return(null);
            }
            LoopListViewItem2 item = null;

            //当index == 总的数据条数
            if (index == SuperDataSourceMgr.Get.TotalItemCount)
            {
                item = listView.NewListViewItem("ItemPrefab0");
                //更新加载栏状态
                UpdateLoadingTip(item);
                return(item);
            }
            LiveReviewItem itemData = SuperDataSourceMgr.Get.GetItemDataByIndex(index);

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

            //如果没有初始化,则进行初始化
            if (item.IsInitHandlerCalled == false)
            {
                item.IsInitHandlerCalled = true;
                itemScript.Init();
            }
            if (index == SuperDataSourceMgr.Get.TotalItemCount - 1)
            {
                item.Padding = 0;
            }
            //更新item数据和UI
            itemScript.SetItemData(itemData, index);
            return(item);
        }
Пример #16
0
        /*when a row is getting show in the scrollrect viewport,
         * this method will be called with the row’ index as a parameter,
         * to let you create the row  and update its content.
         *
         * SuperScrollView uses single items with subitems that make up the columns in the row.
         * so in fact, the GridView is ListView.
         * if one row is make up with 3 subitems, then the GridView looks like:
         *
         *  row0:  subitem0 subitem1 subitem2
         *  row1:  subitem3 subitem4 subitem5
         *  row2:  subitem6 subitem7 subitem8
         *  row3:  subitem9 subitem10 subitem11
         *  ...
         */
        LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index)
        {
            if (index < 0)
            {
                return(null);
            }
            //create one row
            LoopListViewItem2 item       = listView.NewListViewItem("ItemPrefab1");
            ListItem6         itemScript = item.GetComponent <ListItem6>();

            if (item.IsInitHandlerCalled == false)
            {
                item.IsInitHandlerCalled = true;
                itemScript.Init();
            }
            //update all items in the row
            for (int i = 0; i < mItemCountPerRow; ++i)
            {
                int itemIndex = index * mItemCountPerRow + i;
                if (itemIndex >= mListItemTotalCount)
                {
                    itemScript.mItemList[i].gameObject.SetActive(false);
                    continue;
                }
                ItemData itemData = DataSourceMgr.Get.GetItemDataByIndex(itemIndex);
                //update the subitem content.
                if (itemData != null)
                {
                    itemScript.mItemList[i].gameObject.SetActive(true);
                    itemScript.mItemList[i].SetItemData(itemData, itemIndex);
                }
                else
                {
                    itemScript.mItemList[i].gameObject.SetActive(false);
                }
            }
            return(item);
        }
Пример #17
0
        void UpdateLoadingTip(LoopListViewItem2 item)
        {
            if (item == null)
            {
                return;
            }
            ListItem11 itemScript0 = item.GetComponent <ListItem11>();

            if (itemScript0 == null)
            {
                return;
            }
            if (mLoadingTipStatus == LoadingTipStatus.None)
            {
                itemScript0.mText.text = "Click to Load More";
                itemScript0.mWaitingIcon.SetActive(false);
            }
            else if (mLoadingTipStatus == LoadingTipStatus.WaitLoad)
            {
                itemScript0.mWaitingIcon.SetActive(true);
                itemScript0.mText.text = "Loading ...";
            }
        }
Пример #18
0
        //when a TreeItem or TreeChildItem is getting in the scrollrect viewport,
        //this method will be called with the item’ index as a parameter,
        //to let you create the item and update its content.
        LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index)
        {
            if (index < 0)
            {
                return(null);
            }

            /*to check the index'th item is a TreeItem or a TreeChildItem.for example,
             *
             * 0  TreeItem0
             * 1      TreeChildItem0_0
             * 2      TreeChildItem0_1
             * 3      TreeChildItem0_2
             * 4      TreeChildItem0_3
             * 5  TreeItem1
             * 6      TreeChildItem1_0
             * 7      TreeChildItem1_1
             * 8      TreeChildItem1_2
             * 9  TreeItem2
             * 10     TreeChildItem2_0
             * 11     TreeChildItem2_1
             * 12     TreeChildItem2_2
             *
             * the first column value is the param 'index', for example, if index is 1,
             * then we should return TreeChildItem0_0 to SuperScrollView, and if index is 5,
             * then we should return TreeItem1 to SuperScrollView
             */

            TreeViewItemCountData countData = mTreeItemCountMgr.QueryTreeItemByTotalIndex(index);

            if (countData == null)
            {
                return(null);
            }
            int treeItemIndex = countData.mTreeItemIndex;
            TreeViewItemData treeViewItemData = TreeViewDataSourceMgr.Get.GetItemDataByIndex(treeItemIndex);

            if (countData.IsChild(index) == false)// if is a TreeItem
            {
                //get a new TreeItem
                LoopListViewItem2 item       = listView.NewListViewItem("ItemPrefab1");
                ListItem12        itemScript = item.GetComponent <ListItem12>();
                if (item.IsInitHandlerCalled == false)
                {
                    item.IsInitHandlerCalled = true;
                    itemScript.Init();
                    itemScript.SetClickCallBack(this.OnExpandClicked);
                }
                //update the TreeItem's content
                itemScript.mText.text = treeViewItemData.mName;
                itemScript.SetItemData(treeItemIndex, countData.mIsExpand);
                return(item);
            }
            else // if is a TreeChildItem
            {
                //childIndex is from 0 to ChildCount.
                //for example, TreeChildItem0_0 is the 0'th child of TreeItem0
                //and TreeChildItem1_2 is the 2'th child of TreeItem1
                int      childIndex = countData.GetChildIndex(index);
                ItemData itemData   = treeViewItemData.GetChild(childIndex);
                if (itemData == null)
                {
                    return(null);
                }
                //get a new TreeChildItem
                LoopListViewItem2 item       = listView.NewListViewItem("ItemPrefab2");
                ListItem13        itemScript = item.GetComponent <ListItem13>();
                if (item.IsInitHandlerCalled == false)
                {
                    item.IsInitHandlerCalled = true;
                    itemScript.Init();
                }
                //update the TreeChildItem's content
                itemScript.SetItemData(itemData, treeItemIndex, childIndex);
                return(item);
            }
        }