Skip to content

Is that downloadOnly not cache the image? #839

Closed
@ghost

Description

I have two activities named AActivity and BActivity, I want to cache a picture but not show it in the AActivity, then when it turns to BActivity, I hope it should show from the cache, I try to use the downloadOnly to cache the image:

Glide.with(context).load(url).downloadOnly(620, 400);

In the BActivity I use the code

Glide.with(this).load(url).into(imageview);

to load the image.

But it seems not cache the image while in the BActivity it will load the image from net again.

I just want to cache the picture, and not showing it, how can I do?

Activity

TWiStErRob

TWiStErRob commented on Dec 25, 2015

@TWiStErRob
Collaborator

You need to tell Glide in activity B that it can use the SOURCE cache (default is RESULT): .diskCacheStrategy(ALL).

Note that downloadOnly's arguments are not used to resize the image, only the original is cached. If you want to pre-cache the resized one use the following in activity A:

.diskCacheStrategy(ALL).fitCenter().preload(620, 400)

The transformation and size must match the ImageView's in activity B.

ghost

ghost commented on Dec 25, 2015

@ghost

@TWiStErRob Thanks, it's ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @TWiStErRob

        Issue actions

          Is that downloadOnly not cache the image? · Issue #839 · bumptech/glide