Skip to content

Repository files navigation

本项目已过时,Glide4.0后对GIF已经有很好的支持



基于[glide](https://github.com/bumptech/glide)与 [android-gif-drawable](https://github.com/koral--/android-gif-drawable)对Glide处理Gif进行加强

示例apk

快速开始

Gradle

compile 'com.dyhdyh.support:glide-plus:1.0.1'
compile 'com.github.bumptech.glide:glide:3.7.0'

示例

GlidePlus.with(this)
                .gifPlus()//开启gif增强
                .circle()//圆形
                //.crossFade()//淡入淡出(默认开启)
                //.transform(new ImageWrapperCircleTransformation())
                //.animate(new DrawableScaleBounceAnimator())
                .glide()
                .load(url)
                .placeholder(R.mipmap.placeholder)
                .error(R.mipmap.error)
                .into(iv);

效果

对比图

在RecyclerView中使用的注意事项

1.重写Adapter中onViewDetachedFromWindowonViewAttachedToWindow,在Item出屏的时候暂停播放gif,进屏的时候再播放gif,这样可以节省一些性能。

@Override
public void onViewDetachedFromWindow(ViewHolder holder) {
    Drawable drawable = holder.iv.getDrawable();
    if (drawable instanceof pl.droidsonroids.gif.GifDrawable){
        ((pl.droidsonroids.gif.GifDrawable) drawable).pause();
    }
}

@Override
public void onViewAttachedToWindow(ViewHolder holder) {
    Drawable drawable = holder.iv.getDrawable();
    if (drawable instanceof pl.droidsonroids.gif.GifDrawable){
        ((pl.droidsonroids.gif.GifDrawable) drawable).start();
    }
}

About

基于glide与android-gif-drawable对Glide处理Gif进行加强

Topics

Resources

Stars

14 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages