package com.bokecc.livemodule.utils;

import android.content.Context;
import android.widget.ImageView;

import androidx.annotation.DrawableRes;

import com.bokecc.dwlivedemo.R;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;

/**
 * Copyright (C), 20105-2021, 创盛视联数码科技（北京）有限公司
 * FileName:
 * Author: huanghai
 * Date: 2023/7/12
 * Description:
 */
public class ImageLoader {

    public static void loadBitmapIntoImageView(Context context, String url, ImageView imageView){
        Glide.with(context).asBitmap().load(url).into(imageView);
    }

    public static void loadIntoImageView(Context context, String url, ImageView imageView){
        Glide.with(context).load(url).into(imageView);
    }
    public static void loadIntoImageView(Context context, String url, ImageView imageView,@DrawableRes int placeholder,@DrawableRes int errorImg){
        Glide.with(context)
                .load(url)
                .placeholder(placeholder)
                //错误图
                .error(errorImg)
                .centerCrop()
                .into(imageView);
    }
    public static void loadIntoImageView(Context context, @DrawableRes int res, ImageView imageView,@DrawableRes int placeholder,@DrawableRes int errorImg){
        Glide.with(context)
                .load(res)
                .placeholder(placeholder)
                //错误图
                .error(errorImg)
                .centerCrop()
                .into(imageView);
    }


    public static void loadGifIntoImageView(Context context, String url, ImageView imageView){
        Glide.with(context).asGif().load(url).into(imageView);
    }
    public static void loadGifIntoImageView(Context context, @DrawableRes int resId, ImageView imageView){
        Glide.with(context).asGif().load(resId).into(imageView);
    }




    public static void loadCircleBitmapIntoImageView(Context context, String url, ImageView imageView){
        Glide.with(context)
                .load(url)
                .apply(RequestOptions.circleCropTransform().error(R.drawable.user_head_icon))
                .into(imageView);
    }

}
