A.ebrahimi
A.ebrahimi

Reputation: 33

How to show gif on Glide

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);

Upvotes: 2

Views: 4541

Answers (1)

Rumit Patel
Rumit Patel

Reputation: 12469

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);

Upvotes: 1

Related Questions