GlideHelper.java
2.54 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package com.prws.common.utils;
import android.content.Context;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import java.io.File;
/**
* @author zhiqun.tang
* @Description: Glide 工具类
* @date 2022/8/10
*/
public class GlideHelper {
/**
* 加载图片Url
*
* @param mContext
* @param url
* @param imageView
*/
public static void loadUrl(Context mContext, String url, ImageView imageView) {
if (mContext != null) {
Glide.with(mContext.getApplicationContext())
.load(url)
// .format(DecodeFormat.PREFER_RGB_565)
// 取消动画,防止第一次加载不出来
//加载缩略图
.thumbnail(0.3f)
.into(imageView);
}
}
/**
* 加载图片Url
*
* @param mContext
* @param resourceId
* @param imageView
*/
public static void loadUrl(Context mContext, int resourceId, ImageView imageView) {
if (mContext != null) {
Glide.with(mContext.getApplicationContext())
.load(resourceId)
// .format(DecodeFormat.PREFER_RGB_565)
// 取消动画,防止第一次加载不出来
//加载缩略图
.thumbnail(0.3f)
.into(imageView);
}
}
/**
* 加载图片Url
*
* @param mContext
* @param url
* @param imageView
*/
public static void loadSmollUrl(Context mContext, String url, int w, int h, ImageView imageView) {
if (mContext != null) {
Glide.with(mContext.getApplicationContext())
.load(url)
// .format(DecodeFormat.PREFER_RGB_565)
// 取消动画,防止第一次加载不出来
//加载缩略图
.thumbnail(0.3f)
.into(imageView);
}
}
/**
* 加载图片File
*
* @param mContext
* @param file
* @param imageView
*/
public static void loadFile(Context mContext, File file, ImageView imageView) {
if (mContext != null) {
Glide.with(mContext.getApplicationContext())
.load(file)
// 取消动画,防止第一次加载不出来
//加载缩略图
.thumbnail(0.3f)
.into(imageView);
}
}
}