Search in sources :

Example 1 with TextAttachment

use of ve.com.abicelis.remindy.model.attachment.TextAttachment 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)

Example 2 with TextAttachment

use of ve.com.abicelis.remindy.model.attachment.TextAttachment in project Remindy by abicelis.

the class AttachmentAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    Attachment current = mAttachments.get(position);
    switch(current.getType()) {
        case TEXT:
            TextAttachmentViewHolder tvh = (TextAttachmentViewHolder) holder;
            tvh.setData(this, mActivity, (TextAttachment) current, position, mRealTimeDataPersistence);
            tvh.setListeners();
            break;
        case LIST:
            ListAttachmentViewHolder listvh = (ListAttachmentViewHolder) holder;
            listvh.setData(this, mActivity, (ListAttachment) current, position, mRealTimeDataPersistence);
            listvh.setListeners();
            break;
        case LINK:
            LinkAttachmentViewHolder lvh = (LinkAttachmentViewHolder) holder;
            lvh.setData(this, mActivity, (LinkAttachment) current, position, mRealTimeDataPersistence);
            lvh.setListeners();
            break;
        case AUDIO:
            AudioAttachmentViewHolder avh = (AudioAttachmentViewHolder) holder;
            avh.setData(this, mActivity, (AudioAttachment) current, position, mRealTimeDataPersistence);
            //avh.setListeners();
            break;
        case IMAGE:
            ImageAttachmentViewHolder ivh = (ImageAttachmentViewHolder) holder;
            ivh.setData(this, mActivity, (ImageAttachment) current, position, mRealTimeDataPersistence);
            ivh.setListeners();
            break;
        default:
            throw new InvalidParameterException("Wrong viewType passed to onCreateViewHolder in AttachmentAdapter");
    }
}
Also used : LinkAttachmentViewHolder(ve.com.abicelis.remindy.app.holders.LinkAttachmentViewHolder) InvalidParameterException(java.security.InvalidParameterException) ImageAttachmentViewHolder(ve.com.abicelis.remindy.app.holders.ImageAttachmentViewHolder) ListAttachmentViewHolder(ve.com.abicelis.remindy.app.holders.ListAttachmentViewHolder) Attachment(ve.com.abicelis.remindy.model.attachment.Attachment) LinkAttachment(ve.com.abicelis.remindy.model.attachment.LinkAttachment) ListAttachment(ve.com.abicelis.remindy.model.attachment.ListAttachment) AudioAttachment(ve.com.abicelis.remindy.model.attachment.AudioAttachment) TextAttachment(ve.com.abicelis.remindy.model.attachment.TextAttachment) ImageAttachment(ve.com.abicelis.remindy.model.attachment.ImageAttachment) AudioAttachmentViewHolder(ve.com.abicelis.remindy.app.holders.AudioAttachmentViewHolder) TextAttachmentViewHolder(ve.com.abicelis.remindy.app.holders.TextAttachmentViewHolder)

Example 3 with TextAttachment

use of ve.com.abicelis.remindy.model.attachment.TextAttachment in project Remindy by abicelis.

the class TaskFragment method onClick.

@Override
public void onClick(View v) {
    int id = v.getId();
    mAttachmentsFabMenu.close(true);
    if (!mHeadersVisible) {
        fadeInHeaders();
        mHeadersVisible = true;
    }
    switch(id) {
        case R.id.fragment_task_add_list_attachment:
            addAttachment(new ListAttachment());
            break;
        case R.id.fragment_task_add_text_attachment:
            addAttachment(new TextAttachment(""));
            break;
        case R.id.fragment_task_add_link_attachment:
            addAttachment(new LinkAttachment(""));
            break;
        case R.id.fragment_task_add_image_attachment:
            addAttachment(new ImageAttachment());
            break;
        case R.id.fragment_task_add_audio_attachment:
            addAttachment(new AudioAttachment());
            break;
    }
    //Scroll to added item
    if (mAdapter.getItemCount() > 0)
        mRecyclerView.smoothScrollToPosition(mAdapter.getItemCount() - 1);
}
Also used : TextAttachment(ve.com.abicelis.remindy.model.attachment.TextAttachment) LinkAttachment(ve.com.abicelis.remindy.model.attachment.LinkAttachment) AudioAttachment(ve.com.abicelis.remindy.model.attachment.AudioAttachment) ListAttachment(ve.com.abicelis.remindy.model.attachment.ListAttachment) ImageAttachment(ve.com.abicelis.remindy.model.attachment.ImageAttachment)

Example 4 with TextAttachment

use of ve.com.abicelis.remindy.model.attachment.TextAttachment in project Remindy by abicelis.

the class TaskDetailActivity method onClick.

@Override
public void onClick(View v) {
    int id = v.getId();
    mAttachmentsFabMenu.close(true);
    switch(id) {
        case R.id.activity_task_detail_add_list_attachment:
            addAttachment(new ListAttachment());
            break;
        case R.id.activity_task_detail_add_text_attachment:
            addAttachment(new TextAttachment(""));
            break;
        case R.id.activity_task_detail_add_link_attachment:
            addAttachment(new LinkAttachment(""));
            break;
        case R.id.activity_task_detail_add_image_attachment:
            addAttachment(new ImageAttachment());
            break;
        case R.id.activity_task_detail_add_audio_attachment:
            addAttachment(new AudioAttachment());
            break;
        case R.id.activity_task_detail_done_button:
            if (mTask.getDoneDate() == null) {
                mTask.setDoneDate(CalendarUtil.getNewInstanceZeroedCalendar());
                mTask.setStatus(TaskStatus.DONE);
            } else {
                mTask.setDoneDate(null);
                mTask.setStatus((mTask.getReminderType() == ReminderType.NONE ? TaskStatus.UNPROGRAMMED : TaskStatus.PROGRAMMED));
            }
            mTaskDataUpdated = true;
            //Force a TASK_DETAIL_RETURN_ACTION_EDITED_REMINDER state.
            mOldReminderJson = "!";
            setUpDoneOrOverdue();
            break;
    }
    //Scroll to added item
    if (mAdapter != null && mAdapter.getItemCount() > 0)
        mRecyclerView.smoothScrollToPosition(mAdapter.getItemCount() - 1);
}
Also used : TextAttachment(ve.com.abicelis.remindy.model.attachment.TextAttachment) LinkAttachment(ve.com.abicelis.remindy.model.attachment.LinkAttachment) AudioAttachment(ve.com.abicelis.remindy.model.attachment.AudioAttachment) ListAttachment(ve.com.abicelis.remindy.model.attachment.ListAttachment) ImageAttachment(ve.com.abicelis.remindy.model.attachment.ImageAttachment)

Aggregations

AudioAttachment (ve.com.abicelis.remindy.model.attachment.AudioAttachment)4 ImageAttachment (ve.com.abicelis.remindy.model.attachment.ImageAttachment)4 LinkAttachment (ve.com.abicelis.remindy.model.attachment.LinkAttachment)4 ListAttachment (ve.com.abicelis.remindy.model.attachment.ListAttachment)4 TextAttachment (ve.com.abicelis.remindy.model.attachment.TextAttachment)4 InvalidParameterException (java.security.InvalidParameterException)2 AudioAttachmentViewHolder (ve.com.abicelis.remindy.app.holders.AudioAttachmentViewHolder)1 ImageAttachmentViewHolder (ve.com.abicelis.remindy.app.holders.ImageAttachmentViewHolder)1 LinkAttachmentViewHolder (ve.com.abicelis.remindy.app.holders.LinkAttachmentViewHolder)1 ListAttachmentViewHolder (ve.com.abicelis.remindy.app.holders.ListAttachmentViewHolder)1 TextAttachmentViewHolder (ve.com.abicelis.remindy.app.holders.TextAttachmentViewHolder)1 AttachmentType (ve.com.abicelis.remindy.enums.AttachmentType)1 Attachment (ve.com.abicelis.remindy.model.attachment.Attachment)1