0

I have a SimpleDraweeView that is processing an image request through a controller:

Postprocessor redMeshPostprocessor = new BasePostprocessor() {
                @Override
                public String getName() {
                    return "redMeshPostprocessor";
                }

                @Override
                public CloseableReference<Bitmap> process(
                        Bitmap sourceBitmap,
                        PlatformBitmapFactory bitmapFactory) {
                    //custom processing on the bitmap and returning it

                }
            };

            ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(coverImage))
                    .setPostprocessor(redMeshPostprocessor)
                    .build();

            PipelineDraweeController controller = (PipelineDraweeController)
                    Fresco.newDraweeControllerBuilder()
                            .setImageRequest(request)
                            .setOldController(iv_cover.getController())
                            // other setters as you need
                            .build();
            iv_cover.setController(controller);

Then later on, I want to change the image on the SimpleDraweeView by simply saying:

iv_cover.setImageURI(Uri.parse(url));

Problem is that when loading the second image, there's a split second where the SimpleDraweeView is showing the placeholder. How to avoid that? Want the transition between the 2 images to be gapless and smooth. Thanks!

Ziad Halabi
  • 964
  • 11
  • 31

1 Answers1

2

You can do this:

PipelineDraweeController controller = (PipelineDraweeController)
                Fresco.newDraweeControllerBuilder()
                        .setLowResImageRequest(previousRequest)
                        .setImageRequest(newRequest)
                        .setOldController(iv_cover.getController())                           
                        .build();
        iv_cover.setController(controller);

This should give you the behaviour you want.

tyronen
  • 2,558
  • 1
  • 11
  • 15