In the step of uploading pictures, how to deal with the time-consuming method of saving the selected pictures locally?

  android, question
for (int i=0;  i<paths.size();  I plus)
 Bitmap bitmap = ImageCompressUtil.compressBySize(paths.get(i), 1000, 1000);
 Image tools. savehototosdcard (bitmap, constants.myavatardir, i plus "");
 Newpaths.add (constants.myavatarddir plus i plus ".jpg");
 bracket

The code is as above. paths is a list of selected picture addresses. Now I traverse it, compress it, name it with numbers 1, 2 and 3, and store it locally. After storing the compressed address in newpaths, I pass it to adapter for display.

Now there is a problem. Before the selected picture can be stored locally, the picture originally named after the numbers 1, 2 and 3 is passed into the adapter, so the picture displayed is the last saved picture.

My solution is to delay the transmission to adapter for 500 ms. Obviously, this is not the best method. I hope the great gods can provide a more perfect solution.

This depends on where you setAdapter and notifyDataSetChanged. if you are in a different thread from the above code block, your situation may occur. it should be to adjust the adapter refresh method after the above code block is executed. this should be ensured.