Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kwangsu61
Copy link

onlyScaleDown() method is so useful to avoid useless bitmap scale up for memory usage and performance.

This PR allows that onlyScaleDown() works with fit() method like centerCrop()/centerInside().

Refer to #941

@magneticflux-
Copy link

It seems like an arbitrary restriction, I'd love this change! .fit() just uses .resize() behind the scenes, so I don't seen any problems using .onlyScaleDown() with it.

Copy link

@magneticflux- magneticflux- left a comment

Choose a reason for hiding this comment

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

Some confusing wording in the error and possible mistype.

throw new IllegalStateException(
"Center inside requires calling resize with positive width and height.");
}
if (onlyScaleDown && (targetWidth == 0 && targetHeight == 0)) {

Choose a reason for hiding this comment

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

Should this be if(deferred || (targetWidth == 0 && targetHeight == 0))?

Copy link
Collaborator

Choose a reason for hiding this comment

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

And this check should be moved back to the onlyScaleDown method.

Choose a reason for hiding this comment

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

@JakeWharton This method is in the Request class, which seems to be in line with the other checks such as for null lists, invalid properties, and center[Crop|Inside] checks.

Choose a reason for hiding this comment

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

Ahh, the Request class has no knowledge of fitting, which is done in the RequestCreator class. I'm going to make my own pull request that will hopefully fix these issues cleanly.

}
try {
new RequestCreator(picasso, URI_1, 0).onlyScaleDown().into(mockTarget());
fail("onlyScaleDown with unknown height should throw exception.");

Choose a reason for hiding this comment

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

Shouldn't this fail when .onlyScaleDown() is called without a call to .fit() or .resize(int, int)?


@Test
public void intoTargetNoResizeWithCenterInsideOrCenterCropThrows() {
public void intoTargetNoResizeWithCenterInsideOrCenterCropOrOnlyScaleDownThrows() {

Choose a reason for hiding this comment

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

This should probably also be named intoTargetNoResizeOrFitWithCenterInsideOrCenterCropOrOnlyScaleDownThrows.

@magneticflux-
Copy link

@JakeWharton I have an alternative pull request, #1623, that I believe fixes the issues with this 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.

3 participants