zhihu / Matisse

:fireworks: A well-designed local image and video selector for Android
Apache License 2.0
12.52k stars 2.06k forks source link

Integrate Glide V4 #167

Open FynnJason opened 7 years ago

Saxxhw commented 7 years ago

可以自己实现ImageEngine里的方法 ` public class GlideEngine implements ImageEngine {

@Override
public void loadThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) {
    // 加载图片
    Glide.with(context)
            .asBitmap()
            .load(uri)
            .apply(new RequestOptions().placeholder(placeholder).override(resize, resize).centerCrop())
            .transition(new BitmapTransitionOptions().crossFade(300))
            .into(imageView);
}

@Override
public void loadGifThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) {
    Glide.with(context)
            .asBitmap()
            .load(uri)
            .apply(new RequestOptions().placeholder(placeholder).override(resize, resize).centerCrop())
            .transition(new BitmapTransitionOptions().crossFade(300))
            .into(imageView);
}

@Override
public void loadImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) {
    Glide.with(context)
            .load(uri)
            .apply(new RequestOptions().priority(Priority.HIGH).override(resizeX, resizeY).centerCrop())
            .transition(new DrawableTransitionOptions().crossFade(300))
            .into(imageView);
}

@Override
public void loadGifImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) {
    Glide.with(context)
            .asGif()
            .load(uri)
            .apply(new RequestOptions().priority(Priority.HIGH).override(resizeX, resizeY).centerCrop())
            .into(imageView);
}

@Override
public boolean supportAnimatedGif() {
    return true;
}

}`

gejiaheng commented 7 years ago

A PR has been sent developing this feature, see https://github.com/zhihu/Matisse/pull/114.