How to save images with Glide?

0

I program a gallery in android with the glide library but the images are only shown, when I leave the screen prefered, it does not give me the option of saving the images, how does it work?

    
asked by user21032 03.11.2016 в 20:25
source

1 answer

0

You can use a SimpleTarget through which Glide will provide you with a Bitmap and then store it as if it were any other image:

 Glide.load("http://somefakeurl.com/fakeImage.jpeg")
  .asBitmap()
  .fitCenter()
  .into(new SimpleTarget(250, 250) {

      @Override
      public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {
            File file = new File("your/desired/file/path");
            OutputStream os = new FileOutputStream(file);
            resource.compress(Bitmap.CompressFormat.JPEG, 100, os);
      }

  });

}

I have not tried the code but it should not be very different from the final version.

More information at: link

    
answered by 04.11.2016 в 18:09