com.bumptech.glide.load.resource.bitmap.BitmapTransformation Java Examples

The following examples show how to use com.bumptech.glide.load.resource.bitmap.BitmapTransformation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ThumbnailView.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
private GlideRequest applySizing(@NonNull GlideRequest request, @NonNull BitmapTransformation fitting) {
  int[] size = new int[2];
  fillTargetDimensions(size, dimens, bounds);
  if (size[WIDTH] == 0 && size[HEIGHT] == 0) {
    size[WIDTH]  = getDefaultWidth();
    size[HEIGHT] = getDefaultHeight();
  }

  request = request.override(size[WIDTH], size[HEIGHT]);
  
  if (radius > 0) {
    return request.transforms(fitting, new RoundedCorners(radius));
  } else {
    return request.transforms(fitting);
  }
}
 
Example #2
Source File: ImageHelper.java    From Mysplash with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void loadImage(Context context, ImageView view,
                             @NonNull String url, @Nullable String thumbUrl,
                             @Size(2) @Px int[] size, @Nullable @Size(2) @Px int[] thumbSize,
                             @Nullable BitmapTransformation[] ts, @Nullable OnLoadImageListener l) {
    if (thumbSize == null) {
        thumbSize = new int[] {Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL};
    }
    DrawableRequestBuilder<String> thumb = TextUtils.isEmpty(thumbUrl) ? null : Glide.with(getValidContext(context))
            .load(ensureUrl(thumbUrl))
            .override(thumbSize[0], thumbSize[1])
            .diskCacheStrategy(
                    thumbSize[0] == Target.SIZE_ORIGINAL
                            ? DiskCacheStrategy.NONE
                            : DiskCacheStrategy.SOURCE
            ).listener(
                    new BaseRequestListener<>(() -> view.setTag(R.id.tag_item_image_fade_in_flag, false))
            );
    loadImage(context, view, url, thumb, size, ts, l);
}
 
Example #3
Source File: AFGlideUtil.java    From AFBaseLibrary with Apache License 2.0 6 votes vote down vote up
/**
 * 加载圆角图片
 *
 * @param obj 要加载的资源
 * @param img 被加载的图片
 * @param dp  圆角大小
 */
public static void loadRoundImg(Object obj, ImageView img, int dp) {
    DrawableTypeRequest drawableTypeRequest = getDrawableTypeRequest(obj, img);
    if (drawableTypeRequest == null) {
        drawableTypeRequest = getDrawableTypeRequest(sRoundPlaceholder, img);
    }
    if (drawableTypeRequest != null) {
        drawableTypeRequest
                .centerCrop()
                .dontAnimate()
                .transform(new BitmapTransformation[]{new AFGlideUtil.GlideRoundTransform(img.getContext(), dp)})
                .error(sRoundPlaceholder)
                .placeholder(sRoundPlaceholder).
                diskCacheStrategy(DiskCacheStrategy.RESULT).into(img);
    }
}
 
Example #4
Source File: GlideImageLoader.java    From XFrame with Apache License 2.0 5 votes vote down vote up
@Override
public void load(ImageView imageView, Object imageUrl, Object transformation) {
    Glide.with(mContext)
            .load(imageUrl)
            .crossFade()
            .transform((BitmapTransformation) transformation)
            .into(imageView);
}
 
Example #5
Source File: LoadImagePresenter.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void loadUserAvatar(Context context, ImageView view, @Nullable User user,
                                  @Nullable ImageHelper.OnLoadImageListener l) {
    if (user == null || user.profile_image == null) {
        ImageHelper.loadImage(context, view, R.drawable.default_avatar,
                new int[] {ImageHelper.AVATAR_SIZE, ImageHelper.AVATAR_SIZE},
                new BitmapTransformation[] {new CircleTransformation(context)}, l);
    } else {
        ImageHelper.loadImage(context, view, user.profile_image.large, R.drawable.default_avatar_round,
                new int[] {ImageHelper.AVATAR_SIZE, ImageHelper.AVATAR_SIZE},
                new BitmapTransformation[] {new CircleTransformation(context)}, l);
    }
}
 
Example #6
Source File: UserHolder.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SuppressLint("SetTextI18n")
void onBindView(UserModel model, @Nullable UserAdapter.ItemEventCallback callback) {
    Context context = itemView.getContext();

    this.user = model.user;
    this.callback = callback;

    title.setText(model.title);
    subtitle.setText(model.subtitle);

    if (TextUtils.isEmpty(model.portfolioUrl)) {
        portfolioBtn.setVisibility(View.GONE);
    } else {
        portfolioBtn.setVisibility(View.VISIBLE);
    }

    if (TextUtils.isEmpty(model.avatarUrl)) {
        ImageHelper.loadImage(context, avatar, R.drawable.default_avatar,
                model.avatarSize, new BitmapTransformation[]{new CircleTransformation(context)}, null);
    } else {
        ImageHelper.setImageViewSaturation(avatar, model.hasFadeIn ? 1 : 0);
        ImageHelper.loadImage(context, avatar, model.avatarUrl, R.drawable.default_avatar_round,
                model.avatarSize, new BitmapTransformation[]{new CircleTransformation(context)}, () -> {
            if (!model.hasFadeIn) {
                model.hasFadeIn = true;
                long duration = Long.parseLong(
                        ComponentFactory.getSettingsService().getSaturationAnimationDuration());
                ImageHelper.startSaturationAnimation(context, avatar, duration);
            }
        });
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        avatar.setTransitionName(user.username + "-avatar");
        background.setTransitionName(user.username + "-background");
    }
}
 
Example #7
Source File: TitleFeedHolder.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onBindView(FollowingModel model, boolean update) {
    StaggeredGridLayoutManager.LayoutParams params
            = (StaggeredGridLayoutManager.LayoutParams) background.getLayoutParams();
    params.setFullSpan(true);
    background.setLayoutParams(params);

    Context context = itemView.getContext();

    user = ((TitleFeedModel) model).user;
    if (user == null) {
        return;
    }

    avatarVisibility = false;
    setAvatarVisibility(true);

    if (TextUtils.isEmpty(((TitleFeedModel) model).avatarUrl)) {
        ImageHelper.loadImage(context, avatar, R.drawable.default_avatar,
                ((TitleFeedModel) model).avatarSize, new BitmapTransformation[]{new CircleTransformation(context)}, null);
    } else {
        ImageHelper.loadImage(context, avatar, ((TitleFeedModel) model).avatarUrl, R.drawable.default_avatar_round,
                ((TitleFeedModel) model).avatarSize, new BitmapTransformation[]{new CircleTransformation(context)}, null);
    }

    actor.setText(((TitleFeedModel) model).title);

    if (!TextUtils.isEmpty(((TitleFeedModel) model).subtitle)) {
        verb.setVisibility(View.VISIBLE);
        verb.setText(((TitleFeedModel) model).subtitle);
    } else {
        verb.setVisibility(View.GONE);
    }
}
 
Example #8
Source File: ImageHelper.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void loadImage(Context context, ImageView view,
                             @NonNull String url, @DrawableRes int thumbResId, @Size(2) @Px int[] size,
                             @Nullable BitmapTransformation[] ts, @Nullable OnLoadImageListener l) {
    DrawableRequestBuilder<Integer> thumb = thumbResId == 0 ? null : Glide.with(getValidContext(context))
            .load(thumbResId)
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .listener(new BaseRequestListener<>(() -> view.setTag(R.id.tag_item_image_fade_in_flag, false)));
    loadImage(context, view, url, thumb, size, ts, l);
}
 
Example #9
Source File: ImageHelper.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void loadImage(Context context, ImageView view,
                              @NonNull String url, @Nullable DrawableRequestBuilder thumbnailRequest,
                              @Size(2) @Px int[] size,
                              @Nullable BitmapTransformation[] ts, @Nullable OnLoadImageListener l) {
    view.setTag(R.id.tag_item_image_fade_in_flag, true);

    if (ts == null) {
        ts = new BitmapTransformation[] {new NullTransformation(context)};
    }

    Glide.with(getValidContext(context))
            .load(ensureUrl(url))
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .override(size[0], size[1])
            .thumbnail(thumbnailRequest)
            .animate(v -> {
                Boolean fadeInFlag = (Boolean) v.getTag(R.id.tag_item_image_fade_in_flag);
                if (fadeInFlag == null || fadeInFlag) {
                    v.setTag(R.id.tag_item_image_fade_in_flag, false);
                    ObjectAnimator animator = ObjectAnimator.ofFloat(v, "alpha", 0f, 1f);
                    animator.setDuration(300);
                    animator.setInterpolator(new AccelerateDecelerateInterpolator());
                    animator.start();
                }
            }).transform(ts)
            .listener(new BaseRequestListener<>(l))
            .into(view);
}
 
Example #10
Source File: ImageHelper.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void loadImage(Context context, ImageView view,
                             @DrawableRes int resId, @Size(2) @Px int[] size,
                             @Nullable BitmapTransformation[] ts, @Nullable OnLoadImageListener l) {
    if (ts == null) {
        ts = new BitmapTransformation[] {new NullTransformation(context)};
    }

    Glide.with(getValidContext(context))
            .load(resId)
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .override(size[0], size[1])
            .transform(ts)
            .listener(new BaseRequestListener<>(l))
            .into(view);
}
 
Example #11
Source File: GlideUtil.java    From Android with MIT License 5 votes vote down vote up
public static void loadImage(ImageView imageView, Object path,BitmapTransformation... transformations){
    Glide.with(BaseApplication.getInstance())
            .load(path)
            .transform(transformations)
            //.placeholder(R.mipmap.img_default)
            .error(R.mipmap.img_default)
            //.thumbnail(0.2f)
            .into(imageView);
}
 
Example #12
Source File: ThumbnailView.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
private GlideRequest applySizing(@NonNull GlideRequest request, @NonNull BitmapTransformation fitting) {
  int[] size = new int[2];
  fillTargetDimensions(size, dimens, bounds);
  if (size[WIDTH] == 0 && size[HEIGHT] == 0) {
    size[WIDTH]  = getDefaultWidth();
    size[HEIGHT] = getDefaultHeight();
  }
  return request.override(size[WIDTH], size[HEIGHT])
                .transforms(fitting, new RoundedCorners(radius));
}
 
Example #13
Source File: NetImageView.java    From Alibaba-Android-Certification with MIT License 5 votes vote down vote up
/**
 *
 * @param uri
 * @param defDrawable
 * @param mTransformation       自定义Bitmap
 */
public void load(String uri, int defDrawable, BitmapTransformation mTransformation){
    DrawableRequestBuilder<String> builder=Glide.with(getContext()).load(uri).placeholder(defDrawable);
    //监听
    if(mListener!=null){
        builder.listener(mListener);
    }
    //特殊图像
    if(mTransformation!=null){
        builder.transform(mTransformation).into(this);
    }else{
        builder.into(this);
    }
}
 
Example #14
Source File: ImageLoader.java    From Retrofit2SampleApp with MIT License 5 votes vote down vote up
@Override
public void loadImage(String url, final ImageView imageView) {
    Glide.with(imageView.getContext()).load(url).transform(new BitmapTransformation(imageView.getContext()) {
        @Override
        protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
            BlurTransformation blurTransformation = new BlurTransformation(imageView.getContext());
            Resource<Bitmap> blurredBitmapResource = blurTransformation.transform(BitmapResource.obtain(toTransform, pool), 10, 1);

            Bitmap combinedBitmap;
            Bitmap bottom = blurredBitmapResource.get();

            if ((combinedBitmap = pool.get(toTransform.getWidth(), bottom.getHeight() / 3 + toTransform.getHeight(), Bitmap.Config.ARGB_8888)) == null) {
                combinedBitmap = Bitmap.createBitmap(toTransform.getWidth(), bottom.getHeight() / 3 + toTransform.getHeight(), toTransform.getConfig());
            }

            Canvas comboImage = new Canvas(combinedBitmap);
            comboImage.drawBitmap(toTransform, 0f, 0f, null);

            Matrix matrix = new Matrix();
            matrix.postRotate(180);
            matrix.preScale(-1 , 1);
            matrix.postTranslate(0, toTransform.getHeight() * 2);

            comboImage.setMatrix(matrix);
            comboImage.drawBitmap(bottom, 0f, 0f, null);

            return BitmapResource.obtain(combinedBitmap, pool).get();
        }

        @Override
        public String getId() {
            return ImageLoader.class.getName() + ".Transformation";
        }
    }).into(imageView);
}
 
Example #15
Source File: MyFollowHolder.java    From Mysplash with GNU Lesser General Public License v3.0 4 votes vote down vote up
void onBindView(MyFollowModel model, @Nullable MyFollowAdapter.ItemEventCallback callback) {
    Context context = itemView.getContext();

    background.setOnClickListener(v -> {
        if (callback != null) {
            callback.onFollowItemClicked(avatar, background, model.user);
        }
    });

    if (TextUtils.isEmpty(model.avatarUrl)) {
        ImageHelper.loadImage(context, avatar, com.wangdaye.common.R.drawable.default_avatar,
                model.avatarSize, new BitmapTransformation[]{new CircleTransformation(context)}, null);
    } else {
        ImageHelper.loadImage(context, avatar, model.avatarUrl, com.wangdaye.common.R.drawable.default_avatar_round,
                model.avatarSize, new BitmapTransformation[]{new CircleTransformation(context)}, null);
    }

    title.setText(model.title);

    if (model.progressing) {
        rippleButton.setState(
                model.switchOn
                        ? RippleButton.State.TRANSFORM_TO_OFF
                        : RippleButton.State.TRANSFORM_TO_ON
        );
    } else {
        rippleButton.setState(
                model.switchOn
                        ? RippleButton.State.ON
                        : RippleButton.State.OFF
        );
    }
    rippleButton.setOnSwitchListener(current -> {
        if (callback != null && getAdapterPosition() != RecyclerView.NO_POSITION) {
            callback.onFollowUserOrCancel(model.user, getAdapterPosition(), !model.user.followed_by_user);
        }
    });

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        avatar.setTransitionName(model.user.username + "-" + getAdapterPosition() + "-avatar");
        background.setTransitionName(model.user.username + "-" + getAdapterPosition() + "-background");
    }
}
 
Example #16
Source File: AttachmentGallery.java    From mage-android with Apache License 2.0 4 votes vote down vote up
void addAttachment(ViewGroup gallery, final Attachment a) {
    final AppCompatImageView iv = new AppCompatImageView(context);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width, height);
    iv.setLayoutParams(lp);
    iv.setBackgroundColor(ResourcesCompat.getColor(context.getResources(), R.color.background_attachment, context.getTheme()));
    lp.setMargins(0, 16, 25, 16);
    iv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (attachmentClickListener != null) {
                attachmentClickListener.onAttachmentClick(a);
            }
        }
    });
    gallery.addView(iv);

    CircularProgressDrawable progress = new CircularProgressDrawable(context);
    progress.setStrokeWidth(10f);
    progress.setCenterRadius(width / 4);
    progress.setColorSchemeColors(context.getResources().getColor(R.color.md_blue_600), context.getResources().getColor(R.color.md_orange_A200));
    progress.start();

    boolean isVideo = false;
    if (a.getLocalPath() != null) {
        String fileExtension = MimeTypeMap.getFileExtensionFromUrl(a.getLocalPath());
        String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension.toLowerCase());
        isVideo = mimeType.startsWith("video/");
    } else if (a.getContentType() != null) {
        isVideo = a.getContentType().startsWith("video/");
    }

    Collection<BitmapTransformation> transformations = new ArrayList<>();
    transformations.add(new CenterCrop());
    if (isVideo) {
        transformations.add(new VideoOverlayTransformation(context));
    }

    GlideApp.with(context)
            .asBitmap()
            .load(a)
            .placeholder(progress)
            .fallback(R.drawable.ic_attachment_200dp)
            .error(R.drawable.ic_attachment_200dp)
            .transforms(transformations.toArray(new BitmapTransformation[]{}))
            .into(iv);
}
 
Example #17
Source File: GlideBitmapLoader.java    From scissors with Apache License 2.0 4 votes vote down vote up
public GlideBitmapLoader(@NonNull RequestManager requestManager, @NonNull BitmapTransformation transformation) {
    this.requestManager = requestManager;
    this.transformation = transformation;
}
 
Example #18
Source File: ImageHelper.java    From Mysplash with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void loadImage(Context context, ImageView view,
                             @NonNull String url, @Nullable String thumbUrl, @Size(2) @Px int[] size,
                             @Nullable BitmapTransformation[] ts, @Nullable OnLoadImageListener l) {
    loadImage(context, view, url, thumbUrl, size, null, ts, l);
}
 
Example #19
Source File: GlideFillViewportTransformation.java    From scissors with Apache License 2.0 4 votes vote down vote up
public static BitmapTransformation createUsing(int viewportWidth, int viewportHeight) {
    return new GlideFillViewportTransformation(viewportWidth, viewportHeight);
}
 
Example #20
Source File: CollectionHolder.java    From Mysplash with GNU Lesser General Public License v3.0 4 votes vote down vote up
void onBindView(CollectionModel model, @Nullable CollectionAdapter.ItemEventCallback callback) {
    Context context = itemView.getContext();

    card.setCoverImage(image);
    card.setLongPressDragChildList(Collections.singletonList(avatar));
    card.setCancelFlagMarginTop(cancelFlagMarginTop);
    card.setOnClickListener(v -> {
        if (callback != null) {
            callback.onCollectionClicked(avatar, card, model.collection);
        }
    });

    title.setText(model.title);
    subtitle.setText(model.subtitle);
    name.setText(model.authorName);

    if (TextUtils.isEmpty(model.coverUrl)) {
        image.setShowShadow(false);
    } else {
        image.setShowShadow(true);
        image.setSize(model.coverSize[0], model.coverSize[1]);

        ImageHelper.setImageViewSaturation(image, model.hasFadeIn ? 1 : 0);
        ImageHelper.loadImage(context, image, model.coverUrl, model.thumbUrl, model.coverSize, null, () -> {
            if (!model.hasFadeIn) {
                model.hasFadeIn = true;
                long duration = Long.parseLong(
                        ComponentFactory.getSettingsService().getSaturationAnimationDuration());
                ImageHelper.startSaturationAnimation(context, image, duration);
            }
        });
        card.setCardBackgroundColor(model.coverColor);
    }

    if (TextUtils.isEmpty(model.authorAvatarUrl)) {
        ImageHelper.loadImage(context, avatar, R.drawable.default_avatar,
                model.authorAvatarSize, new BitmapTransformation[]{new CircleTransformation(context)}, null);
    } else {
        ImageHelper.loadImage(context, avatar, model.authorAvatarUrl, R.drawable.default_avatar_round,
                model.authorAvatarSize, new BitmapTransformation[]{new CircleTransformation(context)}, null);
    }
    avatar.setOnClickListener(v -> {
        if (callback != null) {
            callback.onUserClicked(avatar, card, model.collection.user);
        }
    });

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        card.setTransitionName(model.collection.id + "-background");
        avatar.setTransitionName(model.collection.user.username + "-avatar");
    }
}
 
Example #21
Source File: PhotoHolder.java    From Mysplash with GNU Lesser General Public License v3.0 4 votes vote down vote up
void onBindView(PhotoModel model, boolean showDeleteButton,
                boolean update, @Nullable PhotoAdapter.ItemEventCallback callback) {
    Context context = itemView.getContext();

    this.photo = model.photo;
    this.callback = callback;

    card.setCoverImage(image);
    card.setLongPressDragChildList(
            Arrays.asList(avatar, downloadButton, collectionButton, likeButton)
    );

    image.setSize(model.photoSize[0], model.photoSize[1]);
    image.setShowShadow(true);

    if (!update) {
        ImageHelper.setImageViewSaturation(image, model.hasFadeIn ? 1 : 0);
        ImageHelper.loadImage(context, image, model.photoUrl, model.thumbUrl, model.photoSize, null, () -> {
            if (!model.hasFadeIn) {
                model.hasFadeIn = true;
                long duration = Long.parseLong(
                        ComponentFactory.getSettingsService().getSaturationAnimationDuration());
                ImageHelper.startSaturationAnimation(context, image, duration);
            }
        });
        card.setCardBackgroundColor(model.photoColor);

        if (TextUtils.isEmpty(model.authorAvatarUrl)) {
            ImageHelper.loadImage(context, avatar, R.drawable.default_avatar,
                    model.authorAvatarSize, new BitmapTransformation[]{new CircleTransformation(context)}, null);
        } else {
            ImageHelper.loadImage(context, avatar, model.authorAvatarUrl, R.drawable.default_avatar_round,
                    model.authorAvatarSize, new BitmapTransformation[]{new CircleTransformation(context)}, null);
        }
    }

    title.setText(model.authorName);

    if (showDeleteButton) {
        deleteButton.setVisibility(View.VISIBLE);
    } else {
        deleteButton.setVisibility(View.GONE);
    }

    downloadButton.setProgressColor(Color.WHITE);
    if (model.downloading) {
        downloadButton.setProgressState();
    } else {
        downloadButton.setResultState(R.drawable.ic_download_white);
    }

    if (model.collected) {
        collectionButton.setImageResource(R.drawable.ic_item_collected);
    } else {
        collectionButton.setImageResource(R.drawable.ic_item_collect);
    }

    likeButton.setProgressColor(Color.WHITE);
    if (model.likeProgressing) {
        likeButton.setProgressState();
    } else {
        likeButton.setResultState(
                model.liked ? R.drawable.ic_heart_red : R.drawable.ic_heart_outline_white);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        image.setTransitionName(photo.id + "-cover");
        card.setTransitionName(photo.id + "-background");
    }
}
 
Example #22
Source File: PhotoFeedHolder.java    From Mysplash with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void onBindView(FollowingModel model, boolean update) {
    Context context = itemView.getContext();
    PhotoFeedModel photoFeedModel = (PhotoFeedModel) model;

    this.photo = model.photo;
    this.photoPosition = model.photoPosition;

    card.setCoverImage(image);
    card.setLongPressDragChildList(
            Arrays.asList(avatar, downloadButton, collectionButton, likeButton)
    );

    image.setSize(photoFeedModel.photoSize[0], photoFeedModel.photoSize[1]);
    image.setShowShadow(true);

    if (!update) {
        ImageHelper.setImageViewSaturation(image, photoFeedModel.hasFadeIn ? 1 : 0);
        ImageHelper.loadImage(context, image, photoFeedModel.photoUrl, photoFeedModel.thumbUrl, 
                photoFeedModel.photoSize, null, () -> {
            if (!photoFeedModel.hasFadeIn) {
                photoFeedModel.hasFadeIn = true;
                long duration = Long.parseLong(
                        ComponentFactory.getSettingsService().getSaturationAnimationDuration());
                ImageHelper.startSaturationAnimation(context, image, duration);
            }
        });
        card.setCardBackgroundColor(photoFeedModel.photoColor);

        if (TextUtils.isEmpty(photoFeedModel.authorAvatarUrl)) {
            ImageHelper.loadImage(context, avatar, R.drawable.default_avatar,
                    photoFeedModel.authorAvatarSize, new BitmapTransformation[]{new CircleTransformation(context)}, null);
        } else {
            ImageHelper.loadImage(context, avatar, photoFeedModel.authorAvatarUrl, R.drawable.default_avatar_round,
                    photoFeedModel.authorAvatarSize, new BitmapTransformation[]{new CircleTransformation(context)}, null);
        }
    }

    title.setText(photoFeedModel.authorName);

    downloadButton.setProgressColor(Color.WHITE);
    if (photoFeedModel.downloading) {
        downloadButton.setProgressState();
    } else {
        downloadButton.setResultState(R.drawable.ic_download_white);
    }

    if (photoFeedModel.collected) {
        collectionButton.setImageResource(R.drawable.ic_item_collected);
    } else {
        collectionButton.setImageResource(R.drawable.ic_item_collect);
    }

    likeButton.setProgressColor(Color.WHITE);
    if (photoFeedModel.likeProgressing) {
        likeButton.setProgressState();
    } else {
        likeButton.setResultState(
                photoFeedModel.liked ? R.drawable.ic_heart_red : R.drawable.ic_heart_outline_white);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        image.setTransitionName(photo.id + "-cover");
        card.setTransitionName(photo.id + "-background");
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        image.setTransitionName(photo.id + "-cover");
        card.setTransitionName(photo.id + "-background");
    }
}
 
Example #23
Source File: ImageConfigImpl.java    From MVPArms with Apache License 2.0 4 votes vote down vote up
public BitmapTransformation getTransformation() {
    return transformation;
}
 
Example #24
Source File: ImageConfigImpl.java    From MVVMArms with Apache License 2.0 4 votes vote down vote up
public BitmapTransformation getTransformation() {
    return transformation;
}
 
Example #25
Source File: ImageConfigImpl.java    From Aurora with Apache License 2.0 4 votes vote down vote up
public BitmapTransformation getTransformation() {
    return transformation;
}
 
Example #26
Source File: CommonImageConfigImpl.java    From Hands-Chopping with Apache License 2.0 4 votes vote down vote up
public BitmapTransformation getTransformation() {
    return transformation;
}
 
Example #27
Source File: CommonImageConfigImpl.java    From lifecycle-component with Apache License 2.0 4 votes vote down vote up
public BitmapTransformation getTransformation() {
    return transformation;
}
 
Example #28
Source File: BitmapRequestBuilder.java    From giffun with Apache License 2.0 2 votes vote down vote up
/**
 * Transform images using the given {@link BitmapTransformation}s.
 *
 * @see #centerCrop()
 * @see #fitCenter()
 * @see #transform(Transformation[])
 *
 * @param transformations The transformations to apply in order.
 * @return This request builder.
 */
public BitmapRequestBuilder<ModelType, TranscodeType> transform(BitmapTransformation... transformations) {
    super.transform(transformations);
    return this;
}
 
Example #29
Source File: GifRequestBuilder.java    From giffun with Apache License 2.0 2 votes vote down vote up
/**
 * Transforms each frame of the GIF using the given transformations.
 *
 * @see #centerCrop()
 * @see #fitCenter()
 * @see #transformFrame(Transformation[])
 * @see #transform(Transformation[])
 *
 * @param bitmapTransformations The transformations to apply in order to each frame.
 * @return This request builder.
 */
public GifRequestBuilder<ModelType> transformFrame(BitmapTransformation... bitmapTransformations) {
    return transform(toGifTransformations(bitmapTransformations));
}
 
Example #30
Source File: DrawableRequestBuilder.java    From giffun with Apache License 2.0 2 votes vote down vote up
/**
 * Transform {@link GlideDrawable}s using the given
 * {@link BitmapTransformation}s.
 *
 * <p>
 *     Note - Bitmap transformations will apply individually to each frame of animated GIF images and also to
 *     individual {@link Bitmap}s.
 * </p>
 *
 * @see #centerCrop()
 * @see #fitCenter()
 * @see #bitmapTransform(Transformation[])
 * @see #transform(Transformation[])
 *
 * @param transformations The transformations to apply in order.
 * @return This request builder.
 */
public DrawableRequestBuilder<ModelType> transform(BitmapTransformation... transformations) {
    return bitmapTransform(transformations);
}