-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] Is this the best way to download an image to share? #3399
Comments
This issue has been automatically marked as stale because it has not had activity in the last seven days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions. |
You can still load the requested image as a byte[] with For SimpleTarget, see: #3304 |
Can't seem to get that to work in Kotlin any idea on what the syntax would be? Also in onResourceReady is this the right way to clean things up / necessary:
I want to basically do what @TWiStErRob is doing here using Glide v4 and Kotlin : #1424 (comment) but can't for the life of me figure out if it's still possible and what the syntax would be. |
Not tested, but I think the v4 version of that issue comment is: Glide.with(context)
.as(byte[].class)
.load(url)
.apply(new RequestOptions()
.override(MAX_IMAGE_SIZE, MAX_IMAGE_SIZE)
.diskCacheStrategy(DiskCacheStrategy.DATA)
.skipMemoryCache(true)
.downsample(DownsampleStrategy.AT_MOST))
.into(new SimpleTarget<byte[]>() {
@Override public void onResourceReady(byte[] resource, GlideAnimation<? super byte[]> ignore
{
new SaveAsFileTask().execute(resource);
}
@Override public void onLoadFailed(Exception ex, Drawable ignore) {
toastUser("Whops, can't load " + link);
}
@Override public void onLoadCleared(Drawable ignored) {
// Assert that SaveAsFileTask is cancelled and won't run, or already finished...
}
}) |
This issue has been automatically marked as stale because it has not had activity in the last seven days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions. |
Glide Version: 4.8.0
Integration libraries:OkHttp3 3.10.0
Issue details / Repro steps / Use case background:
I'm implementing a "Share photo" feature in my app, but I'm having trouble figuring out the "right" / most efficient way to do it with Glide v4. Basically if a user selects a scaled down "preview" image (view) and hits share, I want to give glide a URL, download the fullsize image contents, save it out to the cacheDir, and put it in a sharing intent. I've seen older examples (v3) with toBytes() and other things that seem more efficient than what I am doing, but I don't see how to do this with v4 - also SimpleTraget is warning me about being deprecated. Basically my question is what is the best way to do this and make sure I clean things up when I'm done with the bitmap / request?
The text was updated successfully, but these errors were encountered: