Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Glide load thumbnail not working

I'm using Glide to load thumbnail from videos but it doesn't seem to be working on my app. The ImageView is just empty for some reason.

Glide.with(context)
            .load(url)
            .asBitmap()
            .thumbnail(0.1f)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .into(target);

I added a listener, so I can figure out what is wrong but the Exception thrown is null.

I tried using ThumbnailUtils using the same url because I thought there might be something wrong with it but the thumbnail loads fine.

Anyone experiencing the same? I'm using a Nexus 7 (6.0.1)

like image 712
kishidp Avatar asked Feb 05 '16 10:02

kishidp


People also ask

How do you download pictures from Glide?

To simply load an image to LinearLayout, we call the with() method of Glide class and pass the context, then we call the load() method, which contains the URL of the image to be downloaded and finally we call the into() method to display the downloaded image on our ImageView.


1 Answers

Even i stumbled upon the same situation. Somehow from the uri its not loading the image unless create a file instance using local file path. So to make it work i used it like below

Glide.with(mContext).load(Uri.fromFile(new File(path)).into(icon);

In the doc they are using the same approach. You can refer here : Glide - Videos

Apart from that i also noticed unusual behaviour of using the cache. If you are using cache strategy as DiskCacheStrategy.ALL or DiskCacheStrategy.SOURCE it doesn't load the thumbnail but if i am using DiskCacheStrategy.RESULT it works. Hope it helps

like image 165
Gautam Avatar answered Sep 30 '22 21:09

Gautam