Thread thread = new Thread(new Runnable() {
@Override
public void run() {
Map data = new HashMap();
List fileList = new ArrayList<>();
for (int i = 1; i < adapter.getCount(); ++i) {
try {
String path = ((CustomGallery)adapter.getItem(i)).sdcardPath;
String filename = getFileName(path);
Bitmap bitmap = BitmapFactory.decodeFile(path);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BitmapUtils.compressImage(bitmap, baos);
AVFile avFile = new AVFile(filename,baos.toByteArray());
avFile.save();
AVObject fileObj =AVObject.createWithoutData("_FIle", avFile.getObjectId());
fileList.add(fileObj);
} catch (AVException e) {
e.printStackTrace();
}
}
data.put("text", mEditText.getText().toString());
data.put("longitude", mapLocation.getLongitude());
data.put("latitude", mapLocation.getLatitude());
data.put("locationText", mapLocation.getProvince() + mapLocation.getCity());
data.put("images", fileList);
AVStatus status = AVStatus.createStatusWithData(data);
status.setQuery(AVUser.getQuery());
status.setInboxType("public");