use of ve.com.abicelis.remindy.enums.AttachmentType in project Remindy by abicelis.
the class RemindyDAO method getAttachmentFromCursor.
private Attachment getAttachmentFromCursor(Cursor cursor) {
int id = cursor.getInt(cursor.getColumnIndex(RemindyContract.AttachmentTable._ID));
int reminderId = cursor.getInt(cursor.getColumnIndex(RemindyContract.AttachmentTable.COLUMN_NAME_TASK_FK.getName()));
AttachmentType attachmentType = AttachmentType.valueOf(cursor.getString(cursor.getColumnIndex(RemindyContract.AttachmentTable.COLUMN_NAME_TYPE.getName())));
String textContent = cursor.getString(cursor.getColumnIndex(RemindyContract.AttachmentTable.COLUMN_NAME_CONTENT_TEXT.getName()));
byte[] blobContent = cursor.getBlob(cursor.getColumnIndex(RemindyContract.AttachmentTable.COLUMN_NAME_CONTENT_BLOB.getName()));
switch(attachmentType) {
case AUDIO:
return new AudioAttachment(id, reminderId, textContent);
case IMAGE:
return new ImageAttachment(id, reminderId, blobContent, textContent);
case TEXT:
return new TextAttachment(id, reminderId, textContent);
case LINK:
return new LinkAttachment(id, reminderId, textContent);
case LIST:
return new ListAttachment(id, reminderId, textContent);
default:
throw new InvalidParameterException("AttachmentType is invalid. Value = " + attachmentType);
}
}
Aggregations