@Test @SuppressWarnings({"unchecked", "varargs"}) public void testApplyMultiTransform() { options.transforms(new CircleCrop(), new CenterCrop()); assertThat(options.isTransformationRequired()).isTrue(); assertThat(options.getTransformations()).containsKey(Bitmap.class); assertThat(options.getTransformations().get(Bitmap.class)) .isInstanceOf(MultiTransformation.class); }
@Override public void bindView(@NonNull final ForkModel model, @NonNull final ForkViewHolder holder) { holder.name.setText(model.getName()); final RequestOptions options = new RequestOptions(); options.transform(new MultiTransformation(new BlurTransformation(25), new CircleCrop())); Glide.with(getContext()) .asBitmap() .load(model.getAvatarUrl()) .apply(options) .into(holder.avatar); holder.itemView.setOnClickListener(view -> mListener.onForkItemClicked(model)); }
@Override public void bindView(@NonNull final StargazerModel model, @NonNull final UserViewHolder holder) { holder.name.setText(model.getName()); final RequestOptions options = new RequestOptions(); options.transform(new MultiTransformation(new BlurTransformation(25), new CircleCrop())); Glide.with(getContext()) .asBitmap() .load(model.getAvatarUrl()) .apply(options) .into(holder.avatar); }
/** * 加载圆形图片 * * @param obj * @param iv * @param placeholderResource 占位图 */ public static void loadCircleImg(Object obj, ImageView iv, int placeholderResource) { Glide.with(iv.getContext()).load(obj).apply(getRequestOptions() .error(placeholderResource) .placeholder(placeholderResource) .fallback(placeholderResource) .dontAnimate() .transform(new CircleCrop())).into(iv); }
/** * 加载圆形图片 * * @param obj * @param iv * @param placeholder 占位图 */ public static void loadCircleImg(Object obj, ImageView iv, Drawable placeholder) { Glide.with(iv.getContext()).load(obj).apply(getRequestOptions() .error(placeholder) .placeholder(placeholder) .fallback(placeholder) .dontAnimate() .transform(new CircleCrop())).into(iv); }
private void initUpperInfo(Summary.DataBean data) { Summary.DataBean.OwnerBean owner = data.getOwner(); if (owner != null) { ArmsUtils.obtainAppComponentFromContext(_mActivity).imageLoader().loadImage(_mActivity, ImageConfigImpl.builder().url(owner.getFace()).imageView(mIvHeader).transformation(new CircleCrop()).build()); mTvUpperName.setText(owner.getName()); } Summary.DataBean.OwnerExtBean owner_ext = data.getOwner_ext(); if (owner_ext != null) { mTvFans.setText(TextHandleUtil.handleCount2TenThousand(owner_ext.getFans()) + "人关注"); } // 得到视频相关tag tags = data.getTag(); if (tags != null) { // 如果tag数量超过4个,就缩减 if (tags.size() > 4) { newTags = new ArrayList<>(); Collections.sort(tags); for (int i = 0; i < 4; i++) { newTags.add(tags.get(i)); } adapter = new MyTagAdapter(newTags); isTagShrink = true; } else { adapter = new MyTagAdapter(tags); } mTagFlow.setAdapter(adapter); // 箭头的点击事件 changeArrowDown(); mIvTagShrink.setOnClickListener(v -> { if (isTagShrink) { // 切换成多的 if (newTags != null) { adapter = new MyTagAdapter(tags); } changeArrowUp(); } else { // 切换成少的 if (newTags != null) { adapter = new MyTagAdapter(newTags); } changeArrowDown(); } isTagShrink = !isTagShrink; if (newTags != null) { mTagFlow.setAdapter(adapter); } }); } }
/** * Applies {@link CircleCrop} to all default types, and ignores unknown types. * * <p>This will override previous calls to {@link #dontTransform()}. * * @see #optionalTransform(Transformation) * @see #circleCrop() */ public RequestOptions optionalCircleCrop() { return optionalTransform(DownsampleStrategy.CENTER_OUTSIDE, new CircleCrop()); }
/** * Applies {@link CircleCrop} to all default types and throws an exception if asked to transform * an unknown type. * * <p>This will override previous calls to {@link #dontTransform()}. * * @see #transform(Class, Transformation) * @see #optionalCenterCrop() */ public RequestOptions circleCrop() { return transform(DownsampleStrategy.CENTER_INSIDE, new CircleCrop()); }
/** * Applies {@link CircleCrop} to all default types, and ignores unknown types. * * <p>This will override previous calls to {@link #dontTransform()}. * * @see #optionalTransform(Transformation) * @see #circleCrop() */ @CheckResult public RequestOptions optionalCircleCrop() { return optionalTransform(DownsampleStrategy.CENTER_OUTSIDE, new CircleCrop()); }
/** * Applies {@link CircleCrop} to all default types and throws an exception if asked to transform * an unknown type. * * <p>This will override previous calls to {@link #dontTransform()}. * * @see #transform(Class, Transformation) * @see #optionalCenterCrop() */ @CheckResult public RequestOptions circleCrop() { return transform(DownsampleStrategy.CENTER_INSIDE, new CircleCrop()); }