0

I'm using MaterialDrawer library and loading profile images with Picasso. But I am unable to save it locally with Picasso and loading it from cache in the future.

Before creating the drawer,

 //below line is for loading profile image from url
    DrawerImageLoader.init(new DrawerImageLoader.IDrawerImageLoader() {
        @Override
        public void set(ImageView imageView, Uri uri, Drawable placeholder) {
            Picasso.with(imageView.getContext()).load(uri).placeholder(placeholder).into(imageView);
        }

        @Override
        public void cancel(ImageView imageView) {
            Picasso.with(imageView.getContext()).cancelRequest(imageView);
        }

        @Override
        public Drawable placeholder(Context ctx) {
            return null;
        }

    });

I wrote this as material library says. Then I set my profile picture:

String myURL = "http://www.american.edu/uploads/profiles/large/chris_palmer_profile_11.jpg" profile = new ProfileDrawerItem().withName(person.getFullName()).withEmail(person.getStMajorName()).withIcon(myURL)

But everytime I run the app, it loads it from the internet.

How can I cache the image?

mikepenz
  • 12,708
  • 14
  • 77
  • 117
Kerem
  • 1,494
  • 2
  • 16
  • 27
  • How do you know its loading from the internet everytime? – Eoin Aug 20 '15 at 10:51
  • Normally Picasso takes care about caching and everything. And the MaterialDrawer does not modify this behavior. Are your sure caching does not work? Else try Glide? – mikepenz Sep 12 '15 at 19:53

1 Answers1

1

By default Picasso comes with a default implementation which are suitable for most usecases.

There are various solutions which allow you to force Picasso to load the images from the cache. Or to change this behavior.

You should check out the following StackOverFlow question which come with different solutions to your issue:

How do I use disk caching in Picasso?

Community
  • 1
  • 1
mikepenz
  • 12,708
  • 14
  • 77
  • 117