G
G
gape2015-10-15 00:58:58
Java
gape, 2015-10-15 00:58:58

How to use Picasso to download pictures and cache them?

There is a custom view, you need to submit a bitmap to it, how to download it and cache it?
Trying like this

Picasso.with(this)
                .load(myURL)
                .into(new Target() {
                    @Override
                    public void onBitmapLoaded(final Bitmap bitmap, Picasso.LoadedFrom from) {
                        customView.setImage(bitmap); 
                    }
                });

Thus, it is downloaded, but when the application is restarted, it is downloaded again.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
z0rgoyok, 2015-10-15
@gape

https://gist.github.com/dkunzler/5636491

O
Oleg Gamega, 2015-10-15
@gadfi

if it is downloaded and without brakes, just check if there is such a picture on the disk;
if there is, load from the disk

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question