Search in sources :

Example 1 with AttachmentType

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);
    }
}
Also used : InvalidParameterException(java.security.InvalidParameterException) AttachmentType(ve.com.abicelis.remindy.enums.AttachmentType) TextAttachment(ve.com.abicelis.remindy.model.attachment.TextAttachment) LinkAttachment(ve.com.abicelis.remindy.model.attachment.LinkAttachment) AudioAttachment(ve.com.abicelis.remindy.model.attachment.AudioAttachment) ImageAttachment(ve.com.abicelis.remindy.model.attachment.ImageAttachment) ListAttachment(ve.com.abicelis.remindy.model.attachment.ListAttachment)

Aggregations

InvalidParameterException (java.security.InvalidParameterException)1 AttachmentType (ve.com.abicelis.remindy.enums.AttachmentType)1 AudioAttachment (ve.com.abicelis.remindy.model.attachment.AudioAttachment)1 ImageAttachment (ve.com.abicelis.remindy.model.attachment.ImageAttachment)1 LinkAttachment (ve.com.abicelis.remindy.model.attachment.LinkAttachment)1 ListAttachment (ve.com.abicelis.remindy.model.attachment.ListAttachment)1 TextAttachment (ve.com.abicelis.remindy.model.attachment.TextAttachment)1