square/picasso — pull request #365 by JayH5 (2014-01-21 17:12:40+00:00)
Title: Add ability to fit image to a single dimension

* Make resizing API more flexible with separate width() and
height() calls.
* Make it possible to set size of one dimension and let other be
determined when view is laid out.
* Tests

### Use case:
This may not be the most common use case but I still think it could be useful to some people (it was to me). This change is useful if you know one dimension of an image but want the other to be dynamically sized.

In my particular case I had a DialogFragment with an image that was displayed at the top end of it. The ```ImageView``` was set to match the width of the dialog (```match_parent```) but only be as tall as its contents ```wrap_content```. I had a specific height for the image that I wanted if it *did* load. I didn't (necessarily) know the width of the Dialog at the time the call to Picasso was made as it wasn't necessarily yet laid out. With these new changes I can do:
```java
Picasso.with(context).load(uri).fit().heightDimen(R.dimen.header_height).into(imageView);
```

Which results in an image that can "fill up" a view if the image exists.

These changes also make it slightly more convenient to work with ```resize()``` and ```resizeDimen()```. Often times I've found that I have one of my dimensions in pixel size (I've measured some other view to, say, get the height) and the other dimension in resources. This change allows mixing pixel and resource dimensions:
```java
Picasso.with(context).load(uri).width(10).heightDimen(R.dimen.my_height).into(target);
```