目录
12 Fresco的BasePostprocessor图片处理
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);
}
}