Beispiel #1
0
    /// <summary>
    /// 根据时间排序
    /// </summary>
    /// <param name = "x" ></ param >
    /// < param name="y"></param>
    /// <returns></returns>
    private int OnCompareTime(ChatItemBase x, ChatItemBase y)
    {
        if (x == null || y == null || x.Data == null || y.Data == null)
        {
            return(0);
        }

        ChatInfo dataX = x.Data as ChatInfo;
        ChatInfo dataY = y.Data as ChatInfo;

        if (dataX != null && dataY != null)
        {
            if (dataX.sendTime > dataY.sendTime)
            {
                return(-1);
            }
            else
            {
                return(1);
            }
        }
        return(0);
    }
Beispiel #2
0
    public void Reposition()
    {
        if (Application.isPlaying && !mStarted)
        {
            mReposition = true;
            return;
        }

        if (!mInitDone)
        {
            Init();
        }

        mReposition = false;
        Transform myTrans = transform;

        int x      = 0;
        int y      = 0;
        int height = 0;

        List <ChatItemBase> list = OnSortTime();

        for (int i = 0; i < list.Count; ++i)
        {
            ChatItemBase item = list[i];

            if (item == null)
            {
                continue;
            }

            Transform t = item.transform;

            if (!NGUITools.GetActive(t.gameObject) && hideInactive)
            {
                continue;
            }

            float   depth = t.localPosition.z;
            Vector3 vTemp = Vector3.zero;
            vTemp.x = 0;
            vTemp.y = height;
            vTemp.z = depth;
            Vector3 pos = vTemp;
            height += cellHeight;
            if (animateSmoothly && Application.isPlaying)
            {
                SpringPosition.Begin(t.gameObject, pos, 15f);
            }
            else
            {
                t.localPosition = pos;
            }
            if (++x >= maxPerLine && maxPerLine > 0)
            {
                x = 0;
                ++y;
            }
        }

        if (mDrag != null)
        {
            mDrag.UpdateScrollbars(true);

            if (isMainHeight)
            {
                mDrag.RestrictWithinBounds(true);
            }
            else
            {
                mDrag.RestrictWithinBounds(true, false, true);
            }
        }
        else if (mPanel != null)
        {
            //if (isMainHeight)
            mPanel.ConstrainTargetToBounds(myTrans, true);
        }

        if (onReposition != null)
        {
            onReposition();
        }
    }