-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Allow null transformations? #910
Comments
Nevermind, I didn't realize you could apply multiple transformations. |
What about taking a Collection that could be empty?
|
Yes, perhaps a |
We've had this problem as well. Want to PR?
|
Sure, on it |
I, too, didnt want to break the builder syntax, so that means always needing to call I solved this by first creating a no-op transformation: public class NoOpTransformation implements Transformation {
@Override
public Bitmap transform(Bitmap source) {
return source;
}
@Override
public String key() {
return "noop";
}
} And then I can keep a local instance variable representing this transformation, otherwise I can re-set the instance variable to my "real" transformation as needed and invocation always look like: /* somewhere else ... */
backgroundTransformation = new NoOpTransformation();
/* or elsewhere */
backgroundTransformation = new StrokeTransformation();
// later
mPicasso
.load(mMetric.photoURL)
.noFade()
.transform(backgroundTransformation)
.placeholder(R.drawable.grid_gradient)
.fit()
.into(mViewHolder.background); Are there any downsides to this? |
Yes. An image loaded with that transformation and an image loaded without On Thu, Mar 19, 2015 at 1:14 PM Cody Caughlan notifications@github.com
|
Gotcha! Thanks for the response. I'll implement |
Would you merge a PR that allowed you to set a null transformation?
Currently, you'll encounter the following exception:
Our loading code originally looked something like this:
Now, we're allowing a subclasses to specify an optional transformation, like this:
It would be much nicer if we could instead do this:
The text was updated successfully, but these errors were encountered: