-
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
Fix issue #336 #339
base: main
Are you sure you want to change the base?
Fix issue #336 #339
Conversation
This is not the best sulotion,but now it can resolve the problem. This problem is not so easy. Calculate the decoration is conflict with the method isWrapRequired,and i can not reuse the view for both calculate the decoraion and isWrapRequired. So this solution is just for get the decoration with the view,and the capability maybe not so good.But it certenly solve the problem.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I have got CLA data |
CLAs look good, thanks! |
if (isMainAxisDirectionHorizontal()) { | ||
return getLeftDecorationWidth(view) + getRightDecorationWidth(view); | ||
return getLeftDecorationWidth(v) + getRightDecorationWidth(v); |
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 really don't like this solution. Why? You're creating new View
instance instead of reusing the existing one.
Code from lines 371 and 372 you should put into if conditional statement, but instead of using new v
variable, please use existing view
.
To be more precise:
if (isMainAxisDirectionHorizontal()) {
view = mRecycler.getViewForPosition(index);
calculateItemDecorationsForChild(view, TEMP_RECT);
return getLeftDecorationWidth(view) + getRightDecorationWidth(view);
} else {
return getTopDecorationHeight(view) + getBottomDecorationHeight(view);
}
Another thing - did you write any test or check it on more than 3 different devices?
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.
Thank you.I have modify the code.
But i have to say.
view = mRecycler.getViewForPosition(index);
calculateItemDecorationsForChild(view, TEMP_RECT);
Here actually is not the best solution because calculateItemDecorationsForChild is invoked frequent.But it is a solution.
At last. I write the test code and test on HUAWEI and SAMSUNG devices.
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.
Please reformat code to avoid creating new variable by reusing existing one.
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.
Thanks for your fix @ly85206559, really appreciated.
However, as @piotrek1543 says, your patch creates a new View every time getDecorationLengthMainAxis is called. So it looks it's going to allocate extra memory a lot.
This issue isn't as easy to fix as it seems because it needs to know the decoration length even before the view in question becomes part of a flex line.
So also from my end, let me think about how this should be fixed.
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.
@ly85206559 thanks for changes but wait until @thagikura would provide better solution or merge existing one.
This is not the best sulotion,but now it can resolve the problem.
This problem is not so easy.
Calculate the decoration is conflict with the method isWrapRequired,and i can not reuse the view for both calculate the decoraion and isWrapRequired.
So this solution is just for get the decoration with the view,and the capability maybe not so good.But it certenly solve the problem.