I am currently programming in Android Studio, using Picasso library to load pictures as a background
Now is the problem, most of the times it does work. Picasso loads the picture and then set it as background. But sometimes it will show a blank background.
This is the code i use:
Picasso.with(getContext()).load(picurl).into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
Drawable d = new BitmapDrawable(getResources(), bitmap);
rl.setBackground(d);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
How can i take care of my code to make it show background 100% of the times instead of 50%?
I placed the Picasso method in the onCreate() method of my fragment.
I also used the Picasso logging and this is what i got:
D/Picasso: Main canceled [R1]+81ms target got garbage collected
D/Picasso: Hunter decoded [R1]+123ms
D/Picasso: Dispatcher batched [R1]+123ms for completion
D/Picasso: Dispatcher delivered [R1]+325ms
D/Picasso: Main completed [R1]+325ms from DISK
It is telling me that it loaded and completed the picture. but it is still not being shown as my background.