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?
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?
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