use of org.thoughtcrime.securesms.attachments.DatabaseAttachment in project Signal-Android by WhisperSystems.
the class AttachmentDatabase method getAttachmentsForMessages.
@NonNull
public Map<Long, List<DatabaseAttachment>> getAttachmentsForMessages(@NonNull Collection<Long> mmsIds) {
if (mmsIds.isEmpty()) {
return Collections.emptyMap();
}
SQLiteDatabase database = databaseHelper.getSignalReadableDatabase();
SqlUtil.Query query = SqlUtil.buildCollectionQuery(MMS_ID, mmsIds);
Map<Long, List<DatabaseAttachment>> output = new HashMap<>();
try (Cursor cursor = database.query(TABLE_NAME, PROJECTION, query.getWhere(), query.getWhereArgs(), null, null, UNIQUE_ID + " ASC, " + ROW_ID + " ASC")) {
while (cursor.moveToNext()) {
DatabaseAttachment attachment = getAttachment(cursor);
List<DatabaseAttachment> attachments = output.get(attachment.getMmsId());
if (attachments == null) {
attachments = new LinkedList<>();
output.put(attachment.getMmsId(), attachments);
}
attachments.add(attachment);
}
}
return output;
}
Aggregations