Android图片缓存框架 - Fresco的显示GIF (九)

目录

1.Fresco 简介

2. Fresco 文档

3. Fresco开发步骤

4. Fresco加载图片6种方式

5. Drawees xm属性设置

6 Fresco实现圆角或圆形图片

7. DraweeHierarchy设置

8. Fresco的DraweeController

9. ControllerListener 图片加载监听

10. Fresco的ImageRequest

11 Fresco的显示GIF

11.1 设置动画显示

11.2 动画监听

12 Fresco的BasePostprocessor图片处理

13.Fresco设置和清除缓存


11 Fresco的显示GIF

11.1 设置动画显示

 String gifUrl = "https://upfile.asqql.com/2009pasdfasdfic2009s305985-ts/2018-11/201811301685857474.gif";

 DraweeController controller2 = draweeView.getController();  
 DraweeController controller = Fresco
                    .newDraweeControllerBuilder()
                    .setUri(Uri.parse(gifUrl))
                    .setControllerListener(new MyControllerListener())
                    .setAutoPlayAnimations(true) //是否播放动画
                    .build();

  draweeView.setController(controller);
  animatable = draweeView.getController().getAnimatable();

11.2 动画监听

private class MyControllerListener extends BaseControllerListener {
        @Override
        public void onSubmit(String id, Object callerContext) {
            super.onSubmit(id, callerContext);
            if (animatable != null) {
                animatable.start();
            }
        }

        //下载完成
        @Override
        public void onFinalImageSet(String id, @Nullable Object imageInfo, @Nullable Animatable animatable) {
            super.onFinalImageSet(id, imageInfo, animatable);

        }

        @Override
        public void onIntermediateImageSet(String id, @Nullable Object imageInfo) {
            super.onIntermediateImageSet(id, imageInfo);
        }

        @Override
        public void onIntermediateImageFailed(String id, Throwable throwable) {
            super.onIntermediateImageFailed(id, throwable);
        }

        @Override
        public void onFailure(String id, Throwable throwable) {
            super.onFailure(id, throwable);
        }

        @Override
        public void onRelease(String id) {
            super.onRelease(id);
        }

    }

 

你可能感兴趣的:(Android图片缓存框架,Fresco,Android开发,Android图片缓存框架,Fresco)