abbasalim
abbasalim

Reputation: 3232

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);
       }
  });

Upvotes: 0

Views: 413

Answers (1)

Ben
Ben

Reputation: 1295

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.

Upvotes: 1

Related Questions