本文整理汇总了Java中com.bumptech.glide.DrawableRequestBuilder.placeholder方法的典型用法代码示例。如果您正苦于以下问题:Java DrawableRequestBuilder.placeholder方法的具体用法?Java DrawableRequestBuilder.placeholder怎么用?Java DrawableRequestBuilder.placeholder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.bumptech.glide.DrawableRequestBuilder
的用法示例。
在下文中一共展示了DrawableRequestBuilder.placeholder方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadImage
import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
/**
* Load an image from a url into an ImageView using the default placeholder
* drawable if available.
* @param url The web URL of an image.
* @param imageView The target ImageView to load the image into.
* @param requestListener A listener to monitor the request result.
* @param placeholderOverride A drawable to use as a placeholder for this specific image.
* If this parameter is present, {@link #mPlaceHolderResId}
* if ignored for this request.
*/
public void loadImage(String url, ImageView imageView, RequestListener<String> requestListener,
Drawable placeholderOverride, boolean crop) {
DrawableRequestBuilder<String> request = beginImageLoad(url, requestListener, crop)
.animate(R.anim.image_fade_in);
if (placeholderOverride != null) {
request.placeholder(placeholderOverride);
} else if (mPlaceHolderResId != -1) {
request.placeholder(mPlaceHolderResId);
}
request.into(imageView);
}
示例2: loadImage
import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
@Override
public void loadImage(Context ctx, GlideImageConfig config) {
if (ctx == null) throw new IllegalStateException("Context is required");
if (config == null) throw new IllegalStateException("GlideImageConfig is required");
if (TextUtils.isEmpty(config.getUrl())) throw new IllegalStateException("url is required");
if (config.getImageView() == null) throw new IllegalStateException("imageview is required");
RequestManager manager;
manager = Glide.with(ctx);//如果context是activity则自动使用Activity的生命周期
DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
.crossFade()
.centerCrop();
switch (config.getCacheStrategy()) {//缓存策略
case 0:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
break;
case 1:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
break;
case 2:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
break;
case 3:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
break;
}
if (config.getTransformation() != null) {//glide用它来改变图形的形状
requestBuilder.transform(config.getTransformation());
}
if (config.getPlaceholder() != 0)//设置占位符
requestBuilder.placeholder(config.getPlaceholder());
if (config.getErrorPic() != 0)//设置错误的图片
requestBuilder.error(config.getErrorPic());
requestBuilder
.into(config.getImageView());
}
示例3: loadImage
import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
@Override
public void loadImage(Context ctx, GlideImageConfig config) {
if (ctx == null) throw new IllegalStateException("Context is required");
if (config == null) throw new IllegalStateException("GlideImageConfig is required");
//这里不抛异常空的就显示默认图片
// if (TextUtils.isEmpty(config.getUrl())) throw new IllegalStateException("url is required");
if (config.getImageView() == null) throw new IllegalStateException("imageview is required");
RequestManager manager;
manager = Glide.with(ctx);//如果context是activity则自动使用Activity的生命周期
DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
.centerCrop();
if (config.fitCenter()) {
requestBuilder.fitCenter();
}
if (config.dontAnimation()) {
requestBuilder.dontAnimate();
} else {
requestBuilder.crossFade();
}
switch (config.getCacheStrategy()) {//缓存策略
case 0:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
break;
case 1:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
break;
case 2:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
break;
case 3:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
break;
}
if (config.getTransformation() != null) {//glide用它来改变图形的形状
requestBuilder.transform(config.getTransformation());
}
//设置占位符
if (config.getPlaceholder() != null) {
requestBuilder.placeholder(config.getPlaceholder());
} else if (config.getPlaceholderResId() != 0) {
requestBuilder.placeholder(config.getPlaceholderResId());
}
if (config.getErrorPic() != 0)//设置错误的图片
requestBuilder.error(config.getErrorPic());
requestBuilder.skipMemoryCache(config.skipMemoryCache());
requestBuilder.into(config.getImageView());
}
示例4: loadImage
import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
@Override
public void loadImage(Context ctx, GlideImageConfig config) {
RequestManager manager;
if (ctx instanceof Activity)//如果是activity则可以使用Activity的生命周期
manager = Glide.with((Activity) ctx);
else
manager = Glide.with(ctx);
DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
.crossFade()
.centerCrop();
switch (config.getCacheStrategy()) {//缓存策略
case 0:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
break;
case 1:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
break;
case 2:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
break;
case 3:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
break;
}
if (config.getTransformation() != null) {//glide用它来改变图形的形状
requestBuilder.transform(config.getTransformation());
}
if (config.getPlaceholder() != 0)//设置占位符
requestBuilder.placeholder(config.getPlaceholder());
if (config.getErrorPic() != 0)//设置错误的图片
requestBuilder.error(config.getErrorPic());
requestBuilder
.into(config.getImageView());
}
示例5: load
import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
@Override
public void load(Context context, GlideImageConfig config) {
this.check(context, config);
RequestManager manager = Glide.with(context);
DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
.diskCacheStrategy(DiskCacheStrategy.ALL)
.crossFade()// 默认显示淡入淡出动画
;
// 缓存策略
switch (config.getCacheStrategy()) {
case 0:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
break;
case 1:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
break;
case 2:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
break;
case 3:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
break;
}
// 改变图形的形状
if (config.getTransformation() != null) {
requestBuilder.transform(config.getTransformation());
}
// 设置占位符
if (config.getPlaceholder() != 0) {
requestBuilder.placeholder(config.getPlaceholder());
}
// 设置错误的图片
if (config.getError() != 0) {
requestBuilder.error(config.getError());
}
requestBuilder.into(config.getImageView());
}
示例6: loadImage
import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
@Override
public void loadImage(Context ctx, GlideImageConfig config) {
if (ctx == null) throw new IllegalStateException("Context is required");
if (config == null) throw new IllegalStateException("GlideImageConfig is required");
if (TextUtils.isEmpty(config.getUrl())) throw new IllegalStateException("Url is required");
if (config.getImageView() == null) throw new IllegalStateException("Imageview is required");
RequestManager manager;
manager = Glide.with(ctx);//如果context是activity则自动使用Activity的生命周期
DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
.crossFade()
.centerCrop();
switch (config.getCacheStrategy()) {//缓存策略
case 0:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
break;
case 1:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
break;
case 2:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
break;
case 3:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
break;
}
if (config.getTransformation() != null) {//glide用它来改变图形的形状
requestBuilder.transform(config.getTransformation());
}
if (config.getPlaceholder() != 0)//设置占位符
requestBuilder.placeholder(config.getPlaceholder());
if (config.getErrorPic() != 0)//设置错误的图片
requestBuilder.error(config.getErrorPic());
requestBuilder
.into(config.getImageView());
}
示例7: loadImage
import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
/**
* 根据GlideImageConfig中的配置进行加载图片
*
* @param ctx context
* @param config 图片加载
*/
@Override
public void loadImage(Context ctx, GlideImageConfig config) {
if (ctx == null) throw new IllegalStateException("Context is required");
if (config == null) throw new IllegalStateException("GlideImageConfig is required");
if (TextUtils.isEmpty(config.getUrl())) throw new IllegalStateException("url is required");
if (config.getImageView() == null) throw new IllegalStateException("imageview is required");
RequestManager manager;
manager = Glide.with(ctx);//如果context是activity则自动使用Activity的生命周期
DrawableRequestBuilder<String> requestBuilder = manager.load(config.getUrl())
.crossFade()
.centerCrop();
switch (config.getCacheStrategy()) {//缓存策略
case 0:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.ALL);
break;
case 1:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.NONE);
break;
case 2:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.SOURCE);
break;
case 3:
requestBuilder.diskCacheStrategy(DiskCacheStrategy.RESULT);
break;
}
if (config.getTransformation() != null) {//glide用它来改变图形的形状
requestBuilder.transform(config.getTransformation());
}
if (config.getPlaceholder() != 0)//设置占位符
requestBuilder.placeholder(config.getPlaceholder());
if (config.getErrorPic() != 0)//设置错误的图片
requestBuilder.error(config.getErrorPic());
requestBuilder
.into(config.getImageView());
}
示例8: build
import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
private DrawableRequestBuilder build() {
DrawableTypeRequest drawableTypeRequest;
glide.resumeRequestsRecursive();
if (!TextUtils.isEmpty(url)) {
drawableTypeRequest = glide.load(url);
} else if (resourceId != 0) {
drawableTypeRequest = glide.load(resourceId);
} else {
return null;
}
GifTypeRequest gifTypeRequest = drawableTypeRequest.asGif();
mGifRequest = gifTypeRequest.clone();
DrawableRequestBuilder drawableRequestBuilder = drawableTypeRequest.clone();
if (placeholder != null) {
drawableRequestBuilder = drawableRequestBuilder.placeholder(placeholder);
}
if (error != null) {
drawableRequestBuilder = drawableRequestBuilder.error(error);
}
if (width > 0 && height > 0) {
drawableRequestBuilder = drawableRequestBuilder.override(width, height);
}
if (bitmapTransformation != null) {
Transformation[] bitmapTransformationsAux = new Transformation[bitmapTransformation.size()];
for (int i = 0; i < bitmapTransformation.size(); i++) {
bitmapTransformationsAux[i] = bitmapTransformation.get(i);
}
drawableRequestBuilder = drawableRequestBuilder.bitmapTransform(bitmapTransformationsAux);
}
if (centerCrop) {
drawableRequestBuilder = drawableRequestBuilder.centerCrop();
}
if (fitCenter) {
drawableRequestBuilder = drawableRequestBuilder.fitCenter();
}
if (animate) {
drawableRequestBuilder = drawableRequestBuilder.animate(android.R.anim.slide_in_left);
}
if (sizeMultiplier > 0) {
drawableRequestBuilder = drawableRequestBuilder.sizeMultiplier(sizeMultiplier);
}
return drawableRequestBuilder;
}
开发者ID:Gigigo-Android-Devs,项目名称:gigigo-imageLoader-library-android,代码行数:52,代码来源:ImageLoaderBuilderImp.java