-
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
How to clear cache #624
Comments
|
"Clear cache of an URL". |
Yep, then .load(profile.imageUrl)
.signature(new StringSignature(profile.imageLastUpdate)) |
Thanks for you support. |
Options:
|
you also need to reload the image using the usual |
I already used cleardiskcache but image was not refreshed.
Then :
But no luck |
Do you use an integration library? |
I'm not sure what is "integration library"
for import library. I'm new to Glide :D |
https://github.com/bumptech/glide/wiki/Integration-Libraries |
private class UploadImageAsyncTask extends AsyncTask {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Boolean doInBackground(Void... voids) {
boolean isSuccess = upload api;
if (isSuccess) {
Glide.get(getActivity()).clearDiskCache();
Glide.get(getActivity()).clearMemory();
}
return isSuccess;
}
@Override
protected void onPostExecute(Boolean aBoolean) {
super.onPostExecute(aBoolean);
if (aBoolean) {
// Url
Glide.with(fragment).load(strCoverUrl).dontAnimate().placeholder(R.drawable.img_splash_bg).into(imvCover);
}
}
} Sure load image after clear cache. |
How do you load it normally when you first show the fragment? |
How do you load it normally when you first show the fragment?
Also the line is commented out, I hope it's not like that in your running code ;) |
Hmm, maybe Glide checks if the new load is any different than the currently loaded image and ignores the new one if the same. I can't back this up with code though. You could try calling Drawable oldImage = imvCover.getDrawable(); // may be unsafe
Glide.clear(imvCover); // force Glide to forget about anything related to this view
Glide.with(fragment).load(strCoverUrl).dontAnimate().placeholder(oldImage).into(imvCover); Before you try this I suggest you add Sorry for the hacky workarounds, I can't come up with other ideas yet. |
Thanks for your help. |
Debugged @Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target,
boolean isFromMemoryCache, boolean isFirstResource) {
return false;
} and saw that: |
Let's invoke @sjudd! |
Is the resource you're about to reload already being displayed in a If you want to change the user's profile picture and reload it, either change the url when the the profile picture changes, or use the |
@sjudd : Thanks for your suggestion, I solved it my problem with .signature. |
It's not loaded from disk or memory cache, it's loaded from active resources, which are the images currently showing in views. Since nothing has changed according to Glide (i.e. cache key) it assumes that the current image is the same as what you're loading. Clearing the cache is a brute force method which is not advised, especially because only one image changed. Using |
Yup, signature is a much better solution. Let us know if you have any other questions. |
Hello, |
I think that should use clearMemory() and clearDiskCache() together ...... |
@kimgod can you please elaborate on that? What are you responding to? |
However I use |
ok solved ,:) i put pth of image as signature at the end 👍 at the time of change image(gallery intent) i store path of image in sharedprefs and using sharedpref everywhere i want to update image , it will download image once after image updated as like profile picture and then will use cache instead load everytime as the problem in system.currenttimemillis i dont know is it proper approach but dont find any solution for cache SharedPreferences prefs =getActivity().getSharedPreferences("your_prefs", Activity.MODE_PRIVATE);
//get the path of image u selected in gallery intent , in string from shared prefs in the onactivityresult and done |
I met the same problem and got the answers from the comments. Thank you 👍 Glide.with(context).load(Uri.parse(userProfile.getProfileImageUri()))
.signature(new StringSignature(Long.toString(System.currentTimeMillis()))).centerCrop()
.into(profileImageImageView); |
@amazingguni that's not right... whatever your goal is. Any time you load the image it'll be cached in a separate file using a lot of network, CPU and disk space. It essentially turns off caching, you should use |
I'll try to use |
where's StringSignature? |
Hi,
How can I clear Glide's cache in case.
The text was updated successfully, but these errors were encountered: