-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Reduce the number of measure calls for children of Flexbox #514
Conversation
This PR prevents the number of measure calls for the children of the Flexbox. If any items in a FlexLine don't have the flexGrow or flexShrink attributes set, the children in the FlexLine don't have to be measured in the FlexboxHelper#determineMainSize method. Similarly, if the AlignItems attribute for the Flexbox is not equal to AlignItems.STRETCH nor any items in a FlexLine don't have the AlignSelf.STRETCH attributes, the items in the FlexLine don't have to be measured in the FlexboxHelpers#stretchViews method. Also this PR changes the default values of FlexboxLayout as follows: - mAlignItems: STRETCH -> FLEX_START - mAlignContent: STRETCH -> FLEX_START
If the temporary calculated line length is less than the length of the main axis, the calculation isn't needed.
@@ -223,8 +223,8 @@ public FlexboxLayout(Context context, AttributeSet attrs, int defStyleAttr) { | |||
mFlexWrap = a.getInt(R.styleable.FlexboxLayout_flexWrap, FlexWrap.NOWRAP); | |||
mJustifyContent = a | |||
.getInt(R.styleable.FlexboxLayout_justifyContent, JustifyContent.FLEX_START); | |||
mAlignItems = a.getInt(R.styleable.FlexboxLayout_alignItems, AlignItems.STRETCH); | |||
mAlignContent = a.getInt(R.styleable.FlexboxLayout_alignContent, AlignContent.STRETCH); | |||
mAlignItems = a.getInt(R.styleable.FlexboxLayout_alignItems, AlignItems.FLEX_START); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this break existing apps? Should we bump up the major version if so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it may break the existing apps and we should bump the major version once we release it.
I think it's better in the long run because setting the AlignItems.STRETCH is expensive like setting the weight attribute in LinearLayout especially FlexboxLayout is nested more than several levels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. It makes sense.
Can you please mention the changes to default values in |
Sure. I'll update the README as well. Thanks for pointing it out.
2019年11月13日(水) 11:08 Artem Tyurin <notifications@github.com>:
… Can you please mention the changes to default values in Known differences
from the original CSS specification in README?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#514?email_source=notifications&email_token=AAGCNSI4HS4W5R2RN2OANLTQTNOQZA5CNFSM4JERALVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOED4TWFI#issuecomment-553204501>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGCNSPBXT373TCDZ4ITOGLQTNOQZANCNFSM4JERALVA>
.
|
This PR reduces the number of measure calls for the children of the
Flexbox.
If any items in a FlexLine don't have the flexGrow or flexShrink
attributes set, the children in the FlexLine don't have to be measured
in the FlexboxHelper#determineMainSize method.
Similarly, if the AlignItems attribute for the Flexbox is not equal to
AlignItems.STRETCH nor any items in a FlexLine don't have the
AlignSelf.STRETCH attributes, the items in the FlexLine don't have to be
measured in the FlexboxHelpers#stretchViews method.
Also this PR changes the default values of FlexboxLayout as follows:
Fixes #46