-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Target.onBitmapLoaded() method not called the first time after completed (network) request. #352
Comments
Your Target is being garbage collected. Implement it on an object or store it in a field. If all you want is a callback, there's a two argument version for loading into an ImageView. |
Given the number of people (myself included the first time I used a Target) who make this mistake, wouldn't it be wiser to add some sort of "bigger" warning? |
Same here. |
Same here what? Are you using an anonymous class for target? |
I have the same problem, i my case Picasso is fired from an IntentService, now what i did was create a class which extends from Target and add some useful parameters to process the loaded bitmap, but onBitmapLoaded() is not called. hope someone can help. thanks.
|
You are not keeping a reference to the created ImgTarget and it is being
|
@JakeWharton Well, probably my approach is wrong but due i need to download an image list, this is how i get images. but target objects are still GC'd. Thanks.
|
@lukasz1 : Finally found solution here:- http://www.opensourcealternative.org/tutorials/android-tutorials/android-picasso-save-image-tutorial/ |
I am having the same problem.
onBitmapLoaded is only called once in the app life of install of the device. after that, this method is not longer calling. Can you please advice. thank you |
I'm having the same problem, only I use Picasso from inside a class that extends ImageView. I even save a reference to the callback I'm given, just in case, to no avail.
|
Adding a tag seems to fix this problem, here's my code, the setTag corrected that issues that you are having above:-
|
Adding a tag work for this problem |
I have string array = {url1,url2,url3}; |
Hi In my case, I am using databinding library and calling the picasso loader from custom bindingAdapter, where i am receiving the layout and image location(internal storage location) in the adapter. I have used "target" for loading the image into the background of the layout. As picasso keeps a weak reference to the target, i have created a custom layout of that layout and extended the "target" there, implemented reference methods of target -> The problem is : "onPrepareLoad" and "onBitmapFailed" methods are called but the "onBitmapLoaded" method is not getting called. for loading background image with picasso, i am following this link : ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| xml code : <com.myproject.testapp.test.createprofile.view.CustomLayoutUploadImage Binding Adapter Class: public class BindingAdapterClass {
@BindingAdapter({"bind:setBackGroundImage","bind:setBackGroundColor", "bind:setCurrentState"})
Custom Layout Class: public class CustomLayoutUploadImage extends android.support.constraint.ConstraintLayout implements Target {
} view model class : public class CreateProfileViewModel extends BaseObservable{
........................ @bindable
public void setEditImageVisibility(boolean editImageVisibility) { |
@JakeWharton but why garbage collects it? I can use something like this in Glide library (that's the requestListener in glide) and that will not be garbage collected. So that's a library problem? |
This isn't Glide and you cannot assume behavior is consistent across the
libraries.
…On Tue, Feb 19, 2019, 3:52 AM Hayko985 ***@***.*** wrote:
@JakeWharton <https://github.com/JakeWharton> but why garbage collects
it? I can use something like this in Glide library (that's the
requestListener in glide) and that will not be garbage collected. So that's
a library problem?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#352 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAEEETdbsryOp38fTN0LclHqd84yun8Uks5vO7s1gaJpZM4BXoHo>
.
|
@JakeWharton So why the garbage collector collects it? |
onBitmapLoaded() is not called immediately after fetching has been completed. But when I load the image second time (which I suppose is already cached) the method is indeed called.
The code I use:
Picasso version: 2.1.1
The text was updated successfully, but these errors were encountered: