Example #1
0
    //ItemIsInvisible相同的函数,主要是协程调试不方便
    public void TestItemIsInvisible(int itemNumber)
    {
        if (isUpdatingList)
        {
            return;
        }
        isUpdatingList = true;
        if (m_nTotalDataCount > poolSize)// we need to do something "smart"...
        {
            Transform            item          = itemsPool[itemNumber];
            int                  itemDataIndex = item.GetComponent <InfiniteItemBehavior>().itemDataIndex;
            int                  indexToCheck  = 0;
            InfiniteItemBehavior infItem       = null;

            if (dataTracker.ContainsKey(itemDataIndex + 1))
            {
                infItem = itemsPool[(int)(dataTracker[itemDataIndex + 1])].GetComponent <InfiniteItemBehavior>();


                if ((infItem != null && infItem.verifyVisibility()))
                {
                    // dragging upwards (scrolling down)
                    indexToCheck = itemDataIndex - (extraBuffer / 2);
                    if (dataTracker.ContainsKey(indexToCheck))
                    {
                        //do we have an extra item(s) as well?
                        for (int i = indexToCheck; i >= 0; i--)
                        {
                            if (dataTracker.ContainsKey(i))
                            {
                                infItem = itemsPool[(int)(dataTracker[i])].GetComponent <InfiniteItemBehavior>();

                                if ((infItem != null && !infItem.verifyVisibility()))
                                {
                                    item = itemsPool[(int)(dataTracker[i])];
                                    if ((i) + poolSize < m_nTotalDataCount && i > -1)
                                    {
                                        PrepareListItemWithIndex(item, i + poolSize, i);
                                    }
                                }
                            }
                            else
                            {
                                scrollCursor = itemDataIndex - 1;
                                break;
                            }
                        }
                    }
                }
            }
            if (dataTracker.ContainsKey(itemDataIndex - 1))
            {
                infItem = itemsPool[(int)(dataTracker[itemDataIndex - 1])].GetComponent <InfiniteItemBehavior>();


                if ((infItem != null && infItem.verifyVisibility()))
                {
                    //dragging downwards check the item below
                    indexToCheck = itemDataIndex + (extraBuffer / 2);

                    if (dataTracker.ContainsKey(indexToCheck))
                    {
                        // if we have an extra item
                        for (int i = indexToCheck; i < m_nTotalDataCount; i++)
                        {
                            if (dataTracker.ContainsKey(i))
                            {
                                infItem = itemsPool[(int)(dataTracker[i])].GetComponent <InfiniteItemBehavior>();

                                if ((infItem != null && !infItem.verifyVisibility()))
                                {
                                    item = itemsPool[(int)(dataTracker[i])];
                                    if ((i) - poolSize > -1 && (i) < m_nTotalDataCount)
                                    {
                                        PrepareListItemWithIndex(item, i - poolSize, i);
                                    }
                                }
                            }
                            else
                            {
                                scrollCursor = itemDataIndex + 1;
                                break;
                            }
                        }
                    }
                }
            }
        }
        isUpdatingList = false;
    }
    public IEnumerator ItemIsInvisible(int itemNumber)
    {
        if (isUpdatingList)
        {
            yield return(null);
        }
        isUpdatingList = true;
        if (dataList.Count > poolSize)       // we need to do something "smart"...
        {
            Transform item          = itemsPool[itemNumber];
            int       itemDataIndex = 0;
            if (item.tag.Equals(listItemTag))
            {
                itemDataIndex = item.GetComponent <InfiniteItemBehavior>().itemDataIndex;
            }
            if (item.tag.Equals(listSectionTag))
            {
                itemDataIndex = item.GetComponent <InfiniteSectionBehavior>().itemDataIndex;
            }

            int indexToCheck = 0;
            InfiniteItemBehavior    infItem    = null;
            InfiniteSectionBehavior infSection = null;
            if (dataTracker.ContainsKey(itemDataIndex + 1))
            {
                infItem    = itemsPool[(int)(dataTracker[itemDataIndex + 1])].GetComponent <InfiniteItemBehavior>();
                infSection = itemsPool[(int)(dataTracker[itemDataIndex + 1])].GetComponent <InfiniteSectionBehavior>();

                if ((infItem != null && infItem.verifyVisibility()) || (infSection != null && infSection.verifyVisibility()))
                {
                    // dragging upwards (scrolling down)
                    indexToCheck = itemDataIndex - (extraBuffer / 2);
                    if (dataTracker.ContainsKey(indexToCheck))
                    {
                        //do we have an extra item(s) as well?
                        for (int i = indexToCheck; i >= 0; i--)
                        {
                            if (dataTracker.ContainsKey(i))
                            {
                                infItem    = itemsPool[(int)(dataTracker[i])].GetComponent <InfiniteItemBehavior>();
                                infSection = itemsPool[(int)(dataTracker[i])].GetComponent <InfiniteSectionBehavior>();
                                if ((infItem != null && !infItem.verifyVisibility()) || (infSection != null && !infSection.verifyVisibility()))
                                {
                                    item = itemsPool[(int)(dataTracker[i])];
                                    if ((i) + poolSize < dataList.Count && i > -1)
                                    {
                                        // is it a section index?
                                        if (sectionsIndices.Contains(i + poolSize))
                                        {
                                            // change item to section
                                            ChangeItemToSection(item, i + poolSize, i);
                                        }
                                        else if (item.tag.Equals(listSectionTag))
                                        {
                                            // change section to item
                                            ChangeSectionToItem(item, i + poolSize, i);
                                        }
                                        else
                                        {
                                            PrepareListItemWithIndex(item, i + poolSize, i);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                scrollCursor = itemDataIndex - 1;
                                break;
                            }
                        }
                    }
                }
            }
            if (dataTracker.ContainsKey(itemDataIndex - 1))
            {
                infItem    = itemsPool[(int)(dataTracker[itemDataIndex - 1])].GetComponent <InfiniteItemBehavior>();
                infSection = itemsPool[(int)(dataTracker[itemDataIndex - 1])].GetComponent <InfiniteSectionBehavior>();

                if ((infItem != null && infItem.verifyVisibility()) || (infSection != null && infSection.verifyVisibility()))
                {
                    //dragging downwards check the item below
                    indexToCheck = itemDataIndex + (extraBuffer / 2);

                    if (dataTracker.ContainsKey(indexToCheck))
                    {
                        // if we have an extra item
                        for (int i = indexToCheck; i < dataList.Count; i++)
                        {
                            if (dataTracker.ContainsKey(i))
                            {
                                infItem    = itemsPool[(int)(dataTracker[i])].GetComponent <InfiniteItemBehavior>();
                                infSection = itemsPool[(int)(dataTracker[i])].GetComponent <InfiniteSectionBehavior>();
                                if ((infItem != null && !infItem.verifyVisibility()) || (infSection != null && !infSection.verifyVisibility()))
                                {
                                    item = itemsPool[(int)(dataTracker[i])];
                                    if ((i) - poolSize > -1 && (i) < dataList.Count)
                                    {
                                        // is it a section index?
                                        if (sectionsIndices.Contains(i - poolSize))
                                        {
                                            // change item to section
                                            ChangeItemToSection(item, i - poolSize, i);
                                        }
                                        else if (item.tag.Equals(listSectionTag))
                                        {
                                            // change section to item
                                            ChangeSectionToItem(item, i - poolSize, i);
                                        }
                                        else
                                        {
                                            PrepareListItemWithIndex(item, i - poolSize, i);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                scrollCursor = itemDataIndex + 1;
                                break;
                            }
                        }
                    }
                }
            }
        }
        isUpdatingList = false;
    }
Example #3
0
    public IEnumerator ItemIsInvisible(int itemNumber)
    {
        if (isUpdatingList)
        {
            yield return(null);
        }
        isUpdatingList = true;
        if (m_nTotalDataCount > poolSize)// we need to do something "smart"...
        {
            Transform item = itemsPool[itemNumber];


            int itemDataIndex = item.GetComponent <InfiniteItemBehavior>().itemDataIndex;

            int indexToCheck             = 0;
            InfiniteItemBehavior infItem = null;

            if (dataTracker.ContainsKey(itemDataIndex + 1))
            {
                //Debug.LogError("1 itemNumber = " + itemNumber + " data idx " + itemDataIndex);
                infItem = itemsPool[(int)(dataTracker[itemDataIndex + 1])].GetComponent <InfiniteItemBehavior>();


                if ((infItem != null && infItem.verifyVisibility()))
                {
                    // dragging upwards (scrolling down)
                    indexToCheck = itemDataIndex - (extraBuffer / 2);
                    if (dataTracker.ContainsKey(indexToCheck))
                    {
                        //  Debug.LogError("indexToCheck1  = " + indexToCheck.ToString());
                        //do we have an extra item(s) as well?
                        for (int i = 0; i <= indexToCheck; i++)
                        {
                            if (dataTracker.ContainsKey(i))
                            {
                                infItem = itemsPool[(int)(dataTracker[i])].GetComponent <InfiniteItemBehavior>();

                                if ((infItem != null && !infItem.verifyVisibility()))
                                {
                                    item = itemsPool[(int)(dataTracker[i])];
                                    if ((i) + poolSize < m_nTotalDataCount && i > -1)
                                    {
                                        PrepareListItemWithIndex(item, i + poolSize, i);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (dataTracker.ContainsKey(itemDataIndex - 1))
            {
                //Debug.LogError("2 itemNumber = " + itemNumber + " data idx " + itemDataIndex);
                infItem = itemsPool[(int)(dataTracker[itemDataIndex - 1])].GetComponent <InfiniteItemBehavior>();


                if ((infItem != null && infItem.verifyVisibility()))
                {
                    //dragging downwards check the item below
                    indexToCheck = itemDataIndex + (extraBuffer / 2);

                    if (dataTracker.ContainsKey(indexToCheck))
                    {
                        //   Debug.LogError("indexToCheck2 " + indexToCheck.ToString());
                        // if we have an extra item
                        for (int i = m_nTotalDataCount - 1; i >= indexToCheck; i--)
                        {
                            if (dataTracker.ContainsKey(i))
                            {
                                infItem = itemsPool[(int)(dataTracker[i])].GetComponent <InfiniteItemBehavior>();

                                if ((infItem != null && !infItem.verifyVisibility()))
                                {
                                    item = itemsPool[(int)(dataTracker[i])];
                                    if ((i) - poolSize > -1 && (i) < m_nTotalDataCount)
                                    {
                                        PrepareListItemWithIndex(item, i - poolSize, i);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        isUpdatingList = false;
    }