Java Code Examples for com.chad.library.adapter.base.viewholder.BaseViewHolder#setImageResource()

The following examples show how to use com.chad.library.adapter.base.viewholder.BaseViewHolder#setImageResource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UpFetchAdapter.java    From BaseRecyclerViewAdapterHelper with MIT License 6 votes vote down vote up
@Override
protected void convert(@NotNull BaseViewHolder helper, @NotNull Movie item) {
    switch (helper.getLayoutPosition() %
            3) {
        case 0:
            helper.setImageResource(R.id.iv, R.mipmap.animation_img1);
            break;
        case 1:
            helper.setImageResource(R.id.iv, R.mipmap.animation_img2);
            break;
        case 2:
            helper.setImageResource(R.id.iv, R.mipmap.animation_img3);
            break;
        default:
            break;
    }
}
 
Example 2
Source File: AnimationAdapter.java    From BaseRecyclerViewAdapterHelper with MIT License 6 votes vote down vote up
@Override
protected void convert(@NonNull BaseViewHolder helper, Status item) {
    switch (helper.getLayoutPosition() % 3) {
        case 0:
            helper.setImageResource(R.id.img, R.mipmap.animation_img1);
            break;
        case 1:
            helper.setImageResource(R.id.img, R.mipmap.animation_img2);
            break;
        case 2:
            helper.setImageResource(R.id.img, R.mipmap.animation_img3);
            break;
        default:
            break;
    }
    helper.setText(R.id.tweetName, "Hoteis in Rio de Janeiro");
    String msg = "\"He was one of Australia's most of distinguished artistes, renowned for his portraits\"";
    ((TextView) helper.getView(R.id.tweetText)).setText(SpannableStringUtils.getBuilder(msg).append("landscapes and nedes").setClickSpan(clickableSpan).create());
    ((TextView) helper.getView(R.id.tweetText)).setMovementMethod(ClickableMovementMethod.getInstance());
    ((TextView) helper.getView(R.id.tweetText)).setFocusable(false);
    ((TextView) helper.getView(R.id.tweetText)).setClickable(false);
    ((TextView) helper.getView(R.id.tweetText)).setLongClickable(false);
}
 
Example 3
Source File: HeaderAndFooterAdapter.java    From BaseRecyclerViewAdapterHelper with MIT License 6 votes vote down vote up
@Override
protected void convert(@NonNull BaseViewHolder helper, Status item) {
    switch (helper.getLayoutPosition() %
            3) {
        case 0:
            helper.setImageResource(R.id.iv, R.mipmap.animation_img1);
            break;
        case 1:
            helper.setImageResource(R.id.iv, R.mipmap.animation_img2);
            break;
        case 2:
            helper.setImageResource(R.id.iv, R.mipmap.animation_img3);
            break;
        default:
            break;
    }
}
 
Example 4
Source File: DragAndSwipeAdapter.java    From BaseRecyclerViewAdapterHelper with MIT License 6 votes vote down vote up
@Override
protected void convert(@NotNull BaseViewHolder helper, @NotNull String item) {
    switch (helper.getLayoutPosition() % 3) {
        case 0:
            helper.setImageResource(R.id.iv_head, R.mipmap.head_img0);
            break;
        case 1:
            helper.setImageResource(R.id.iv_head, R.mipmap.head_img1);
            break;
        case 2:
            helper.setImageResource(R.id.iv_head, R.mipmap.head_img2);
            break;
        default:
            break;
    }
    helper.setText(R.id.tv, item);
}
 
Example 5
Source File: NestAdapter.java    From BaseRecyclerViewAdapterHelper with MIT License 6 votes vote down vote up
@Override
protected void convert(@NonNull BaseViewHolder helper, Status item) {
    switch (helper.getLayoutPosition() % 3) {
        case 0:
            helper.setImageResource(R.id.img, R.mipmap.animation_img1);
            break;
        case 1:
            helper.setImageResource(R.id.img, R.mipmap.animation_img2);
            break;
        case 2:
            helper.setImageResource(R.id.img, R.mipmap.animation_img3);
            break;
        default:
            break;
    }
    helper.setText(R.id.tweetName, "Hoteis in Rio de Janeiro");
    String msg = "\"He was one of Australia's most of distinguished artistes, renowned for his portraits\"";
    ((TextView) helper.getView(R.id.tweetText)).setText(SpannableStringUtils.getBuilder(msg).append("landscapes and nedes").setClickSpan(clickableSpan).create());
    ((TextView) helper.getView(R.id.tweetText)).setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example 6
Source File: LoadMoreAdapter.java    From BaseRecyclerViewAdapterHelper with MIT License 6 votes vote down vote up
@Override
protected void convert(@NotNull BaseViewHolder helper, @Nullable Status item) {
    switch (helper.getLayoutPosition() % 3) {
        case 0:
            helper.setImageResource(R.id.img, R.mipmap.animation_img1);
            break;
        case 1:
            helper.setImageResource(R.id.img, R.mipmap.animation_img2);
            break;
        case 2:
            helper.setImageResource(R.id.img, R.mipmap.animation_img3);
            break;
        default:
            break;
    }
    helper.setText(R.id.tweetName, "Hoteis in Rio de Janeiro");
    String msg = "\"He was one of Australia's most of distinguished artistes, renowned for his portraits\"";
    ((TextView) helper.getView(R.id.tweetText)).setText(SpannableStringUtils.getBuilder(msg).append("landscapes and nedes").setClickSpan(clickableSpan).create());
    ((TextView) helper.getView(R.id.tweetText)).setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example 7
Source File: EmptyViewAdapter.java    From BaseRecyclerViewAdapterHelper with MIT License 6 votes vote down vote up
@Override
protected void convert(@NotNull BaseViewHolder helper, @NotNull Status item) {
    switch (helper.getLayoutPosition() % 3) {
        case 0:
            helper.setImageResource(R.id.img, R.mipmap.animation_img1);
            break;
        case 1:
            helper.setImageResource(R.id.img, R.mipmap.animation_img2);
            break;
        case 2:
            helper.setImageResource(R.id.img, R.mipmap.animation_img3);
            break;
        default:
            break;
    }
    helper.setText(R.id.tweetName, "Hoteis in Rio de Janeiro");
    helper.setText(R.id.tweetText, "O ever youthful,O ever weeping");
}
 
Example 8
Source File: MultipleItemQuickAdapter.java    From BaseRecyclerViewAdapterHelper with MIT License 6 votes vote down vote up
@Override
protected void convert(@NonNull BaseViewHolder helper, QuickMultipleEntity item) {
    switch (helper.getItemViewType()) {
        case QuickMultipleEntity.TEXT:
            helper.setText(R.id.tv, item.getContent());
            break;
        case QuickMultipleEntity.IMG_TEXT:
            switch (helper.getLayoutPosition() % 2) {
                case 0:
                    helper.setImageResource(R.id.iv, R.mipmap.animation_img1);
                    break;
                case 1:
                    helper.setImageResource(R.id.iv, R.mipmap.animation_img2);
                    break;
                default:
                    break;
            }
            break;
        default:
            break;
    }
}
 
Example 9
Source File: DelegateMultiAdapter.java    From BaseRecyclerViewAdapterHelper with MIT License 6 votes vote down vote up
@Override
protected void convert(@NotNull BaseViewHolder helper, @NotNull DelegateMultiEntity item) {
    switch (helper.getItemViewType()) {
        case QuickMultipleEntity.TEXT:
            helper.setText(R.id.tv, "CymChad " + helper.getAdapterPosition());
            break;
        case QuickMultipleEntity.IMG_TEXT:
            switch (helper.getLayoutPosition() % 2) {
                case 0:
                    helper.setImageResource(R.id.iv, R.mipmap.animation_img1);
                    break;
                case 1:
                    helper.setImageResource(R.id.iv, R.mipmap.animation_img2);
                    break;
                default:
                    break;
            }
            helper.setText(R.id.tv, "ChayChan " + helper.getAdapterPosition());
            break;
        default:
            break;
    }
}
 
Example 10
Source File: SectionQuickAdapter.java    From BaseRecyclerViewAdapterHelper with MIT License 5 votes vote down vote up
@Override
protected void convert(@NotNull BaseViewHolder helper, @NotNull MySection item) {
    Video video = (Video) item.getObject();
    switch (helper.getLayoutPosition() % 2) {
        case 0:
            helper.setImageResource(R.id.iv, R.mipmap.m_img1);
            break;
        case 1:
            helper.setImageResource(R.id.iv, R.mipmap.m_img2);
            break;
        default:
            break;
    }
    helper.setText(R.id.tv, video.getName());
}
 
Example 11
Source File: FirstProvider.java    From BaseRecyclerViewAdapterHelper with MIT License 5 votes vote down vote up
@Override
public void convert(@NotNull BaseViewHolder helper, @NotNull BaseNode data) {
    FirstNode entity = (FirstNode) data;
    helper.setText(R.id.title, entity.getTitle());
    helper.setImageResource(R.id.iv, R.mipmap.arrow_r);

    setArrowSpin(helper, data, false);
}
 
Example 12
Source File: SecondProvider.java    From BaseRecyclerViewAdapterHelper with MIT License 5 votes vote down vote up
@Override
public void convert(@NotNull BaseViewHolder helper, @NotNull BaseNode data) {
    SecondNode entity = (SecondNode) data;
    helper.setText(R.id.title, entity.getTitle());

    if (entity.isExpanded()) {
        helper.setImageResource(R.id.iv, R.mipmap.arrow_b);
    } else {
        helper.setImageResource(R.id.iv, R.mipmap.arrow_r);
    }
}
 
Example 13
Source File: SecondNodeProvider.java    From BaseRecyclerViewAdapterHelper with MIT License 5 votes vote down vote up
@Override
public void convert(@NotNull BaseViewHolder helper, @Nullable BaseNode data) {
    if (data == null) {
        return;
    }

    ItemNode entity = (ItemNode) data;
    helper.setImageResource(R.id.iv, entity.getImg());
    helper.setText(R.id.tv, entity.getName());
}
 
Example 14
Source File: ImgItemProvider.java    From BaseRecyclerViewAdapterHelper with MIT License 5 votes vote down vote up
@Override
public void convert(@NonNull BaseViewHolder helper, @Nullable ProviderMultiEntity data) {
    if (helper.getAdapterPosition() % 2 == 0) {
        helper.setImageResource(R.id.iv, R.mipmap.animation_img1);
    } else {
        helper.setImageResource(R.id.iv, R.mipmap.animation_img2);
    }
}
 
Example 15
Source File: TextImgItemProvider.java    From BaseRecyclerViewAdapterHelper with MIT License 5 votes vote down vote up
@Override
public void convert(@NotNull BaseViewHolder helper, @Nullable ProviderMultiEntity data) {
    helper.setText(R.id.tv, "CymChad " + helper.getAdapterPosition());
    if (helper.getAdapterPosition() % 2 == 0) {
        helper.setImageResource(R.id.iv, R.mipmap.animation_img1);
    } else {
        helper.setImageResource(R.id.iv, R.mipmap.animation_img2);
    }
}