Пример #1
0
 private void shiftUp(float d)
 {
     for (int i = firstPos; i <= lastPos; i++)
     {
         ItemBundle beforeB = getByPosition(i - 1);
         ItemBundle ib      = getByPosition(i);
         if (beforeB == null)
         {
             Vector2 v = ib.trans.anchoredPosition + new Vector2(0, d);
             if ((lastPos + 1) < adapter.getCount() && v.y > getTopLimtY())
             {
                 firstPos++;
                 ib.position = ++lastPos;
             }
             else
             {
                 ib.trans.anchoredPosition += new Vector2(0, d);
             }
         }
         else
         {
             ib.trans.anchoredPosition = beforeB.getBottomCenter();
         }
     }
 }
Пример #2
0
        public bool isEnded()
        {
            ItemBundle ib = getByPosition(adapter.getCount() - 1);

            if (ib == null)
            {
                return(false);
            }
            return(ib.getBottomCenter().y > getBottomLimtY());
        }
Пример #3
0
        private bool lockMoveToBottom(float d)
        {
            ItemBundle firstB = getByPosition(firstPos);

            if (firstB == null)
            {
                return(false);
            }
            float topY = firstB.trans.anchoredPosition.y;

            return(d < 0 && firstPos <= 0 && topY <= 0);
        }
Пример #4
0
        internal void changeData()
        {
            ItemBundle ib = null;

            while ((ib = getCurrentFeedItem()) != null)
            {
                ib.trans.anchoredPosition = new Vector3(ib.trans.anchoredPosition.x, -getContentHeight(), 0);
                items.Add(ib);
                eventController.injectItemEvent(ib.trans.gameObject);
            }
            reflesh();
            fixedTop();
            onDataChanged();
        }
Пример #5
0
        private bool lockMoveToTop(float d)
        {
            ItemBundle lastB = getByPosition(lastPos);

            if (lastB == null)
            {
                return(false);
            }
            float y       = lastB.getBottomCenter().y;
            bool  db      = d > 0;
            bool  indexB  = lastPos >= adapter.getCount();
            bool  heightB = y > -getContainerHeight();

            return(d > 0 && (lastPos + 1) >= adapter.getCount() && y > -getContainerHeight());
        }
Пример #6
0
 private void fixedTop()
 {
     if (isEnded())
     {
         ItemBundle ib = getByPosition(0);
         if (ib == null)
         {
             return;
         }
         float y = ib.trans.anchoredPosition.y;
         if (y != 0)
         {
             plusY(-y);
         }
     }
 }
Пример #7
0
        private void checkRecycle(ItemBundle ib)
        {
            ItemBundle targetIb;

            if (ib.trans.anchoredPosition.y > getTopLimtY() && (lastPos + 1) < adapter.getCount() && (targetIb = getByPosition(lastPos)) != null)
            {
                ib.trans.anchoredPosition = targetIb.getBottomCenter();
                ib.position = ++lastPos;
                firstPos++;
            }
            else if (ib.trans.anchoredPosition.y < getBottomLimtY() && firstPos > 0 && (targetIb = getByPosition(firstPos)) != null)
            {
                Vector2 v = targetIb.trans.anchoredPosition + new Vector2(0, ib.trans.rect.height);
                ib.trans.anchoredPosition = v;
                ib.position = --firstPos;
                lastPos--;
            }
        }
Пример #8
0
 private void refleshFastOne(ItemBundle ib)
 {
     if (ib.position < adapter.getCount())
     {
         if (!ib.trans.gameObject.activeSelf)
         {
             ib.trans.gameObject.SetActive(true);
         }
         RectTransform rtf = adapter.getView(ib.trans, ib.position);
         ib.trans = rtf;
     }
     else
     {
         if (ib.trans.gameObject.activeSelf)
         {
             ib.trans.gameObject.SetActive(false);
         }
     }
 }
Пример #9
0
        private ItemBundle getCurrentFeedItem()
        {
            int  i       = items.Count;
            bool heightB = (getContainerHeight() * ITEM_BUFFER_HEIGHT_SCALE) > getContentHeight();
            bool countB  = i < adapter.getCount();

            if (heightB && countB)
            {
                ItemBundle ans = new ItemBundle();
                ans.trans = adapter.getView(null, i);
                initItemTrans(ans.trans);
                ans.position = i;
                lastPos      = i;
                return(ans);
            }
            else
            {
                return(null);
            }
        }
Пример #10
0
 private void shiftDown(float d)
 {
     for (int i = lastPos; i >= firstPos; i--)
     {
         ItemBundle nextB = getByPosition(i + 1);
         ItemBundle ib    = getByPosition(i);
         if (nextB == null)
         {
             if ((firstPos) > 0 && ib.getBottomCenter().y < getBottomLimtY())
             {
                 lastPos--;
                 ib.position = --firstPos;
             }
             else
             {
                 ib.trans.anchoredPosition += new Vector2(0, d);
             }
         }
         else
         {
             ib.trans.anchoredPosition = nextB.trans.anchoredPosition + new Vector2(0, ib.trans.rect.height);
         }
     }
 }
Пример #11
0
 private void refleshFastOne(ItemBundle ib)
 {
     if (ib.position < adapter.getCount()) {
         if (!ib.trans.gameObject.activeSelf) {
             ib.trans.gameObject.SetActive(true);
         }
         RectTransform rtf = adapter.getView(ib.trans, ib.position);
         ib.trans = rtf;
     } else {
         if (ib.trans.gameObject.activeSelf) {
             ib.trans.gameObject.SetActive(false);
         }
     }
 }
Пример #12
0
 private ItemBundle getCurrentFeedItem()
 {
     int i = items.Count;
     bool heightB = (getContainerHeight() * ITEM_BUFFER_HEIGHT_SCALE) > getContentHeight();
     bool countB = i < adapter.getCount();
     if (heightB && countB) {
         ItemBundle ans = new ItemBundle();
         ans.trans = adapter.getView(null, i);
         initItemTrans(ans.trans);
         ans.position = i;
         lastPos = i;
         return ans;
     } else {
         return null;
     }
 }
Пример #13
0
 private void checkRecycle(ItemBundle ib)
 {
     ItemBundle targetIb;
     if (ib.trans.anchoredPosition.y > getTopLimtY() && (lastPos + 1) < adapter.getCount() && (targetIb = getByPosition(lastPos)) != null) {
         ib.trans.anchoredPosition = targetIb.getBottomCenter();
         ib.position = ++lastPos;
         firstPos++;
     } else if (ib.trans.anchoredPosition.y < getBottomLimtY() && firstPos > 0 && (targetIb = getByPosition(firstPos)) != null) {
         Vector2 v = targetIb.trans.anchoredPosition + new Vector2(0, ib.trans.rect.height);
         ib.trans.anchoredPosition = v;
         ib.position = --firstPos;
         lastPos--;
     }
 }