Пример #1
0
        void OnEndDrag()
        {
            float             vec = mLoopListView.ScrollRect.velocity.x;
            int               curNearestItemIndex = mLoopListView.CurSnapNearestItemIndex;
            LoopListViewItem2 item = mLoopListView.GetShownItemByItemIndex(curNearestItemIndex);

            if (item == null)
            {
                mLoopListView.ClearSnapData();
                return;
            }
            if (Mathf.Abs(vec) < 50f)
            {
                mLoopListView.SetSnapTargetItemIndex(curNearestItemIndex);
                return;
            }
            Vector3 pos = mLoopListView.GetItemCornerPosInViewPort(item, ItemCornerEnum.LeftTop);

            if (pos.x > 0)
            {
                if (vec > 0)
                {
                    mLoopListView.SetSnapTargetItemIndex(curNearestItemIndex - 1);
                }
                else
                {
                    mLoopListView.SetSnapTargetItemIndex(curNearestItemIndex);
                }
            }
            else if (pos.x < 0)
            {
                if (vec > 0)
                {
                    mLoopListView.SetSnapTargetItemIndex(curNearestItemIndex);
                }
                else
                {
                    mLoopListView.SetSnapTargetItemIndex(curNearestItemIndex + 1);
                }
            }
            else
            {
                if (vec > 0)
                {
                    mLoopListView.SetSnapTargetItemIndex(curNearestItemIndex - 1);
                }
                else
                {
                    mLoopListView.SetSnapTargetItemIndex(curNearestItemIndex + 1);
                }
            }
        }
Пример #2
0
        /// <summary>         下面的菊花        动作action  </summary>
        private void OnDownMoreDragAction()
        {
            mDragDir = 1;
            if (mLoopListView.ShownItemCount == 0)
            {
                return;
            }
            if (mLoadingTipStatus != LoadingTipStatus.None && mLoadingTipStatus != LoadingTipStatus.WaitRelease)
            {
                return;
            }
            LoopListViewItem2 item = mLoopListView.GetShownItemByItemIndex(DataSourceMgr.Get.TotalItemCount);

            if (item == null)
            {
                return;
            }
            LoopListViewItem2 item1 = mLoopListView.GetShownItemByItemIndex(DataSourceMgr.Get.TotalItemCount - 1);

            if (item1 == null)
            {
                return;
            }
            float y = mLoopListView.GetItemCornerPosInViewPort(item1, ItemCornerEnum.LeftBottom).y;

            if (y + mLoopListView.ViewPortSize >= mLoadingTipItemHeight)
            {
                if (mLoadingTipStatus != LoadingTipStatus.None)
                {
                    return;
                }
                mLoadingTipStatus = LoadingTipStatus.WaitRelease;
                UpdateLoadingTip(item);
            }
            else
            {
                if (mLoadingTipStatus != LoadingTipStatus.WaitRelease)
                {
                    return;
                }
                mLoadingTipStatus = LoadingTipStatus.None;
                UpdateLoadingTip(item);
            }
        }
        void OnDraging()
        {
            if (mLoopListView.ShownItemCount == 0)
            {
                return;
            }
            if (mLoadingTipStatus != LoadingTipStatus.None && mLoadingTipStatus != LoadingTipStatus.WaitRelease)
            {
                return;
            }
            LoopListViewItem2 item = mLoopListView.GetShownItemByItemIndex(DataSourceMgr.Get.TotalItemCount);

            if (item == null)
            {
                return;
            }
            LoopListViewItem2 item1 = mLoopListView.GetShownItemByItemIndex(DataSourceMgr.Get.TotalItemCount - 1);

            if (item1 == null)
            {
                return;
            }
            float x = mLoopListView.GetItemCornerPosInViewPort(item1, ItemCornerEnum.LeftBottom).x;

            if (x + mLoopListView.ViewPortSize >= mLoadingTipItemWidth)
            {
                if (mLoadingTipStatus != LoadingTipStatus.None)
                {
                    return;
                }
                mLoadingTipStatus = LoadingTipStatus.WaitRelease;
                UpdateLoadingTip(item);
            }
            else
            {
                if (mLoadingTipStatus != LoadingTipStatus.WaitRelease)
                {
                    return;
                }
                mLoadingTipStatus = LoadingTipStatus.None;
                UpdateLoadingTip(item);
            }
        }
Пример #4
0
        void OnDraging2()
        {
            if (mLoopListView.ShownItemCount == 0)
            {
                return;
            }
            if (mLoadingTipStatus2 != LoadingTipStatus.None && mLoadingTipStatus2 != LoadingTipStatus.WaitRelease)
            {
                return;
            }
            LoopListViewItem2 item = mLoopListView.GetShownItemByItemIndex(GetMaxRowCount() + 1);

            if (item == null)
            {
                return;
            }
            LoopListViewItem2 item1 = mLoopListView.GetShownItemByItemIndex(GetMaxRowCount());

            if (item1 == null)
            {
                return;
            }
            float y = mLoopListView.GetItemCornerPosInViewPort(item1, ItemCornerEnum.LeftBottom).y;

            if (y + mLoopListView.ViewPortSize >= mLoadingTipItemHeight2)
            {
                if (mLoadingTipStatus2 != LoadingTipStatus.None)
                {
                    return;
                }
                mLoadingTipStatus2 = LoadingTipStatus.WaitRelease;
                UpdateLoadingTip2(item);
            }
            else
            {
                if (mLoadingTipStatus2 != LoadingTipStatus.WaitRelease)
                {
                    return;
                }
                mLoadingTipStatus2 = LoadingTipStatus.None;
                UpdateLoadingTip2(item);
            }
        }
Пример #5
0
        void UpdateStickeyHeadPos()
        {
            bool isHeadItemVisible = mStickeyHeadItem.gameObject.activeSelf;
            int  count             = mLoopListView.ShownItemCount;

            if (count == 0)
            {
                if (isHeadItemVisible)
                {
                    mStickeyHeadItem.gameObject.SetActive(false);
                }
                return;
            }
            LoopListViewItem2 item0   = mLoopListView.GetShownItemByIndex(0);
            Vector3           topPos0 = mLoopListView.GetItemCornerPosInViewPort(item0, ItemCornerEnum.LeftTop);

            LoopListViewItem2 targetItem = null;
            float             start      = topPos0.y;
            float             end        = start - item0.ItemSizeWithPadding;
            int targetItemShownIndex     = -1;

            if (start <= 0)
            {
                if (isHeadItemVisible)
                {
                    mStickeyHeadItem.gameObject.SetActive(false);
                }
                return;
            }
            if (end < 0)
            {
                targetItem           = item0;
                targetItemShownIndex = 0;
            }
            else
            {
                for (int i = 1; i < count; ++i)
                {
                    LoopListViewItem2 item = mLoopListView.GetShownItemByIndexWithoutCheck(i);
                    start = end;
                    end   = start - item.ItemSizeWithPadding;
                    if (start >= 0 && end <= 0)
                    {
                        targetItem           = item;
                        targetItemShownIndex = i;
                        break;
                    }
                }
            }
            if (targetItem == null)
            {
                if (isHeadItemVisible)
                {
                    mStickeyHeadItem.gameObject.SetActive(false);
                }
                return;
            }
            int itemIndex  = targetItem.UserIntData1;
            int childIndex = targetItem.UserIntData2;
            TreeViewItemCountData countData = mTreeItemCountMgr.GetTreeItem(itemIndex);

            if (countData == null)
            {
                if (isHeadItemVisible)
                {
                    mStickeyHeadItem.gameObject.SetActive(false);
                }
                return;
            }
            if (countData.mIsExpand == false || countData.mChildCount == 0)
            {
                if (isHeadItemVisible)
                {
                    mStickeyHeadItem.gameObject.SetActive(false);
                }
                return;
            }
            if (isHeadItemVisible == false)
            {
                mStickeyHeadItem.gameObject.SetActive(true);
            }
            if (mStickeyHeadItem.TreeItemIndex != itemIndex)
            {
                TreeViewItemData treeViewItemData = TreeViewDataSourceMgr.Get.GetItemDataByIndex(itemIndex);
                mStickeyHeadItem.mText.text = treeViewItemData.mName;
                mStickeyHeadItem.SetItemData(itemIndex, countData.mIsExpand);
            }
            mStickeyHeadItem.gameObject.transform.localPosition = Vector3.zero;
            float lastChildPosAbs = -end;
            float lastPadding     = targetItem.Padding;

            if (lastChildPosAbs - lastPadding >= mStickeyHeadItemHeight)
            {
                return;
            }
            for (int i = targetItemShownIndex + 1; i < count; ++i)
            {
                LoopListViewItem2 item = mLoopListView.GetShownItemByIndexWithoutCheck(i);
                if (item.UserIntData1 != itemIndex)
                {
                    break;
                }
                lastChildPosAbs += item.ItemSizeWithPadding;
                lastPadding      = item.Padding;
                if (lastChildPosAbs - lastPadding >= mStickeyHeadItemHeight)
                {
                    return;
                }
            }
            float y = mStickeyHeadItemHeight - (lastChildPosAbs - lastPadding);

            mStickeyHeadItemRf.anchoredPosition3D = new Vector3(0, y, 0);
        }
        void OnDraging()
        {
            if (mLoopListView.ShownItemCount == 0)
            {
                return;
            }
            if (mLoadingTipStatus != LoadingTipStatus.None &&
                mLoadingTipStatus != LoadingTipStatus.WaitReleasePush &&
                mLoadingTipStatus != LoadingTipStatus.WaitReleasePull)
            {
                return;
            }

            ScrollRect sr  = mLoopListView.ScrollRect;
            Vector3    pos = sr.content.localPosition;

            if (pos.y > 0)
            {
                // 加载更多
                LoopListViewItem2 item = mLoopListView.GetShownItemByItemIndex(DataSourceMgr.Get.TotalItemCount); //最后一个prefab是否已经显示,可以开始加载更多
                //Debug.Log(DataSourceMgr.Get.TotalItemCount + " -->> " + (mLoopListView.GetShownItemByItemIndex(DataSourceMgr.Get.TotalItemCount) != null));
                if (item != null)
                {
                    LoopListViewItem2 item1 = mLoopListView.GetShownItemByItemIndex(DataSourceMgr.Get.TotalItemCount - 1);
                    if (item1 == null)
                    {
                        //Debug.Log("item1 == null");
                        return;
                    }

                    float y = mLoopListView.GetItemCornerPosInViewPort(item1, ItemCornerEnum.LeftBottom).y;
                    if (y + mLoopListView.ViewPortSize >= mLoadingTipItemHeight)
                    {
                        if (mLoadingTipStatus != LoadingTipStatus.None)
                        {
                            return;
                        }
                        mLoadingTipStatus = LoadingTipStatus.WaitReleasePush;
                        UpdateLoadingTip(item);
                    }
                    else
                    {
                        if (mLoadingTipStatus != LoadingTipStatus.WaitReleasePush)
                        {
                            //Debug.Log("Draging ==>> RETURN");
                            //return;
                        }
                        else
                        {
                            mLoadingTipStatus = LoadingTipStatus.None;
                            UpdateLoadingTip(item);
                        }
                    }
                }
                else
                {
                    Debug.Log(DataSourceMgr.Get.TotalItemCount + " ==>> " + (mLoopListView.GetShownItemByItemIndex(DataSourceMgr.Get.TotalItemCount) != null));
                }
            }
            else
            {
                //下拉刷新
                LoopListViewItem2 _item = mLoopListView.GetShownItemByItemIndex(0);
                if (_item != null)
                {
                    //ScrollRect sr = mLoopListView.ScrollRect;
                    //Vector3 pos = sr.content.localPosition;
                    if (pos.y < -mLoadingTipItemHeight)
                    {
                        if (mLoadingTipStatus != LoadingTipStatus.None)
                        {
                            return;
                        }
                        //Debug.Log("<<<<"); //刷新
                        mLoadingTipStatus = LoadingTipStatus.WaitReleasePull;
                        UpdateLoadingTip(_item);
                        _item.CachedRectTransform.localPosition = new Vector3(0, mLoadingTipItemHeight, 0);
                    }
                    else
                    {
                        if (mLoadingTipStatus != LoadingTipStatus.WaitReleasePull)
                        {
                            return;
                        }
                        //Debug.Log(">>>>"); //放弃
                        mLoadingTipStatus = LoadingTipStatus.None;
                        UpdateLoadingTip(_item);
                        _item.CachedRectTransform.localPosition = new Vector3(0, 0, 0);
                    }
                }
            }
        }