Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Best Android library for caching images

Hi Guys, I need a library to load images async and cache them when loaded.
I'm searching for the best Xamarin Android Library and I found Picasso and other free projects.
Can someone suggest me which is the best?

Thanks :)

Best Answers

Answers

  • RiccardoBadiniRiccardoBadini ITMember ✭✭

    Ok thanks. :)
    I also need to subscribe to the event of "image load finished"...for example when I load image into an image view and I wanna to do something after loading.
    Is there a way to do this using Picasso?

  • RiccardoBadiniRiccardoBadini ITMember ✭✭

    Ok thanks to all, I'm using Picasso now and I understood how to manage callbacks ;)

  • akshay2000akshay2000 INMember

    @RiccardoBadini said:
    Ok thanks to all, I'm using Picasso now and I understood how to manage callbacks ;)

    What made you choose Picasso over FFImageLoading? Do you have any pros-cons comparison?

  • MahibaRajaseelanMahibaRajaseelan USMember ✭✭

    I tried both Picasso and FFImageLoading.
    In Picasso, downloaded images disappear when I scroll back up.
    Suggest FFImageLoading which is faster and cache friendly. Tried FFImageLoading in listview to load around 50 images. Its working great.
    Refer https://forums.xamarin.com/discussion/58341/ffimageloading-plugin-fast-and-memory-friendly-image-loader-ios-android-forms-windows

  • MAmmarMAmmar USMember ✭✭

    I need some urgent help. I want to call a function in picasso library after image has been load but did not find some hint. How to do this?
    This is java code and i want to implement in Xamarin.
    Picasso.with(getContext())
    .load(url)
    .into(imageView, new com.squareup.picasso.Callback() {
    @Override
    public void onSuccess() {

                        }
    
                        @Override
                        public void onError() {
    
                        }
                    });
    
  • cwphillicwphilli USMember ✭✭✭

    I actually really like Akavache.
    I use it for all my mobile caching needs including it's built in image request / caching.

  • DooksDooks ZAMember ✭✭✭

    @MAmmar said:
    I need some urgent help. I want to call a function in picasso library after image has been load but did not find some hint. How to do this?
    This is java code and i want to implement in Xamarin.
    Picasso.with(getContext())
    .load(url)
    .into(imageView, new com.squareup.picasso.Callback() {
    @Override
    public void onSuccess() {

                        }
    
                        @Override
                        public void onError() {
    
                        }
                    });
    

    Using the callback is exactly the same as the one override .into(imgView, () => { /*Success*/ }, () => { /*Error*/ }
    Unfortunately there are no error messages to help you solve issues.

    If you do want to use the callback, you have to create a new Class extending to Java.Lang.Object, Square.Picasso.ICallback
    Like so:

    public class PicassoCallback : Java.Lang.Object, Square.Picasso.ICallback
    {
        private Action Success;
        private Action Error;
        public picassocallback(Action success, Action error)
        {
            Success = success;
            Error = error;
        }
    
        public void OnError()
        {
            Error?.Invoke();
        }
    
        public void OnSuccess()
        {
            Success?.Invoke();
        }
    }
    

    Then you use it like this:

    .into(imgView, new PicassoCallback(() =>
    {
        //Success
    }, () =>
    {
        //Error
    });
    

    Just use the override and don't go through all the trouble of creating an extra class just for the same outcome.

  • flint666flint666 Member

    An absolutely essential thing...... Thanks !!!

  • flint666flint666 Member

    An absolutely essential thing...... Thanks !!!

  • prabeshprabesh Member ✭✭

    @cwphilli said:
    I actually really like Akavache
    I use it for all my mobile caching needs including it's built in image request / caching.

    Hi, I read the read me document for Akavache at github and could see that it has not got its full documentation there. Could you please point any proper implementation of Akavache for Xamarin.Android/IOS. I would like to use it for image cacheing and also for cacheing objects received via http requests for certain amount of time. Thank you

  • brayanalarconzamorabrayanalarconzamora USMember ✭✭
    edited May 2019

    help

    please code in c# :( !!!!

    Glide.with(this)
    .load(GlideActivityA.FOX_PIC_URL)
    .centerCrop()
    .dontAnimate()
    .listener(new RequestListener<String, GlideDrawable>() {
    @Override
    public boolean onException(Exception e, String model, Target target, boolean isFirstResource) {
    supportStartPostponedEnterTransition();
    return false;
    }
    @Override
    public boolean onResourceReady(GlideDrawable resource, String model, Target target, boolean isFromMemoryCache, boolean isFirstResource) {
    supportStartPostponedEnterTransition();
    return false;
    }
    })
    .into(imageView);

Sign In or Register to comment.