ArMo 372 ArMo 372 - 3 months ago 15
Android Question

notifyItemInserted in runOnUiThread not work

For me,

notifyItemInserted
in
runOnUiThread
does not work.
I have
runOnUiThread
in
asyncTask
after download each file:

ImageModel imageModel = new ImageModel();
imageModel.setName("تصویر " );
imageModel.setUrl(aFile.getName());
imageModel.ImageFile = localFile;
data.add(imageModel);
runOnUiThread(new Runnable() {
@Override
public void run() {
mAdapter.notifyItemInserted(data.size() - 1);
}
});

Ben Ben
Answer

Not a direct answer to why it isn't working but I would recommend calling publishProgress() and then in onProgressUpdate() in your asynctask put your adapter call without the runOnUiThread.

Comments