0

i´m using Picasso and Target for downloading an image and saving it as a bitmap to pass it into an Object which i use for and RecyclerView.

But when I try to download the image the Target also loads the onBitmapFailed or onPrepareLoad and the bitmapis not successfully received...

where´s the bug in my code? The URL is absolutely correct. when i take the passed URL and paste it in chrome browser the image shows...

Code

//Get Bitmap
                            targetForBitmap = new Target() {
                                @Override
                                public void onBitmapLoaded (final Bitmap responseBitmap, Picasso.LoadedFrom from){

                                    bitmap = responseBitmap;
                                }

                                @Override
                                public void onPrepareLoad(Drawable placeHolderDrawable) {
                                    Log.i("prepareLoad", "onPrepereLoad ääääääääääääääääääää ");
                                }

                                @Override
                                public void onBitmapFailed(Drawable errorDrawable) {
                                    Log.i("onBitmapFailed", "onBitmapFailed xxxxxxxxxxxxxxxx");
                                }
                            };

                            String url = "Http://" + server_wan + ":" + port_wan + "/" + server_path + "/Produktbilder/" + product_image + ".png";
                            Log.i("url", url);
                            Picasso.with(SpeisekarteActivity.this)
                                    .load(url)
                                    .into(targetForBitmap);

targetForBitmap is string instance at beginning of the class (private Target targetForBitmap)

skm
  • 559
  • 1
  • 6
  • 22
  • getting any errors? – Kaushal28 May 14 '17 at 07:30
  • I´m not getting the bitmap...it´s loading the two other methods. The bitmap is not shown in recclerview or any other Imageview when i pass for testing... Maybe important to know is that I´m trying to load many images ... in a loop using this method. – skm May 14 '17 at 07:31
  • Internet permissions? – Kaushal28 May 14 '17 at 07:31
  • yes internet is in Manifest – skm May 14 '17 at 07:32
  • it seems that is doesn´t enter the onBitmapLoaded method...why? – skm May 14 '17 at 07:34
  • Do you check what's the error `onBitmapFailed` listener method? I use Picasso in one of my apps. It does not load some images if they are big. – Thracian May 14 '17 at 07:44
  • yes, i have put them both in an imageView on Screen and there´s showing noting...maybe null or just no image which is passed to the imageView. – skm May 14 '17 at 08:22

1 Answers1

0

Please provide the imageview where you want to load the image inside the onBitmapLoaded. Try using .placeholder(drawable) and .error(drawable) with picasso.Use it after .load function. Try checking out here: [1]: Picasso Library, Android: Using Error Listener

Community
  • 1
  • 1
  • for what is the .placeholder(drawable) ? and .error(drawable) ? – skm May 14 '17 at 08:20
  • .placeholder()=it places the dummy image in the imageview while picasso is loading the image. .error()=it places the image in the imageview when picasso encounters error while loading the image – My Question May 14 '17 at 12:10