package com.zswc.creativity.utils

import android.content.Context
import android.util.Log
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.zswc.creativity.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)
        if(url.contains("content://")){
//            imageView.load(url) {
//                crossfade(true)
//                placeholder(R.drawable.picture_image_placeholder)
//                transformations(CircleCropTransformation())
//            }

            imageView.load(url)

        }else{
            imageView.load(File(url))

        }


        Log.e("-shy-", "url1=: "+url )

    }

    override fun loadImage(context: Context, url: String, imageView: ImageView, longImageView: SubsamplingScaleImageView?, callback: OnImageCompleteCallback?) {
        imageView.load(url)
        Log.e("-shy-", "url2=: "+url )

    }

    override fun loadImage(context: Context, url: String, imageView: ImageView, longImageView: SubsamplingScaleImageView?) {
        imageView.load(url)
        Log.e("-shy-", "url3=: "+url )


    }

    override fun loadAsGifImage(context: Context, url: String, imageView: ImageView) {
        imageView.load(url)
        Log.e("-shy-", "url4=: "+url )

    }

    override fun loadGridImage(context: Context, url: String, imageView: ImageView) {
        Log.e("-shy-", "url5=: "+url )
        if(url.contains("content://")){
//            imageView.load(url) {
//                crossfade(true)
//                placeholder(R.drawable.picture_image_placeholder)
//                transformations(CircleCropTransformation())
//            }

            imageView.load(url)

        }else{
            imageView.load(File(url))

        }

    }

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

        Log.e("-shy-", "url6=: "+url )
//        imageView.load(url) {
//            crossfade(true)
//            placeholder(R.drawable.picture_image_placeholder)
//            transformations(CircleCropTransformation())
//        }

        imageView.load(url)
    }

}
