0

I'm using Picasso to load images, scale and set to listview item. There is my code:

Picasso.with(getActivity()).load(builder.toString())
                            .config(Bitmap.Config.RGB_565)
                            .into(new Target() {
                                @Override
                                public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                                    int width = Double.valueOf(bitmap.getWidth() * 0.75).intValue();
                                    int height = bitmap.getHeight();
                                    Bitmap newBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height);
                                    imageView.setImageBitmap(newBitmap);

                                }

                                @Override
                                public void onBitmapFailed(Drawable errorDrawable) {

                                }

                                @Override
                                public void onPrepareLoad(Drawable placeHolderDrawable) {

                                }
                    });

The problem appears when I made new Target() object in the .into() method, before that the speed of loaded images were very fast. I thought what exactly slowed down my work and how to correct it? Is scale memory-expensive or this is because of new Target() implementation at all?

Who faced with this problem? How to solve that?

VLeonovs
  • 2,193
  • 5
  • 24
  • 44

3 Answers3

1

You can use Fresco for image loading..even facebook using same and for scaling you can use android:scaleType.its very usefull Read about Fresco http://frescolib.org/docs/index.html

piyush poriya
  • 316
  • 1
  • 3
  • 18
0

Use the Glide Library An image loading and caching library for Android focused on smooth scrolling.

https://github.com/bumptech/glide

Picasso is also a good for cashing or U can use LRU cache.

Ajay Keshri
  • 97
  • 1
  • 8
0

You aren't seeing slowness. That Target will probably never be called.

Picasso only holds a WeakReference to a Target. You need to hold your own reference to that Target, or else it will be cleared and gc'd before it can be loaded into.

Eric Cochran
  • 8,414
  • 5
  • 50
  • 91