package cn.flightfeather.thirdapp.util.photo
|
|
import android.widget.ImageView
|
import cn.flightfeather.thirdapp.CommonApplication
|
import com.bumptech.glide.Glide
|
import com.bumptech.glide.load.DecodeFormat
|
import com.bumptech.glide.request.RequestOptions
|
import com.lcw.library.imagepicker.utils.ImageLoader
|
|
/**
|
* 实现自定义图片加载
|
* @author riku
|
* Date: 2019/10/18
|
*
|
*/
|
class GlideLoader : ImageLoader {
|
|
private val mOptions = RequestOptions()
|
.centerCrop()
|
.format(DecodeFormat.PREFER_RGB_565)
|
|
private val mPreOptions = RequestOptions()
|
.skipMemoryCache(true)
|
|
override fun loadPreImage(imageView: ImageView?, imagePath: String?) {
|
//小图加载
|
imageView?.let {
|
Glide.with(it.context).load(imagePath).apply(mOptions).into(it)
|
}
|
}
|
|
override fun loadImage(imageView: ImageView?, imagePath: String?) {
|
//大图加载
|
imageView?.let {
|
Glide.with(it.context).load(imagePath).apply(mPreOptions).into(it)
|
}
|
}
|
|
override fun clearMemoryCache() {
|
//清理缓存
|
Glide.get(CommonApplication.getInstance()).clearMemory()
|
}
|
|
}
|