Rewind button with picasso

Viewed 41

I am making an application that generates a random image by a url when touching the button and presents it in the imageview and I use picasso and to change the image you have to clear the cache and I would like someone to tell me how I could go back to the previous image, like a back button

Any help is appreciated from the heart

My code to generate a new image:

nextButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String quest1 = "https://proxxcraft.com/";
                Picasso.get().load(quest1).memoryPolicy(MemoryPolicy.NO_CACHE).into(memeRandomView);
                Picasso.get().isLoggingEnabled();
              
            }
        });
1 Answers

you should save the image as a bitmap, save it in an array or some other data structure. I know how to do it with glide but you should check for how to set callbacks to know when the image is loaded.

private void loadImage() {
        Picasso.with(this)
                .load("https://proxxcraft.com/")
                .into(mContentTarget);
      }


private Target mContentTarget = new Target() {
    @Override
    public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
     //save the bitmap in an array so you can use it later.
     Imageview.setImageBitmap(bitmap);
    }

    @Override
    public void onBitmapFailed(Drawable errorDrawable) {
    }

    @Override
    public void onPrepareLoad(Drawable placeHolderDrawable) {
    }
};
Related