use of org.matrix.androidsdk.data.RoomSummary in project matrix-android-sdk by matrix-org.
the class MXFileStore method saveSummaries.
/**
* Flush the pending summaries.
*/
private void saveSummaries() {
if ((mRoomsToCommitForSummaries.size() > 0) && (null != mFileStoreHandler)) {
// get the list
final HashSet<String> fRoomsToCommitForSummaries = mRoomsToCommitForSummaries;
mRoomsToCommitForSummaries = new HashSet<>();
Runnable r = new Runnable() {
@Override
public void run() {
mFileStoreHandler.post(new Runnable() {
public void run() {
if (!isKilled()) {
long start = System.currentTimeMillis();
for (String roomId : fRoomsToCommitForSummaries) {
try {
File roomSummaryFile = new File(mStoreRoomsSummaryFolderFile, roomId);
RoomSummary roomSummary = mRoomSummaries.get(roomId);
if (null != roomSummary) {
writeObject("saveSummaries " + roomId, roomSummaryFile, roomSummary);
} else {
deleteRoomSummaryFile(roomId);
}
} catch (OutOfMemoryError oom) {
dispatchOOM(oom);
} catch (Exception e) {
Log.e(LOG_TAG, "saveSummaries failed : " + e.getMessage());
// Toast.makeText(mContext, "saveSummaries failed " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
}
}
Log.d(LOG_TAG, "saveSummaries : " + fRoomsToCommitForSummaries.size() + " summaries in " + (System.currentTimeMillis() - start) + " ms");
}
}
});
}
};
Thread t = new Thread(r);
t.start();
}
}
Aggregations