GlideUtils.java
1.9 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
package com.shunzhi.parent.util;
import android.content.Context;
import android.text.TextUtils;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.shunzhi.parent.AppConfig;
import com.shunzhi.parent.R;
import com.squareup.picasso.Picasso;
/**
* Created by ToaHanDong on 2018/3/21.
*/
public class GlideUtils {
public static void showImg(Context context, ImageView imageView,String url){
if (!TextUtils.isEmpty(url)){
if (url.startsWith("http"))
Glide.with(context).load(url).placeholder(R.color.xueqing_blue)
.into(imageView);
else Glide.with(context).load(AppConfig.BASE_URL_FILE+url).placeholder(R.color.xueqing_blue)
.into(imageView);
}else {
Glide.with(context).load(url).placeholder(R.color.xueqing_blue).centerCrop().into(imageView);
}
}
public static void showImgWithPicass(Context context,ImageView imageView,String url){
if (!TextUtils.isEmpty(url)){
if (url.startsWith("http"))
Picasso.get().load(url).error(R.color.xueqing_blue).into(imageView);
else Picasso.get().load(AppConfig.BASE_URL_FILE+url).error(R.color.xueqing_blue).into(imageView);
}else {
Picasso.get().load(url).error(R.color.xueqing_blue).into(imageView);
}
}
public static void showImgWithDefaule(Context context,ImageView imageView,String url,int defaultImg){
if (!TextUtils.isEmpty(url)){
if (url.startsWith("http"))
Glide.with(context).load(url).placeholder(defaultImg)
.into(imageView);
else Glide.with(context).load(AppConfig.BASE_URL_FILE+url).placeholder(defaultImg)
.into(imageView);
}else {
Glide.with(context).load(url).placeholder(defaultImg).centerCrop().into(imageView);
}
}
}