0

I am tried this code, but not getting the desired output.

 Picasso.with(getApplicationContext()).load(mPicList.get(position)).into(new Target() {
                    @Override
                    public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                        zoomImageView.setImageBitmap(bitmap);
                        Logger.getInstance().v("qw", "ViewPagerAdapter.134.onBitmapLoaded.");           
                    }

                    @Override
                    public void onBitmapFailed(Drawable errorDrawable) {
                        Logger.getInstance().v("qw", "ViewPagerAdapter.139.onBitmapFailed.");       
                    }

                    @Override
                    public void onPrepareLoad(Drawable placeHolderDrawable) {
                        Logger.getInstance().v("qw", "ViewPagerAdapter.144.onPrepareLoad.");
                    }
                });

It always print log onPrepareLoad why????

duke mars
  • 3
  • 4

2 Answers2

0

I'm not sure if there is a reason for new Target()... but you can try to use something like this:

Picasso.with(this).load(mPicList.get(position)).into(zoomImageView); 

If you are in a Fragment, use getActivity() instead of this.

Marijan
  • 711
  • 8
  • 16
0

Your problem is that nothing keeps a strong reference to the Target instance so it gets garbage collected. You can't just call new Target() { ... } because there aren't any strong references to it. You need to store it on a field in a view holder or implement it on a subclass of a view.

See this answer:

https://stackoverflow.com/a/30681395/5476209

this guy explicitly managed garbage collection issue happening in library.

Community
  • 1
  • 1
TapanHP
  • 5,969
  • 6
  • 37
  • 66
  • success with zoomImageView.setTag(mTarget); – duke mars Jun 27 '16 at 10:51
  • 1
    no problem at all whenever you got any situation like this kindly go to that github library and at least check issues in library, your issue is already discussed there in picasso library. @dukemars – TapanHP Jun 27 '16 at 11:12
  • thanks,I have never use stackflow before,thanks for your suggestion – duke mars Jun 28 '16 at 02:41