I want to start several threads, retrive data from net, perform some actions with it and then change UI regarding this data.
I’m using executor service
executorService = Executors.newFixedThreadPool(3);
all the data get, but when i try to invoke imageView.post it returns true but body of regarding Runnable is not executed:
Log.v("imageloader", "before post + " + imageView);
imageView.post(new Runnable()
{
@Override
public void run()
{
Log.v("imageloader", "in post - " + bmpToShow.toString() + "/" + imageView);
if (imageView.getTag().equals(url))
{
imageView.setImageBitmap(bmpToShow);
}
}
});
If execute 10 Runnables in this executor service in log you can find 10 “before post” messages, but only nTasks (depends on how many task you allow in “Executors.newFixedThreadPool(nTasks)”) “in post” messages
I can’t figure out how nTasks connects with number of view.post runs.
PS. it happens only with first start of the app (i use android fragments and fill data in onCreateView)
wow, the problem was in some cases (i dont know on what it depends) code in ImageView.post was not performed (maybe this view was not created yet), i changed Imageview.post() on runOnUiThread() and everything works now.