Java Code Examples for com.chad.library.adapter.base.viewholder.BaseViewHolder#getLayoutPosition()
The following examples show how to use
com.chad.library.adapter.base.viewholder.BaseViewHolder#getLayoutPosition() .
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: ArticleAdapter.java From DevUtils with Apache License 2.0 | 6 votes |
@Override protected void convert(BaseViewHolder helper, ArticleBean.DataBean.DatasBean item) { // 当前索引 int position = helper.getLayoutPosition(); // 标题 helper.setText(R.id.vid_aa_title_tv, item.title); // 时间 helper.setText(R.id.vid_aa_time_tv, DevCommonUtils.toCheckValue(item.niceShareDate, item.niceDate)); // 随机图片 GlideUtils.with().displayImage("https://picsum.photos/2" + DateUtils.convertTime(position), helper.getView(R.id.vid_aa_pic_igview), ProjectUtils.getRoundOptions()); // 绑定点击事件 ListenerUtils.setOnClicks(new View.OnClickListener() { @Override public void onClick(View v) { String link = item.link; if (!TextUtils.isEmpty(link)) { Uri uri = Uri.parse(link); Intent intent = new Intent(Intent.ACTION_VIEW, uri); AppUtils.startActivity(intent); } } }, helper.getView(R.id.vid_aa_cardview)); }
Example 2
Source File: ItemSlideAdapter.java From DevUtils with Apache License 2.0 | 6 votes |
@Override protected void convert(BaseViewHolder helper, CommodityEvaluateBean item) { // 当前索引 int position = helper.getLayoutPosition(); // 判断是否显示边距 ViewUtils.setVisibility(position == 0, helper.getView(R.id.vid_ams_line)); // ============ // = 商品信息 = // ============ // 商品名 helper.setText(R.id.vid_ams_name_tv, item.commodityName); // 商品价格 helper.setText(R.id.vid_ams_price_tv, "¥" + BigDecimalUtils.round(item.commodityPrice, 2)); // 商品图片 GlideUtils.with().displayImage(item.commodityPicture, helper.getView(R.id.vid_ams_pic_igview), ProjectUtils.getRoundOptions()); }
Example 3
Source File: UpFetchAdapter.java From BaseRecyclerViewAdapterHelper with MIT License | 6 votes |
@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 4
Source File: AnimationAdapter.java From BaseRecyclerViewAdapterHelper with MIT License | 6 votes |
@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 5
Source File: HeaderAndFooterAdapter.java From BaseRecyclerViewAdapterHelper with MIT License | 6 votes |
@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 6
Source File: DragAndSwipeAdapter.java From BaseRecyclerViewAdapterHelper with MIT License | 6 votes |
@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 7
Source File: NestAdapter.java From BaseRecyclerViewAdapterHelper with MIT License | 6 votes |
@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 8
Source File: LoadMoreAdapter.java From BaseRecyclerViewAdapterHelper with MIT License | 6 votes |
@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 9
Source File: EmptyViewAdapter.java From BaseRecyclerViewAdapterHelper with MIT License | 6 votes |
@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 10
Source File: MultipleItemQuickAdapter.java From BaseRecyclerViewAdapterHelper with MIT License | 6 votes |
@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 11
Source File: DelegateMultiAdapter.java From BaseRecyclerViewAdapterHelper with MIT License | 6 votes |
@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 12
Source File: SectionQuickAdapter.java From BaseRecyclerViewAdapterHelper with MIT License | 5 votes |
@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 13
Source File: MultiSelectAdapter.java From DevUtils with Apache License 2.0 | 4 votes |
@Override protected void convert(BaseViewHolder helper, CommodityEvaluateBean item) { // 当前索引 int position = helper.getLayoutPosition(); // 判断是否显示边距 ViewUtils.setVisibility(position == 0, helper.getView(R.id.vid_ams_line)); // ============ // = 商品信息 = // ============ // 商品名 helper.setText(R.id.vid_ams_name_tv, item.commodityName); // 商品价格 helper.setText(R.id.vid_ams_price_tv, "¥" + BigDecimalUtils.round(item.commodityPrice, 2)); // 商品图片 GlideUtils.with().displayImage(item.commodityPicture, helper.getView(R.id.vid_ams_pic_igview), ProjectUtils.getRoundOptions()); // ============ // = 多选处理 = // ============ BaseImageView vid_ams_igview = helper.getView(R.id.vid_ams_igview); // 是否显示编辑按钮、以及是否选中 ViewHelper.get().setVisibility(isEditState(), vid_ams_igview) .setSelected(multiSelectMapAssist.isSelectKey(position), vid_ams_igview) .setOnClicks(new View.OnClickListener() { @Override public void onClick(View v) { if (!isEditState()) return; // 反选处理 multiSelectMapAssist.toggle(position, item); // 设置是否选中 ViewUtils.setSelected(multiSelectMapAssist.isSelectKey(position), vid_ams_igview); // 触发回调 if (selectListener != null) { selectListener.onClickSelect(position, multiSelectMapAssist.isSelectKey(position)); } } }, helper.getView(R.id.vid_ams_linear)); }