apksherlock
apksherlock

Reputation: 8371

Problems with loading image url with Picasso

I am loading images from a certain url with Picasso and I get this error:

Failed to create image decoder with message 'unimplemented'

This is my adapter class :

class CountriesAdapter(var countriesList: ArrayList<Country>) :
    RecyclerView.Adapter<CountriesAdapter.CountriesViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CountriesViewHolder =
        CountriesViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.single_item_country, parent, false))


    override fun onBindViewHolder(holder: CountriesViewHolder, position: Int) {
        holder.bind(countriesList[position])
    }

    override fun getItemCount(): Int = countriesList.size


    class CountriesViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        fun bind(country: Country) = with(itemView) {
            itemView.tvCountryName.text = country.name
            Picasso.get().load(country.flagUrl).fit().placeholder(R.drawable.ic_asr_sun).into(itemView.ivCountryFlag)
        }

    }
}

I tested the same use case with Glide and still doesn't work , so I am assuming I am doing something wrong .

Edit The url is correct

Upvotes: 1

Views: 3338

Answers (1)

apksherlock
apksherlock

Reputation: 8371

According to this link here , after I logged the Picasso error , which was :

W/System.err: java.io.IOException: Failed to decode stream.

This issue cannot be resolved here . As the discussion says :

This error occurs when Android is unable to decode your image. There's nothing Picasso can do to correct this. Consider using another image format or re-encoding your image.

Upvotes: 2

Related Questions