The problem that i’m having is that the gif only loads if i click in the image. I made a ViewHolderCreator class that builds the view. There is a method onCreateViewHolder that will tell which type it is.There are various types. This is the list in the class:
private final int CI_IMAGE = 1; private final int CI_IMAGE_AND_TEXT = 2; private final int CI_TEXT = 4; private final int CI_VIDEO_RIGHT = 5; private final int CI_PRODUCT = 6; private final int CI_TEXT_AND_IMAGE = 7; private final int CI_VIDEO_LEFT = 8; private final int CI_IMAGE_SQUARED = 9; private final int CI_IMAGE_THREE_BY_ONE = 10;
The specific gif that i want is CI_IMAGE and in the code it will instatiate the class CIImageViewHolder
This is the CIImageViewHolder class:
public class CIImageViewHolder extends ContentViewHolder {
@Nullable
@BindView(R.id.image)
ImageView imageView;
@Nullable
private BitmapImageViewTarget imageTarget;
public CIImageViewHolder(@NonNull View view) {
super(view);
ButterKnife.bind(this, view);
imageTarget = new BitmapImageViewTarget(imageView);
}
@Override
public void refreshView(Content content, boolean vertical, boolean isUnicorn) {
final ContentInfusion contentInfusion = content.getContent();
imageView.setImageBitmap(null);
Image image = contentInfusion.getImage();
if (image != null) {
Glide.with(mContext).asBitmap().load(image.getUrl())
.transition(new GenericTransitionOptions<>().transition(R.anim.quick_fade_in)).into(imageTarget);
imageView.setVisibility(View.VISIBLE);
} else {
imageView.setVisibility(View.INVISIBLE);
}
}
}
Advertisement
Answer
Try this for gif
Glide.with(mContext)
.asGif()
.load(image.getUrl())
.transition(new GenericTransitionOptions<>().transition(R.anim.quick_fade_in))
.into(imageView);
Gradle versions:
implementation 'com.github.bumptech.glide:glide:4.12.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'