关于短视频平台源码动态广场自动播放gif动图
关于短视频平台源码动态广场自动播放gif动图实现的相关代码
Glide.with(this).load(R.drawable.start_play).listener(new RequestListener<Integer, GlideDrawable>() {
@Override
public boolean onException(Exception arg0, Integer arg1,
Target<GlideDrawable> arg2, boolean arg3) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource,
Integer model, Target<GlideDrawable> target,
boolean isFromMemoryCache, boolean isFirstResource) {
// 计算动画时长
GifDrawable drawable = (GifDrawable) resource;
GifDecoder decoder = drawable.getDecoder();
int duration = 0;
for (int i = 0; i < drawable.getFrameCount(); i++) {
duration += decoder.getDelay(i);
}
duration += 2000;
// 发送延时消息,通知动画结束
handler.sendEmptyMessageDelayed(QUIT_SPLASH_COMMAND,
duration);
return false;
}
}) // 仅仅加载一次gif动画
.into(new GlideDrawableImageViewTarget(gView, 1));
以上就是关于短视频平台源码动态广场自动播放gif动图实现的相关代码, 更多内容欢迎关注之后的文章