Fresco:SimpleDraweeView总是重置

时间:2016-04-26 15:20:40

标签: java android fresco

我有一个通过控制器处理图像请求的SimpleDraweeView:

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);

然后,我想通过简单地说:

来更改SimpleDraweeView上的图像
iv_cover.setImageURI(Uri.parse(url));

问题是,在加载第二张图片时,SimpleDraweeView会显示占位符。怎么避免呢?希望2幅图像之间的过渡是无间隙和平滑的。谢谢!

1 个答案:

答案 0 :(得分:1)

你可以这样做:

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

这可以为您提供所需的行为。