Image conversion does not apply after changing orientation using Picasso

I use the Picasso and RoundedTransformation class , which applies rounded corners to the image that I load Picasso. The corresponding code is given below:

Transformation transformation = new RoundedTransformationBuilder()
            .cornerRadiusDp(4)
            .oval(false)
            .build();

ImageView cardViewTop1Image = (ImageView) cardViewTop1.findViewById(R.id.cv_top1_image);
Picasso.with(cardViewTop1.getContext()).load("http:/some_image_url.com")
            .fit().centerCrop()
            .transform(transformation).into(cardViewTop1Image);

All this works fine until I go through two orientation changes - first to horizontal orientation, and then back to vertical orientation. When I return to the vertical orientation, the rounded transform is no longer applied.

I believe that Picasso caches an unformed image and then fills it with an ImageView. Is there a way to cache the converted image or load a non-transformed image from the cache and then apply the conversion? Thanks for the help!

+4
1

, .

Picasso.with(yourContext)
        .load(yourUrl)
        .memoryPolicy(MemoryPolicy.NO_CACHE )
        .networkPolicy(NetworkPolicy.NO_CACHE)
        .fit()
        .centerCrop()
        .transform(yourTransformation)
        .into(yourImageView);

. https://gist.github.com/aprock/6213395.

0

Source: https://habr.com/ru/post/1570240/


All Articles