Reputation: 1964
I am using Picasso for my Android app. Using Picasso transforms i rendered the images transformed in some sections of my app, but when i try to render the image in another part, I get the transformed image as well. How can i get the original image to display it without transformation?
Here is a code example.
String imageUrl = "http://path/image.png";
CustomTransformation *trans= new CustomTransformation();
Picasso.with(this).load(imageUrl).transform(trans).into(myImageView1);
Picasso.with(this).load(imageUrl).into(myImageView2);
After this the two image views are displaying the image with the transformation applied to both of them
Upvotes: 3
Views: 1236
Reputation: 257
Probably you don't set the transformation key so the caching mechanism doesn't see the difference. Example:
private Transformation blur = new Transformation() {
@Override
public Bitmap transform(Bitmap source) {
Bitmap blurred = BitmapUtils.createBlurredBitmap(source);
source.recycle();
return blurred;
}
@Override
public String key() {
return "blurred"; //this will be added to the key that Picasso uses for caching
}
};
//key: <uri>\nblurred
void loadAndBlur(Uri uri, ImageView mPhoto) {
picasso.load(uri).transform(blur).into(mPhoto);
}
//key: <uri>
void load(Uri uri, ImageView mPhoto) {
picasso.load(uri).into(mPhoto);
}
Upvotes: 3