Esempio n. 1
0
        private int layoutChild(LayoutState.View child, int markerLine, LayoutManager.Direction direction, SectionData sd, LayoutState state)
        {
            int height = mLayoutManager.GetDecoratedMeasuredHeight(child.view);
            int width  = mLayoutManager.GetDecoratedMeasuredWidth(child.view);

            int left  = state.isLTR ? sd.contentStart : sd.contentEnd;
            int right = left + width;
            int top;
            int bottom;

            if (direction == LayoutManager.Direction.END)
            {
                top    = markerLine;
                bottom = top + height;
            }
            else
            {
                bottom = markerLine;
                top    = bottom - height;
            }
            mLayoutManager.LayoutDecorated(child.view, left, top, right, bottom);

            if (direction == LayoutManager.Direction.END)
            {
                markerLine = mLayoutManager.GetDecoratedBottom(child.view);
            }
            else
            {
                markerLine = mLayoutManager.GetDecoratedTop(child.view);
            }

            return(markerLine);
        }
Esempio n. 2
0
        /// <summary>
        /// Fill a row.
        /// </summary>
        /// <param name="markerLine">      Line indicating the top edge of the row. </param>
        /// <param name="anchorPosition">  Position of the first view in the row. </param>
        /// <param name="direction">       Direction of edge to fill towards. </param>
        /// <param name="measureRowItems"> Measure the row items. </param>
        /// <param name="sd">              Section data. </param>
        /// <param name="state">           Layout state. </param>
        /// <returns> The height of the new row. </returns>
        public int fillRow(int markerLine, int anchorPosition, LayoutManager.Direction direction, bool measureRowItems, SectionData sd, LayoutState state)
        {
            int rowHeight = 0;

            LayoutState.View[] views = new LayoutState.View[mNumColumns];
            for (int i = 0; i < mNumColumns; i++)
            {
                int position = anchorPosition + i;
                if (position >= state.recyclerState.ItemCount)
                {
                    break;
                }

                LayoutState.View view = state.GetView(position);
                if (view.LayoutParams.FirstPosition != sd.firstPosition)
                {
                    state.CacheView(position, view.view);
                    break;
                }

                if (measureRowItems)
                {
                    MeasureChild(view, sd);
                }
                else
                {
                    state.DecacheView(i + anchorPosition);
                }
                rowHeight = Math.Max(rowHeight, mLayoutManager.GetDecoratedMeasuredHeight(view.view));
                views[i]  = view;
            }

            bool directionIsStart = direction == LayoutManager.Direction.START;

            if (directionIsStart)
            {
                markerLine -= rowHeight;
            }

            for (int i = 0; i < mNumColumns; i++)
            {
                int col = directionIsStart ? mNumColumns - i - 1 : i;
                if (views[col] == null)
                {
                    continue;
                }
                LayoutChild(views[col], markerLine, col, rowHeight, sd, state);
                AddView(views[col], col + anchorPosition, direction, state);
            }

            return(rowHeight);
        }
Esempio n. 3
0
        protected int AddView(LayoutState.View child, int position, LayoutManager.Direction direction, LayoutState state)
        {
            int addIndex;

            if (direction == LayoutManager.Direction.START)
            {
                addIndex = 0;
            }
            else
            {
                addIndex = mLayoutManager.ChildCount;
            }

            state.DecacheView(position);
            mLayoutManager.AddView(child.view, addIndex);

            return(addIndex);
        }