简体   繁体   English

Android,毕加索-大多数图像都不想加载(Kotlin)

[英]Android, Picasso - most of the images don't want to load (Kotlin)

I'm trying to build a RecyclerView filled with a card view items. 我正在尝试构建一个充满卡片视图项目的RecyclerView。 For each item I need 2 small images that I load from URL. 对于每个项目,我需要从URL加载的2张小图像。 Everything works fine only if I load sample image from Picasso website ( http://i.imgur.com/DvpvklR.png ). 仅当我从Picasso网站( http://i.imgur.com/DvpvklR.png )加载示例图像时,一切都正常。 Every other picture I try to load doesn't show up. 我尝试加载的所有其他图片均未显示。

Here's my code; 这是我的代码; inside my RecyclerViewAdapter, inside the onBindViewHolder() function I'm calling: 在我的RecyclerViewAdapter中,在我正在调用的onBindViewHolder()函数中:

fun loadImageInBackground(item : Footballer,  holder : ViewHolder){
    doAsync {
        var loadImage = Picasso.get().load(item.footballerImageUrl)
        var loadFlagImage = Picasso.get().load(item.flagImageUrl)
        uiThread {
            loadImage.into(holder?.footballerImage)
            loadFlagImage.into(holder?.flagImage)
        }
    }
}

I'm using Kotlin ANKO for "doAsync". 我将Kotlin ANKO用于“ doAsync”。 Any ideas? 有任何想法吗? Thanks in advance! 提前致谢!

I partly solved this. 我部分解决了这个问题。 It seems like I was using wrong links, but I'm not sure where was the issue. 似乎我使用了错误的链接,但是我不确定问题出在哪里。

Now when I upload a picture to imgur.com and copy a direct link it works. 现在,当我将图片上传到imgur.com并复制直接链接时,它可以正常工作。 But what's the rule for the links? 但是链接的规则是什么? Why the previous mentioned were not working? 为什么前面提到的无效? Can anybody guide me here? 有人可以在这里引导我吗?

Try below methods its working for me. 请尝试以下方法为我工作。

build.gradle : build.gradle:

implementation 'com.squareup.picasso:picasso:2.71828'

Java Code : Java代码:

Picasso.get().load("URL PATH").into(Image_view)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM