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

Ensure View dimensions are evaluated to at least 1px. #29

Merged
merged 2 commits into from
Aug 15, 2019

Conversation

colinrtwhite
Copy link
Member

Fixes: #20

This fixes the case where one or more of a View's dimensions resolves to 0px. In this case, we treat the dimension as 1px. Image dimensions must be loaded with all dimensions > 0 so this saves us from handling a lot of complexity later in the image pipline.

viewTreeObserver.removePreDrawListenerSafe(this)
val width = max(1, view.width - view.paddingLeft - view.paddingRight)
val height = max(1, view.height - view.paddingTop - view.paddingBottom)
continuation.resume(PixelSize(width, height))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!isResumed check no longer needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I didn't think we did initially, but I'm going to leave it in for safety. It's to prevent resuming the continuation twice, which would throw an exception.

Jawnnypoo
Jawnnypoo previously approved these changes Aug 14, 2019
@colinrtwhite colinrtwhite merged commit 3d190e8 into master Aug 15, 2019
@colinrtwhite colinrtwhite deleted the colin/fix_wrap_content branch August 15, 2019 06:52
colinrtwhite added a commit that referenced this pull request Oct 5, 2022
* Ensure View dimensions are at least 1px.

* Re-add resumed check.
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.

ImageView with one of its dimensions set to wrap_content does not work
2 participants