0

I'm implementing a custom list of achievements in my app, but I can not succeed when trying to load the image of each achievement.

This is my code snippet in my adapter responsible for loading the image:

Uri uri = (currentAchievement.getState() == Achievement.STATE_UNLOCKED) ? currentAchievement.getUnlockedImageUri() : currentAchievement.getRevealedImageUri();

Picasso.with(context)
    .load(uri.getPath())
    .placeholder(R.drawable.ic_account_circle_grey600_36dp)
    .transform(new CircleTransform())
    .resizeDimen(R.dimen.imagem_user_perfil, R.dimen.imagem_user_perfil)
    .centerCrop()
    .into(imageAchievement);

This code always displays the image placeholder. Does anyone have any idea why?

Michiyo
  • 1,161
  • 1
  • 14
  • 33
sThiago
  • 215
  • 1
  • 10
  • Have you debugged the contents of 'uri.getPath()' at that point? – Alejandro Zurcher May 12 '16 at 20:29
  • Yes. getPath() returns something similar '/images/13cffed8/1047' – sThiago May 12 '16 at 20:39
  • So how should Picasso know where `/images/13cffed8/1047` is? You're missing the host for this. – Darwind May 12 '16 at 21:34
  • Check this [SO question](http://stackoverflow.com/questions/25782224/android-picasso-shows-only-placeholder-not-the-image-from-url) if it can help you :) – KENdi May 13 '16 at 05:19
  • 1
    It seems that you're miss using Picasso library, in its [documentation](http://square.github.io/picasso/) you can find how to pass the image location, is either a web url, an index of a drawable using R.id.xxxx or a File object. Check to be using it properly, and send the correct Path. `Picasso.with(context).load(R.drawable.landing_screen).into(imageView1) Picasso.with(context).load("file:///android_asset/DvpvklR.png").into(imageView2) Picasso.with(context).load(new File(...)).into(imageView3)` – Alejandro Zurcher May 14 '16 at 17:48
  • @azetaguionbajo Thanks for this, I accidentally loaded a normal path instead of a file or web url. – Dennis van Opstal May 17 '16 at 12:38

0 Answers0