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

Fix issue #336 #339

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Fix issue #336 #339

wants to merge 2 commits into from

Conversation

ly85206559
Copy link

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.

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.
@googlebot
Copy link

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 signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If your company signed a CLA, they designated a Point of Contact who decides which employees are authorized to participate. You may need to contact the Point of Contact for your company and ask to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the project maintainer to go/cla#troubleshoot.
  • In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

@ly85206559
Copy link
Author

I have got CLA data

@googlebot
Copy link

CLAs look good, thanks!

if (isMainAxisDirectionHorizontal()) {
return getLeftDecorationWidth(view) + getRightDecorationWidth(view);
return getLeftDecorationWidth(v) + getRightDecorationWidth(v);
Copy link

@piotrek1543 piotrek1543 Aug 7, 2017

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?

Copy link
Author

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.

Copy link

@piotrek1543 piotrek1543 left a 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.

Copy link
Contributor

@thagikura thagikura left a 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.

Copy link

@piotrek1543 piotrek1543 left a 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.

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

Successfully merging this pull request may close these issues.

4 participants