简体   繁体   中英

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. For each item I need 2 small images that I load from URL. Everything works fine only if I load sample image from Picasso website ( 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:

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". 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. 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 :

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

Java Code :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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