Glide doesn't load images until scrolled or don't load at all

Viewed 380
Android Studio 3.0 Beta 5
glide:3.7.0

I am using glide to load images into a CircleImageView. However, the images don't load until the recyclerview is scrolled. And sometimes when scrolling it is not smooth.

This is my viewholder:

public class MovieActorsViewHolder extends RecyclerView.ViewHolder {
    @BindView(R.id.civActorPicture) CircleImageView actorPicture;
    @BindView(R.id.tvName) TextView name;
    @BindView(R.id.tvCharacter) TextView character;

    private Context context;

    public MovieActorsViewHolder(View itemView) {
        super(itemView);
        ButterKnife.bind(this, itemView);

        context = itemView.getContext();
    }

    public void populateActor(Actor actor) {
        Glide.with(context)
                .load(MovieImage.build(actor.getProfile_path(), MovieImage.ImageSize.w92))
                .placeholder(R.drawable.people_placeholder)
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .into(actorPicture);

        name.setText(actor.getName());
        character.setText(actor.getCharacter());
    }
}

My layout I am using. TextView always gets populated. However, when I open the detail screen. I have to scroll forwards and backwards for the images to load.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="6dp">

    <de.hdodenhof.circleimageview.CircleImageView
        android:id="@+id/civActorPicture"
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:layout_gravity="center"
        android:scaleType="centerCrop"
        tools:src="@drawable/people_placeholder"/>

    <TextView
        android:id="@+id/tvName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="4dp"
        tools:text="Micheal Keaton"/>

    <TextView
        android:id="@+id/tvCharacter"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="4dp"
        tools:text="Adrian Toomes / The Vulture"/>
</LinearLayout>

enter image description here

1 Answers

Try to add .asBitmap() method before .load() this solved my problem

Glide.with(context)
      .asBitmap()
      .load(MovieImage.build(actor.getProfile_path(), MovieImage.ImageSize.w92))
Related