package com.quansu.heifengwuliu.utils

import android.content.Context
import android.widget.ImageView
import coil.load
import coil.transform.CircleCropTransformation
import com.luck.picture.lib.engine.ImageEngine
import com.luck.picture.lib.listener.OnImageCompleteCallback
import com.luck.picture.lib.widget.longimage.SubsamplingScaleImageView
import com.quansu.heifengwuliu.R
import java.io.File

/**
 *Created by shihuiyun
 *on 2020/9/16
 */
 object  LoadEngin : ImageEngine {


    override fun loadImage(context: Context, url: String, imageView: ImageView) {
        imageView.load(url)
    }

    override fun loadImage(context: Context, url: String, imageView: ImageView, longImageView: SubsamplingScaleImageView?, callback: OnImageCompleteCallback?) {
        imageView.load(url)
    }

    override fun loadImage(context: Context, url: String, imageView: ImageView, longImageView: SubsamplingScaleImageView?) {
        imageView.load(url)
    }

    override fun loadAsGifImage(context: Context, url: String, imageView: ImageView) {
        imageView.load(url)
    }

    override fun loadGridImage(context: Context, url: String, imageView: ImageView) {
        imageView.load(File(url))
    }

    override fun loadFolderImage(context: Context, url: String, imageView: ImageView) {

        imageView.load(url) {
            crossfade(true)
            placeholder(R.drawable.picture_image_placeholder)
            transformations(CircleCropTransformation())
        }
    }


}
