滑行加载缩略图不起作用 [英] Glide load thumbnail not working

查看:48
本文介绍了滑行加载缩略图不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Glide从视频加载缩略图,但是在我的应用程序上似乎无法使用.由于某些原因,ImageView只是空的.

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

我添加了一个侦听器,所以我可以找出问题所在,但抛出的Exception为null.

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

我尝试使用具有相同网址的ThumbnailUtils,因为我认为这可能有问题,但是缩略图可以很好地加载.

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

有人遇到同样的事情吗?我正在使用Nexus 7(6.0.1)

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

推荐答案

即使我偶然发现了同样的情况.除非使用本地文件路径创建文件实例,否则它会从uri中加载图像.因此,为了使其正常工作,我使用了以下

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

除此之外,我还注意到使用缓存的异常行为.如果您将缓存策略用作 DiskCacheStrategy.ALL或DiskCacheStrategy.SOURCE ,则不会加载缩略图,但是如果我使用的是 DiskCacheStrategy.RESULT ,则可以正常工作.希望对您有帮助

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

这篇关于滑行加载缩略图不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆