I have implemented a custom view that has a DraweeHolder. I have implemented all callbacks and listeners for my custom view (attach / detach / invalidateDrawable / setListener).
If I set a GIF image url to controller - it does not play gif correctly. It refreshes the gif only when the view is redrawn. I guess that animated GIF should have some invalidation callback or something.
P.S. Gif does work correctly if I use DraweeView. Also all other images work correctly inside my custom view.
Creating holder:
private DraweeHolder<GenericDraweeHierarchy> createComponentHolder(View parent, Context context) {
GenericDraweeHierarchy componentHierarchy = new GenericDraweeHierarchyBuilder(parent.getResources())
.setRoundingParams(RoundingParams.fromCornersRadius(LayoutHelper.dp(3)).setBorder(Theme.COLOR_MEDIA_BORDER, 1))
.build();
DraweeHolder<GenericDraweeHierarchy> holder = DraweeHolder.create(componentHierarchy, context);
holder.getTopLevelDrawable().setCallback(parent);
return holder;
}
Setting controller:
PipelineDraweeControllerBuilder controllerBuilder = Fresco.newDraweeControllerBuilder()
.setImageRequest(MediaHelper.getImageRequest(filePath))
.setAutoPlayAnimations(true)
.setControllerListener(controllerListener)
.setOldController(draweeHolder.getController());
if (thumbUrl != null) {
controllerBuilder.setLowResImageRequest(getThumbnailRequest(thumbUrl));
}
draweeHolder.setController(controllerBuilder.build());
Image request:
public static ImageRequest getImageRequest(String filePath) {
int imageSize = LayoutHelper.dp(100);
return ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(new File(filePath)))
.setResizeOptions(new ResizeOptions(imageSize, imageSize))
.setAutoRotateEnabled(true)
.build();
}