本文整理汇总了Java中com.bumptech.glide.DrawableRequestBuilder.fitCenter方法的典型用法代码示例。如果您正苦于以下问题:Java DrawableRequestBuilder.fitCenter方法的具体用法?Java DrawableRequestBuilder.fitCenter怎么用?Java DrawableRequestBuilder.fitCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.bumptech.glide.DrawableRequestBuilder
的用法示例。
在下文中一共展示了DrawableRequestBuilder.fitCenter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDrawableRequestBuilder
import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的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: 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());
}
示例3: 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