本文整理汇总了Java中com.bumptech.glide.DrawableTypeRequest类的典型用法代码示例。如果您正苦于以下问题:Java DrawableTypeRequest类的具体用法?Java DrawableTypeRequest怎么用?Java DrawableTypeRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DrawableTypeRequest类属于com.bumptech.glide包,在下文中一共展示了DrawableTypeRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDrawableRequestBuilder
import com.bumptech.glide.DrawableTypeRequest; //导入依赖的package包/类
/**
* DrawableRequestBuilder 的通行配置
* @param ctx 上下文
* @param img ImageLoader封装器
* @param typeRequest url or resource
* @param <T> String or Integer
* @return DrawableRequestBuilder<T>
*/
private <T> DrawableRequestBuilder<T> getDrawableRequestBuilder(Context ctx, ImageLoader img, DrawableTypeRequest<T> typeRequest) {
DrawableRequestBuilder<T> builder = typeRequest
.placeholder(img.placeHolder)
.error(img.errorHolder)
.diskCacheStrategy(DiskCacheStrategy.ALL);
// transform image type
int transType = img.transType;
if (transType == LoaderConfig.TRANS_CIRCLE) {
builder = builder.transform(new GlideCircleTransform(ctx));
} else if (transType == LoaderConfig.TRANS_ROUND) {
builder = builder.transform(new GlideRoundTransform(ctx));
}
// SCALE type
if (img.scaleType == LoaderConfig.SCALE_CENTER_CROP) {
builder = builder.centerCrop();
} else if (img.scaleType == LoaderConfig.SCALE_FIT_CENTER) {
builder = builder.fitCenter();
}
return builder;
}
示例2: display
import com.bumptech.glide.DrawableTypeRequest; //导入依赖的package包/类
/**
* 显示图片
* @param context 上下文
* @param imageView 图片view
* @param uri 图片路径
* @param bitmapTransformation bitmap转换器
*/
private static void display(Context context, final ImageView imageView, String uri, BitmapTransformation bitmapTransformation, boolean isAvatar){
DrawableTypeRequest<String> drawableTypeRequest = Glide.with(context).load(uri);
drawableTypeRequest
.centerCrop()
.placeholder(ERROR_IMAGE)
.error(isAvatar ? AVATAR_IMAGE : ERROR_IMAGE)
.diskCacheStrategy(DiskCacheStrategy.ALL)
.dontAnimate();
// 添加转换器
if(null != bitmapTransformation){
drawableTypeRequest.bitmapTransform(bitmapTransformation);
}
// 设置图片
drawableTypeRequest.into(imageView);
}
示例3: onLoad
import com.bumptech.glide.DrawableTypeRequest; //导入依赖的package包/类
/**
*/
@Nullable
@Override
protected Bitmap onLoad(@NonNull RequestManager loader) {
ensureHasTargetOrThrow();
final DrawableTypeRequest<String> request = onPrepareRequest(loader);
try {
return request.asBitmap().into(-1, -1).get();
} catch (InterruptedException | ExecutionException e) {
throw new ImageLoader.Error(
ImageLoader.Error.REASON_UNKNOWN,
"Failed to load image.",
e
);
}
}
示例4: load
import com.bumptech.glide.DrawableTypeRequest; //导入依赖的package包/类
/**
* 图片加载
* @author leibing
* @createTime 2016/8/15
* @lastModify 2016/8/15
* @param context 上下文
* @param imageView 图片显示控件
* @param localPath 图片本地链接
* @param defaultImage 默认占位图片
* @param errorImage 加载失败后图片
* @return
*/
public void load(Context context, ImageView imageView, File localPath, Drawable defaultImage, Drawable errorImage){
// 图片加载库采用Glide框架
DrawableTypeRequest request = Glide.with(context).load(localPath);
request.thumbnail(0.1f) //用原图的1/10作为缩略图
.placeholder(defaultImage) //设置资源加载过程中的占位Drawable
.crossFade() //设置加载渐变动画
.priority(Priority.NORMAL) //指定加载的优先级,优先级越高越优先加载,
// 但不保证所有图片都按序加载
// 枚举Priority.IMMEDIATE,Priority.HIGH,Priority.NORMAL,Priority.LOW
// 默认为Priority.NORMAL
.fallback(null) //设置model为空时要显示的Drawable
// 如果没设置fallback,model为空时将显示error的Drawable,
// 如果error的Drawable也没设置,就显示placeholder的Drawable
.error(errorImage) //设置load失败时显示的Drawable
.skipMemoryCache(true) //设置跳过内存缓存,但不保证一定不被缓存
// (比如请求已经在加载资源且没设置跳过内存缓存,这个资源就会被缓存在内存中)
.diskCacheStrategy(DiskCacheStrategy.RESULT) //缓存策略DiskCacheStrategy.SOURCE:
// 缓存原始数据,DiskCacheStrategy.RESULT:
// 缓存变换(如缩放、裁剪等)后的资源数据,
// DiskCacheStrategy.NONE:什么都不缓存,
// DiskCacheStrategy.ALL:缓存SOURC和RESULT。
// 默认采用DiskCacheStrategy.RESULT策略,
// 对于download only操作要使用DiskCacheStrategy.SOURCE
.into(imageView);
}
示例5: loadNet
import com.bumptech.glide.DrawableTypeRequest; //导入依赖的package包/类
@Override
public void loadNet(Context context, String url, Options options, final LoadCallback callback) {
DrawableTypeRequest request = getRequestManager(context).load(url);
if (options == null) options = Options.defaultOptions();
if (options.loadingResId != Options.RES_NONE) {
request.placeholder(options.loadingResId);
}
if (options.loadErrorResId != Options.RES_NONE) {
request.error(options.loadErrorResId);
}
wrapScaleType(request, options)
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.crossFade()
.into(new SimpleTarget<GlideBitmapDrawable>() {
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
super.onLoadFailed(e, errorDrawable);
if (callback != null) {
callback.onLoadFailed(e);
}
}
@Override
public void onResourceReady(GlideBitmapDrawable resource, GlideAnimation<? super GlideBitmapDrawable> glideAnimation) {
if (resource != null && resource.getBitmap() != null) {
if (callback != null) {
callback.onLoadReady(resource.getBitmap());
}
}
}
});
}
示例6: load
import com.bumptech.glide.DrawableTypeRequest; //导入依赖的package包/类
private void load(DrawableTypeRequest request, ImageView target, Options options) {
if (options == null) options = Options.defaultOptions();
if (options.loadingResId != Options.RES_NONE) {
request.placeholder(options.loadingResId);
}
if (options.loadErrorResId != Options.RES_NONE) {
request.error(options.loadErrorResId);
}
wrapScaleType(request, options)
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.crossFade()
.into(target);
}
示例7: wrapScaleType
import com.bumptech.glide.DrawableTypeRequest; //导入依赖的package包/类
private DrawableTypeRequest wrapScaleType(DrawableTypeRequest request, Options options) {
if (options != null
&& options.scaleType != null) {
switch (options.scaleType) {
case MATRIX:
break;
case FIT_XY:
break;
case FIT_START:
break;
case FIT_END:
break;
case CENTER:
break;
case CENTER_INSIDE:
break;
case FIT_CENTER:
request.fitCenter();
break;
case CENTER_CROP:
request.centerCrop();
break;
}
}
return request;
}
示例8: loadNet
import com.bumptech.glide.DrawableTypeRequest; //导入依赖的package包/类
@Override
public void loadNet(Context context, String url, Options options, final LoadCallback callback) {
DrawableTypeRequest request = getRequestManager(context).load(url);
if (options == null) options = Options.defaultOptions();
if (options.loadingResId != Options.RES_NONE) {
request.placeholder(options.loadingResId);
}
if (options.loadErrorResId != Options.RES_NONE) {
request.error(options.loadErrorResId);
}
request.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.crossFade()
.into(new SimpleTarget<GlideBitmapDrawable>() {
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
super.onLoadFailed(e, errorDrawable);
if (callback != null) {
callback.onLoadFailed(e);
}
}
@Override
public void onResourceReady(GlideBitmapDrawable resource, GlideAnimation<? super GlideBitmapDrawable> glideAnimation) {
if (resource != null && resource.getBitmap() != null) {
if (callback != null) {
callback.onLoadReady(resource.getBitmap());
}
}
}
});
}
示例9: load
import com.bumptech.glide.DrawableTypeRequest; //导入依赖的package包/类
private void load(DrawableTypeRequest request, ImageView target, Options options) {
if (options == null) options = Options.defaultOptions();
if (options.loadingResId != Options.RES_NONE) {
request.placeholder(options.loadingResId);
}
if (options.loadErrorResId != Options.RES_NONE) {
request.error(options.loadErrorResId);
}
request.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.crossFade()
.into(target);
}
示例10: createBaseRequest
import com.bumptech.glide.DrawableTypeRequest; //导入依赖的package包/类
public static DrawableTypeRequest createBaseRequest(RequestManager requestManager, Song song, boolean ignoreMediaStore) {
if (ignoreMediaStore) {
return requestManager.load(new AudioFileCover(song.data));
} else {
return requestManager.loadFromMediaStore(MusicUtil.getMediaStoreAlbumCoverUri(song.albumId));
}
}
示例11: load
import com.bumptech.glide.DrawableTypeRequest; //导入依赖的package包/类
private void load(DrawableTypeRequest request, ImageView target, Options options) {
if (options == null) options = Options.defaultOptions();
if (options.loadingResId != Options.RES_NONE) {
request.placeholder(options.loadingResId);
}
if (options.loadErrorResId != Options.RES_NONE) {
request.error(options.loadErrorResId);
}
request.crossFade().into(target);
}
示例12: load
import com.bumptech.glide.DrawableTypeRequest; //导入依赖的package包/类
/**
* 图片加载
* @author leibing
* @createTime 2016/8/15
* @lastModify 2016/8/15
* @param context 上下文
* @param imageView 图片显示控件
* @param localPath 图片本地链接
* @param defaultImage 默认占位图片
* @param errorImage 加载失败后图片
* @param isCropCircle 是否圆角
* @return
*/
public void load(Context context, ImageView imageView, File localPath, Drawable defaultImage, Drawable errorImage , boolean isCropCircle){
// 图片加载库采用Glide框架
DrawableTypeRequest request = Glide.with(context).load(localPath);
// 设置scaleType
request.centerCrop();
// 圆角裁切
if (isCropCircle)
request.bitmapTransform(new CropCircleTransformation(context));
request.thumbnail(0.1f) //用原图的1/10作为缩略图
.placeholder(defaultImage) //设置资源加载过程中的占位Drawable
.crossFade() //设置加载渐变动画
.priority(Priority.NORMAL) //指定加载的优先级,优先级越高越优先加载,
// 但不保证所有图片都按序加载
// 枚举Priority.IMMEDIATE,Priority.HIGH,Priority.NORMAL,Priority.LOW
// 默认为Priority.NORMAL
.fallback(null) //设置model为空时要显示的Drawable
// 如果没设置fallback,model为空时将显示error的Drawable,
// 如果error的Drawable也没设置,就显示placeholder的Drawable
.error(errorImage) //设置load失败时显示的Drawable
.skipMemoryCache(true) //设置跳过内存缓存,但不保证一定不被缓存
// (比如请求已经在加载资源且没设置跳过内存缓存,这个资源就会被缓存在内存中)
.diskCacheStrategy(DiskCacheStrategy.RESULT) //缓存策略DiskCacheStrategy.SOURCE:
// 缓存原始数据,DiskCacheStrategy.RESULT:
// 缓存变换(如缩放、裁剪等)后的资源数据,
// DiskCacheStrategy.NONE:什么都不缓存,
// DiskCacheStrategy.ALL:缓存SOURC和RESULT。
// 默认采用DiskCacheStrategy.RESULT策略,
// 对于download only操作要使用DiskCacheStrategy.SOURCE
.into(imageView);
}
示例13: preload
import com.bumptech.glide.DrawableTypeRequest; //导入依赖的package包/类
@Override
public void preload(final FileItem item) {
final DrawableTypeRequest<String> glideLoad = Glide
.with(context)
.load(item.getPath());
if (PLAY_GIF) {
// Play GIFs
glideLoad.preload();
} else {
// Force bitmap so GIFs don't play
glideLoad.asBitmap().preload();
}
}
示例14: createBaseRequest
import com.bumptech.glide.DrawableTypeRequest; //导入依赖的package包/类
static DrawableTypeRequest createBaseRequest(RequestManager requestManager, Song song, boolean ignoreMediaStore) {
if (ignoreMediaStore) {
return requestManager.load(new AudioFileCover(song.data));
} else {
return requestManager.loadFromMediaStore(MusicUtil.getMediaStoreAlbumCoverUri(song.albumId));
}
}
示例15: createBaseRequest
import com.bumptech.glide.DrawableTypeRequest; //导入依赖的package包/类
static DrawableTypeRequest createBaseRequest(RequestManager requestManager, Artist artist, boolean noCustomImage, boolean forceDownload) {
boolean hasCustomImage = CustomArtistImageUtil.getInstance(RetroApplication.getInstance()).hasCustomArtistImage(artist);
if (noCustomImage || !hasCustomImage) {
return requestManager.load(new ArtistImage(artist.getName(), forceDownload));
} else {
return requestManager.load(CustomArtistImageUtil.getFile(artist));
}
}