android - Glide 和 Picasso 无法从 YouTube 加载图像
问题描述
我是 ImageView、Picasso、Glide 的新手。我只想从 url 加载图像,我尝试过 Glide 和 Picasso。他们都可以很好地加载图像,但如果我尝试从 youtube(缩略图)加载图像 - 不加载。// http://i.ytimg.com/vi/z0NfI2NeDHI/sddefault.jpg - 不加载
MainActivity.java
imageView = findViewById(R.id.image);
videoImg = ""
fetchData.execute(); //returns link for image to videoImg
Glide.with(this)
.load(videoImg)
.placeholder(R.drawable.ic_launcher_background)
.error(R.drawable.ic_launcher_foreground)
.into(imageView);
Picasso.get().load(videoImg).into(imageView);
activity_main.xml
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
日志猫
W/Glide: Failed to find GeneratedAppGlideModule. You should include an annotationProcessor compile dependency on com.github.bumptech.glide:compiler in your application and a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored
W/Glide: Load failed for null with size [0x0]
class com.bumptech.glide.load.engine.GlideException: Received null model
解决方案
我认为您面临的问题与 Glide、Picasso 等图书馆无关。我尝试使用您提供的图片链接Glide
,它按预期工作。
我有根据的猜测是,您的设备正在使用某种受限网络,因此它会阻止来自 youtube 端点的进出请求。如果你从另一个网络连接它会工作得很好。
推荐阅读
- html - HTML 浏览器图像兼容性
- entity-framework-6 - 在 EntityFramwork 6.2.0 我想创建阴影属性(是 EF 6 支持阴影属性)
- react-native - 在反应原生的屏幕之间传递不可序列化的对象
- r - 尽管使用 scale_fill_manual(),ggplotly() 仍忽略图例标签编辑
- javascript - JS 对象原型级别和继承复制或参考
- java - 具有默认接口方法的 Java 8 InvocationHandler
- javascript - 如何通过使用 ajax 调用按下按钮删除来删除数据库行
- python-3.x - Read .txt with emoji characters in python
- keycloak - ISPN 缓存的 Keycloak 和失效模式
- javascript - 如何使 ChartJS 中的 Line 不超过 yAxes 的最大值