-
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
Allowing to force the loading of the image on targets even if the same m... #39
Conversation
…e model has been loaded on the same target before
You should be able to get the same affect by calling Glide.clear(youImageView) right before you call Glide.load. Maybe this really implies that we should call the request listener synchronously if you try to load an image into a target that is already displaying that image? |
Sounds good. The only subtle point is that we need the listeners to be called even if the initial call failed to load. Basically, any time I call Glide.into, I should receive a callback no matter what. To keep the API cleaner, it might be good to specify a third callback like onImageAlreadyLoaded or something but still call the error callback if it fails to load again (either from any cache or the network). |
Also, I think you meant I should call Glide.cancel. Am I right? I can't see a clear method on Glide |
This, by the way, won't work for me since I am loading into a custom subclass on imageviewtarget, an instance I no longer have a reference to when I want to reload an image |
Yes I meant Glide#cancel, not clear. I was also incorrect in my previous post about the custom subclass. You can and probably should be using a subclass of ImageViewTarget. However I was incorrect to say that you could pass in a new instance of your target subclass for each call to load. Instead you need to create and retain a single target per image view. If you pass in an ImageView directly, Glide will do this for you by calling ImageView#setTag. Otherwise it's up to you to retain the target in a non-static way. The simplest thing to do is also to call setTarget if you're loading into a view, or if you're using the viewholder pattern, to add your target to your viewholder. You could also subclass the view directly and implement the interface in that subclass, although I think that's a bit uglier. The fundamental problem is that we need to be able to retrieve information about the previous load when a new load starts so that we can do things like reuse bitmaps. Sorry for the confusion! |
If we subclass Also can we have a method/way to |
@deathlord87 Please open a new issue for the cancelAll method and feel free to throw up some code, I think that would be relatively straight forward. |
For closure, in the 3.0 branch you can use a request listener which will be notified every time a load completes regardless of the source. Since that's fixed there, I'm going to close this. Thanks for reporting the issue and sorry it's taken so long to get it fixed. |
...odel has been loaded on the same target before
This allows the listeners to be called every time you call load into on a target. We need this for our adapter views where Glide would not even try to load the image if it was the same but we needed the callbacks to happen