0

Now i was working on an demo app that load movies data from an api and i figured out that Glide is a bet faster than Picasso so after using it and adding

RequestOptions requestOptions = new RequestOptions();
requestOptions.error(R.drawable.poster_placeholder);

Glide.with(context)
     .setDefaultRequestOptions(requestOptions)
     .load(film.getPoster())into(poster);

error() works fine but i need to add loading gif to improve UX so i find this solution to add gif and it works great but error() stop working, gif is always run now.

the new code is

RequestOptions requestOptions = new RequestOptions();
requestOptions.error(R.drawable.poster_placeholder);

Glide.with(context)
     .setDefaultRequestOptions(requestOptions)
     .load(film.getPoster())
     .thumbnail(Glide.with(context)
     .load(R.drawable.placeholdergif)).into(poster);

i need a solution that make error() works again or other way to display loading image til the image is loaded.

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
Adham Gamal
  • 775
  • 8
  • 13

1 Answers1

0

This is super simple now with the CircularProgressDrawable released in 26.1.0 (Support library):

  CircularProgressDrawable circularProgressDrawable = 
  CircularProgressDrawable(this);
  circularProgressDrawable.strokeWidth = 5f;
  circularProgressDrawable.centerRadius = 30f;
  circularProgressDrawable.start();

  Glide.with(context)
  .setDefaultRequestOptions(requestOptions)
  .load(film.getPoster())
  .thumbnail(Glide.with(context)
  .placeholder(circularProgressDrawable)
  .into(a_main_image);
}
Asad Ali
  • 309
  • 3
  • 14