本文整理汇总了Java中com.bumptech.glide.DrawableRequestBuilder.into方法的典型用法代码示例。如果您正苦于以下问题:Java DrawableRequestBuilder.into方法的具体用法?Java DrawableRequestBuilder.into怎么用?Java DrawableRequestBuilder.into使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.bumptech.glide.DrawableRequestBuilder
的用法示例。
在下文中一共展示了DrawableRequestBuilder.into方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setImage
import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
@BindingAdapter(value = {"imageUrl", "defaultImg", "radius"}, requireAll = false)
public static void setImage(ImageView imageView, String imageUrl, Drawable defaultImg, int radius) {
DrawableRequestBuilder drawableTypeRequest = Glide.with(imageView.getContext()).load(imageUrl).crossFade();
if (defaultImg != null) {
drawableTypeRequest.placeholder(defaultImg).error(defaultImg);
} else {
drawableTypeRequest.placeholder(R.drawable.bg_defautl_imageview).error(R.drawable.bg_defautl_imageview);
}
if (radius > 0) {
drawableTypeRequest.bitmapTransform(new CenterCrop(imageView.getContext()),
new RoundedCornersTransformation(imageView.getContext(), PixelUtil.dp2px(radius), 0));
} else {
drawableTypeRequest.bitmapTransform(new CenterCrop(imageView.getContext()));
}
drawableTypeRequest.into(imageView);
}
示例2: loadingImageWithRoundTransform
import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
/**
* Using Glide to load image with round transform
*
* @param context {@link Context}
* @param imageView {@link ImageView}
* @param imagePath {@link String}
* @param isRoundTransform {@link Boolean}
*/
public static void loadingImageWithRoundTransform(final Context context,
final ImageView imageView,
final String imagePath,
final boolean isRoundTransform) {
DrawableRequestBuilder<String> request = Glide.with(context)
.load(imagePath)
.placeholder(R.drawable.image_placeholder);
if (isRoundTransform) {
RoundedCornersTransformation transformation = new RoundedCornersTransformation(context,
50, 0, RoundedCornersTransformation.CornerType.ALL);
request.bitmapTransform(transformation);
}
request.into(imageView);
}
示例3: onBindViewHolder
import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
GankBean gankBean = mData.get(position);
holder.tvHomeGankTitle.setText(gankBean.desc);
holder.tvHomeGankAuthor.setText(gankBean.who);
holder.tvHomeGankDate.setText(DateUtils.formatDateDetailDay(DateUtils.parseStringToDate(gankBean.publishedAt)));
if (gankBean.images != null && !gankBean.images.isEmpty()) {
holder.ivHomeGankImg.setVisibility(View.VISIBLE);
DrawableRequestBuilder<String> requestBuilder = Glide.with(mContext)
.load(gankBean.images.get(0)+"?imageView2/0/w/400")
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.error(R.color.accent)
.crossFade();
requestBuilder.into(holder.ivHomeGankImg);
}else {
holder.ivHomeGankImg.setVisibility(View.GONE);
}
}
示例4: loadAvatar
import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
public static void loadAvatar(Context context, ImageView view,
@Nullable User user, @NotNull String url, int index,
@Nullable OnLoadImageListener<User> l) {
DrawableRequestBuilder<Integer> thumbnailRequest = Glide.with(context)
.load(R.drawable.default_avatar)
.override(128, 128)
.transform(new CircleTransformation(context))
.diskCacheStrategy(DiskCacheStrategy.SOURCE);
DrawableRequestBuilder<String> request = Glide.with(context)
.load(url)
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.override(128, 128)
.transform(new CircleTransformation(context))
.thumbnail(thumbnailRequest);
if (l != null) {
request.listener(new UserSaturationListener(context, view, user, index, l));
}
request.into(view);
}
示例5: loadAdapterRadius
import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
/**
* 下载图片转换圆角
* @param context
* @param imageRes
* @param view
* @param radius 圆角度
*/
public static void loadAdapterRadius(Context context, String imageRes, ImageView view,int radius){
DrawableRequestBuilder requestBuilder = Glide.with(context)
.load(imageRes)
.centerCrop()
.crossFade()
.transform(new GlideRoundTransform(context, radius))
.diskCacheStrategy(DiskCacheStrategy.ALL);
requestBuilder.into(view);
}
示例6: loadRegularPhoto
import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
private static DrawableRequestBuilder<String> loadRegularPhoto(Context context, ImageView view,
Photo photo, int index,
boolean saturation, boolean execute,
@Nullable OnLoadImageListener<Photo> l) {
if (photo != null && photo.urls != null
&& photo.width != 0 && photo.height != 0) {
DrawableRequestBuilder<String> thumbnailRequest = Glide
.with(context)
.load(photo.urls.thumb)
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.listener(new SetEnableListener(view));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
&& !photo.hasFadedIn && saturation) {
AnimUtils.ObservableColorMatrix matrix = new AnimUtils.ObservableColorMatrix();
matrix.setSaturation(0);
view.setColorFilter(new ColorMatrixColorFilter(matrix));
}
view.setEnabled(false);
DrawableRequestBuilder<String> regularRequest = Glide
.with(context)
.load(photo.getRegularSizeUrl(context))
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.override(photo.getRegularWidth(), photo.getRegularHeight())
.thumbnail(thumbnailRequest)
.animate(new FadeAnimator());
if (l != null && saturation) {
regularRequest.listener(new PhotoSaturationListener(context, view, photo, index, l));
} else if (l != null) {
regularRequest.listener(new BaseRequestListener<Photo, String, GlideDrawable>(photo, 0, l));
}
if (execute) {
regularRequest.into(view);
}
return regularRequest;
}
return null;
}
示例7: loadResourceImage
import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
public static void loadResourceImage(Context context, ImageView view, int resId,
@Nullable BitmapTransformation transformation) {
DrawableRequestBuilder<Integer> request = Glide
.with(context)
.load(resId)
.dontAnimate()
.diskCacheStrategy(DiskCacheStrategy.SOURCE);
if (transformation != null) {
request.transform(transformation);
}
request.into(view);
}
示例8: loadImageFromUrl
import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
public static void loadImageFromUrl(Context context, ImageView view, String url, boolean lowPriority,
@Nullable OnLoadImageListener<String> l) {
DrawableRequestBuilder<String> request = Glide
.with(context)
.load(url)
.diskCacheStrategy(DiskCacheStrategy.SOURCE);
if (lowPriority) {
request.priority(Priority.LOW);
}
if (l != null) {
request.listener(new BaseRequestListener<String, String, GlideDrawable>(url, 0, l));
}
request.into(view);
}
示例9: bindLibrary
import com.bumptech.glide.DrawableRequestBuilder; //导入方法依赖的package包/类
private void bindLibrary(final LibraryHolder holder, final Library lib) {
holder.name.setText(lib.name);
holder.description.setText(lib.description);
DrawableRequestBuilder<String> request = Glide.with(holder.image.getContext())
.load(lib.imageUrl)
.placeholder(R.drawable.avatar_placeholder);
if (lib.circleCrop) {
request.transform(circleCrop);
}
request.into(holder.image);
}
示例10: 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);
}
示例11: 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());
}
示例12: 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());
}
示例13: 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());
}
示例14: 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());
}
示例15: 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());
}