Scaling TouchImageView scaled to frame using Picasso

I used the Universal Image Loader library to load a set of images and a TouchImageView to scale. I decided to replace Universal Image Loader with picasso. Everything worked fine, but now the image is getting closer to a frame that is slightly larger than the image.

@Override
    public Object instantiateItem(ViewGroup view, int position) {
        View imageLayout = inflater.inflate(R.layout.item_pager_image, view, false);
        assert imageLayout != null;
        TouchImageView imageView = (TouchImageView) imageLayout.findViewById(R.id.image);
        final ProgressBar spinner = (ProgressBar) imageLayout.findViewById(R.id.loading);
        spinner.setVisibility(View.INVISIBLE);
        Picasso.with(getApplicationContext()).setIndicatorsEnabled(false);
        Picasso.with(getApplicationContext()).load(images[position]).into(imageView,new Callback() {

            @Override
            public void onSuccess() {
                spinner.setVisibility(View.GONE);        
            }

            @Override
            public void onError() {

            }
        });
        view.addView(imageLayout, 0);
        return imageLayout;

      

During this time I rack my brains for several hours. Is this some kind of TouchImageView issue with Picasso? Any help would be appreciated. Thank.

+3


source to share


3 answers


Mahram Foadi posted a great solution here that works for me too:

Picasso.with(context).load (someUri).into(new Target () {
   @Override
    public void onBitmapLoaded (final Bitmap bitmap,
        final Picasso.LoadedFrom loadedFrom) {
        someTouchImageView.setImageBitmap (bitmap);
    }

   @Override
    public void onBitmapFailed (final Drawable drawable) {
       Log.d(TAG, "Failed");
    }

   @Override
   public void onPrepareLoad (final Drawable drawable) {
        someTouchImageView.setImageDrawable (drawable);
   }
});

      



Hope this helps other people like us to use TouchImageView with Picasso;)

+5


source


I figured out that the whole problem is somehow fixed when I set the width and height of the image from wrap_content to fill_parent.



0


source


Here's if you are using Glide. Slipping faster on load than Picasso and cheaper memory consumption

Glide.with(context).load(url).asBitmap().into(new SimpleTarget<Bitmap>() {
    @Override
    public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
        someTouchImageView.setImageBitmap(resource);
    }
});

      

0


source







All Articles