/**
* @param url 通过URL得到 Drawable
* @return
*/
public static void getDrawableGlide(String url, CustomTarget<Drawable> customTarget) {
Glide.with(mContext).load(url).into(customTarget);
}
/**
* @param url 通过URL得到 Bitmap
* @return
*/
public static void getBitmapGlide(String url, CustomTarget<Bitmap> customTarget) {
Glide.with(mContext).asBitmap().load(url).into(customTarget);
}
/**
* 这是一个耗时的操作需要异步处理
*
* @param url 通过URL得到 Drawable
* @return
*/
public static Drawable getDrawableGlide(String url) {
try {
return Glide.with(mContext)
.load(url)
.submit()
.get();
} catch (ExecutionException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
return null;
}
/**
* 这是一个耗时的操作需要异步处理
*
* @param url 通过URL得到 Bitmap
* @return
*/
public static Bitmap getBitmapGlide(String url) {
try {
return Glide.with(mContext)
.asBitmap()
.load(url)
.submit()
.get();
} catch (ExecutionException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
return null;
}
使用Glide得到 Bitmap、Drawable
最新推荐文章于 2025-02-06 15:25:15 发布