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

Not possible load image on ImageView with WRAP_CONTENT? #40

Closed
savvasdalkitsis opened this issue Nov 7, 2013 · 2 comments
Closed

Not possible load image on ImageView with WRAP_CONTENT? #40

savvasdalkitsis opened this issue Nov 7, 2013 · 2 comments

Comments

@savvasdalkitsis
Copy link
Contributor

We are getting this exception while running our acceptance tests:

11-07 17:13:45.324    2956-2956/com.shazam.android W/System.err﹕ java.lang.IllegalArgumentException: class com.bumptech.glide.loader.image.ImageManagerLoader cannot handle width=-2 and/or height =-1

It seems that our ImageView has width = WRAP_CONTENT and height = MATCH_PARENT.

From the code, I can see that Glide will throw an exception if the following is not true:

width >= 0 && height >= 0 ||
                (downsampler == Downsampler.NONE && (width == WRAP_CONTENT || height == WRAP_CONTENT));

Is there no way for Glide to determine that the target is an imageview that has been laid out and retrieve the dimensions from it directly?

From a quick glance, that would require quite deep changes to the model unless I am missing something

@sjudd
Copy link
Collaborator

sjudd commented Nov 7, 2013

This is because we really don't know what you want with that combination. If you want the image the be as tall as the parent, unless you want to stretch or squash the image, the width must increase to match in which case we're not really obeying wrap content as the width.

You can get around this using the asIs() method on your request. This disables downsampling, which is unfortunate, but it will load the image and is probably fine for a one off view. Transformations, if you're using them, will probably still fail because they won't get a valid width and height.

@sjudd
Copy link
Collaborator

sjudd commented Mar 21, 2014

I believe this is fixed here: 635d04f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants