短视频系统,使用Glide播放gif图的相关用法
短视频系统,使用Glide播放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));
以上就是短视频系统,使用Glide播放gif图的相关用法, 更多内容欢迎关注之后的文章