Custom Target sometimes work,sometime doesn't
See original GitHub issueThis is my scenario
// on FragmentActivity Class
Picasso picasso = Picasso.with(this);
String[] imageUrls = {
"http://digital-photography-school.com/wp-content/uploads/2013/03/Acorn256.png",
"http://stereo-ssc.nascom.nasa.gov/beacon/latest_256/behind_euvi_195_latest.jpg",
"http://littleblackapp.blob.core.windows.net/product3071/img10020_0.png" };
private void initLoadImages() {
for (int i = 0; i < imageUrls.length; i++) {
String imageUrl = imageUrls[i];
picasso.getSnapshot().dump();
CustomTarget target = new CustomTarget(imageView, progressBar,
index);
picasso.load(imageUrl).into(target);
}
}
// this class is within the Activity class
public class CustomTarget implements Target {
public ImageView imageView;
public ProgressBar progressBar;
public CustomTarget(ImageView imageView, ProgressBar progressBar,
int position) {
this.imageView = imageView;
this.progressBar = progressBar;
}
@Override
public void onBitmapLoaded(final Bitmap bitmap, LoadedFrom from) {
Log.i("bitmap loaded", "bitmap loaded");
imageView.setImageBitmap(bitmap);
}
@Override
public void onBitmapFailed() {
}
}
The custom target for first image will be always called but for other images it will be sometimes called and sometimes doesn’t. Have I implemented it in wrong way or am I missing something. I have used latest Picasso along with okHttp 1.2.1.
Issue Analytics
- State:
- Created 10 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Once = true attribute for Targets to allow target only executed ...
MSBuild is project oriented and within a project a target will only run once. Having a Once attribute on Target doesn't make sense....
Read more >Event listeners not working? 3 key areas to troubleshoot
Events are dispatched by specific elements (their target ). Code can then add listeners to run custom logic in response. But it's not...
Read more >How to modify environment variables passed to custom ...
A portable way of setting environment variables for a custom target is to use CMake's command-line tool mode command env :.
Read more >target_sources() doesn't recognise GENERATED property for ...
When a target in another directory references it there is no GENERATED mark in the other directory. Some non-trivial refactoring and likely a ......
Read more >4 Reasons Your Facebook Ads Don't Convert (and How to Fix ...
One of the main reasons marketers fail with Facebook Ads is because they fail to target their ads properly. Facebook allows you to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

You need to hold a strong reference to targets yourself.
after this line
targethas nothing referencing it so it will be garbaged collected.@hakimrie : Thanks for mentioning. I have updated the variable index now