riku
2022-02-18 d59d55575d913646b7a90fca651904ab889c6723
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package cn.flightfeather.thirdappmodule.util.photo
 
import android.widget.ImageView
import cn.flightfeather.thirdappmodule.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()
    }
 
}