Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
LiuBeixi opened this issue Sep 8, 2023 · 0 comments

Comments

@LiuBeixi
Copy link

LiuBeixi commented Sep 8, 2023

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;
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant