Search in sources :

Example 1 with ImageAttachmentViewHolder

use of ve.com.abicelis.remindy.app.holders.ImageAttachmentViewHolder in project Remindy by abicelis.

the class TaskActivity method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    //This request comes from ImageAttachmentViewHolder calling startActivityForResult() on EditImageAttachmentActivity
    if (requestCode == EditImageAttachmentActivity.EDIT_IMAGE_ATTACHMENT_REQUEST_CODE && resultCode == RESULT_OK) {
        int position = data.getIntExtra(EditImageAttachmentActivity.HOLDER_POSITION_EXTRA, -1);
        ImageAttachment imageAttachment = (ImageAttachment) data.getSerializableExtra(EditImageAttachmentActivity.IMAGE_ATTACHMENT_EXTRA);
        if (position != -1) {
            TaskFragment taskFragment = (TaskFragment) mTaskViewPagerAdapter.getRegisteredFragment(0);
            ImageAttachmentViewHolder holder = (ImageAttachmentViewHolder) taskFragment.mRecyclerView.findViewHolderForAdapterPosition(position);
            holder.updateImageAttachment(imageAttachment);
        }
    }
    //This request comes from ImageAttachmentViewHolder calling startActivityForResult() on ViewImageAttachmentActivity
    if (requestCode == ViewImageAttachmentActivity.VIEW_IMAGE_ATTACHMENT_REQUEST_CODE && resultCode == RESULT_OK) {
        int position = data.getIntExtra(ViewImageAttachmentActivity.HOLDER_POSITION_EXTRA, -1);
        ImageAttachment imageAttachment = (ImageAttachment) data.getSerializableExtra(ViewImageAttachmentActivity.IMAGE_ATTACHMENT_EXTRA);
        if (position != -1) {
            TaskFragment taskFragment = (TaskFragment) mTaskViewPagerAdapter.getRegisteredFragment(0);
            ImageAttachmentViewHolder holder = (ImageAttachmentViewHolder) taskFragment.mRecyclerView.findViewHolderForAdapterPosition(position);
            holder.updateImageAttachment(imageAttachment);
        }
    }
}
Also used : TaskFragment(ve.com.abicelis.remindy.app.fragments.TaskFragment) ImageAttachmentViewHolder(ve.com.abicelis.remindy.app.holders.ImageAttachmentViewHolder) ImageAttachment(ve.com.abicelis.remindy.model.attachment.ImageAttachment)

Example 2 with ImageAttachmentViewHolder

use of ve.com.abicelis.remindy.app.holders.ImageAttachmentViewHolder in project Remindy by abicelis.

the class TaskDetailActivity method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    //This request comes from ImageAttachmentViewHolder calling startActivityForResult() on EditImageAttachmentActivity
    if (requestCode == EditImageAttachmentActivity.EDIT_IMAGE_ATTACHMENT_REQUEST_CODE && resultCode == RESULT_OK) {
        int position = data.getIntExtra(EditImageAttachmentActivity.HOLDER_POSITION_EXTRA, -1);
        ImageAttachment imageAttachment = (ImageAttachment) data.getSerializableExtra(EditImageAttachmentActivity.IMAGE_ATTACHMENT_EXTRA);
        if (position != -1) {
            ImageAttachmentViewHolder holder = (ImageAttachmentViewHolder) mRecyclerView.findViewHolderForAdapterPosition(position);
            if (holder != null)
                holder.updateImageAttachment(imageAttachment);
        }
    }
    //This request comes from ImageAttachmentViewHolder calling startActivityForResult() on ViewImageAttachmentActivity
    if (requestCode == ViewImageAttachmentActivity.VIEW_IMAGE_ATTACHMENT_REQUEST_CODE && resultCode == RESULT_OK) {
        int position = data.getIntExtra(ViewImageAttachmentActivity.HOLDER_POSITION_EXTRA, -1);
        ImageAttachment imageAttachment = (ImageAttachment) data.getSerializableExtra(ViewImageAttachmentActivity.IMAGE_ATTACHMENT_EXTRA);
        if (position != -1) {
            ImageAttachmentViewHolder holder = (ImageAttachmentViewHolder) mRecyclerView.findViewHolderForAdapterPosition(position);
            if (holder != null)
                holder.updateImageAttachment(imageAttachment);
        }
    }
    //This request comes from TaskActivity, which was called from menu edit button
    if (requestCode == TaskActivity.TASK_ACTIVITY_REQUEST_CODE && resultCode == RESULT_OK) {
        //Task was edited
        mTaskDataUpdated = true;
        mTask = (Task) data.getSerializableExtra(TaskActivity.TASK_TO_EDIT);
        setUpViews();
        setUpDoneOrOverdue();
        setUpToolbar();
        setUpReminderViews();
        setUpRecyclerView();
    }
}
Also used : ImageAttachmentViewHolder(ve.com.abicelis.remindy.app.holders.ImageAttachmentViewHolder) ImageAttachment(ve.com.abicelis.remindy.model.attachment.ImageAttachment)

Example 3 with ImageAttachmentViewHolder

use of ve.com.abicelis.remindy.app.holders.ImageAttachmentViewHolder 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)

Aggregations

ImageAttachmentViewHolder (ve.com.abicelis.remindy.app.holders.ImageAttachmentViewHolder)3 ImageAttachment (ve.com.abicelis.remindy.model.attachment.ImageAttachment)3 InvalidParameterException (java.security.InvalidParameterException)1 TaskFragment (ve.com.abicelis.remindy.app.fragments.TaskFragment)1 AudioAttachmentViewHolder (ve.com.abicelis.remindy.app.holders.AudioAttachmentViewHolder)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 Attachment (ve.com.abicelis.remindy.model.attachment.Attachment)1 AudioAttachment (ve.com.abicelis.remindy.model.attachment.AudioAttachment)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