Skip to content

Is there possible to set "needsToFill" not only mContext.getResources().getDisplayMetrics().heightPixels? #629

Open
@LiuBeixi

Description

@LiuBeixi

Issues and steps to reproduce

RecyclerView(height is wrap_content) + FlexboxLayoutManager and use a custom maxHeight to change RecyclerView heightMeasureSpec by makeMeasureSpec.
when FlexboxLayoutManager updateFlexLines,it will use display height to judged sumCrossSize,so all child will be create and measure. But i just want to measure the child at maxHeight. create all child will drop RecyclerView performance

Expected behavior

measure those childviews that are needed.
In my opinion, Is there possible to set needsToFill to getHeight()/getWidth() when spec mode is AT_MOST

Version of the flexbox library

3.0.0

Link to code

 if (isMainAxisDirectionHorizontal()) {
            isMainSizeChanged = mLastWidth != Integer.MIN_VALUE && mLastWidth != width;

            // If the mInfinite flag is set to true (that usually happens when RecyclerViews are
            // nested and inner RecyclerView's layout_height is set to wrap_content, thus height is
            // passed as 0 from the RecyclerView)
            // Set the upper limit as the height of the device in order to prevent computing all
            // items in the adapter
            needsToFill = mLayoutState.mInfinite ?
                    mContext.getResources().getDisplayMetrics().heightPixels
                    : mLayoutState.mAvailable;
        } else {
            isMainSizeChanged = mLastHeight != Integer.MIN_VALUE && mLastHeight != height;

            // If the mInfinite flag is set to true (that usually happens when RecyclerViews are
            // nested and inner RecyclerView's layout_width is set to wrap_content, thus width is
            // passed as 0 from the RecyclerView)
            // Set the upper limit as the width of the device in order to prevent computing all
            // items in the adapter
            needsToFill = mLayoutState.mInfinite ?
                    mContext.getResources().getDisplayMetrics().widthPixels
                    : mLayoutState.mAvailable;
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions