2

I want to show gif on Glide error() in recycler Adapter. how should I do that?

I want to show a picture in Glide, and when the internet will be disconnected, I'll show a Gif, but Glide Gif will not show. here is my glide code that just shows loading_back.gif and didn't show connection_fail.gif .

 RequestOptions options = new RequestOptions()
            .centerCrop()
            .placeholder(R.drawable.static_place_holder)
            .error(R.drawable.connection_fail)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .priority(Priority.HIGH);

    Glide.with(context)
            .load(items.get(pos).getLinks())
            .apply(options)
            .thumbnail(Glide.with(context).load(R.drawable.loading_back))
            .thumbnail(Glide.with(context).load(R.drawable.connection_fail))
            .into(holder.imageView);
Zoe
  • 27,060
  • 21
  • 118
  • 148
A.ebrahimi
  • 33
  • 1
  • 7
  • 3
    Possible duplicate of [using glide to show animated gif file with ImageView (android)](https://stackoverflow.com/questions/44319981/using-glide-to-show-animated-gif-file-with-imageview-android) – Anil Ravsaheb Ghodake Nov 28 '18 at 12:54

1 Answers1

1

From This and this questions.

build.gradle(app-level)

dependencies {
  implementation 'com.github.bumptech.glide:glide:4.14.2'
  annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2'
}

Use of Glide.

Glide.with(context)
    .load(imgUrl)
    .asGif()
    .placeholder(R.drawable.img)
    .crossFade()
    .into(imageView);
Rumit Patel
  • 8,830
  • 18
  • 51
  • 70