com.chad.library.adapter.base.viewholder.BaseViewHolder Java Examples
The following examples show how to use
com.chad.library.adapter.base.viewholder.BaseViewHolder.
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 |
@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: 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 #3
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 #4
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 #5
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 #6
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 #7
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 #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: KeyValueAdapter.java From DevUtils with Apache License 2.0 | 6 votes |
@Override protected void convert(BaseViewHolder helper, KeyValueBean item) { ViewHelper.get().setVisibility(helper.getLayoutPosition() == 0, helper.getView(R.id.vid_akv_line)) .setText(helper.getView(R.id.vid_akv_key_tv), item.getKey()) .setText(helper.getView(R.id.vid_akv_value_tv), item.getValue()) .setOnClicks(new View.OnClickListener() { @Override public void onClick(View v) { String text = item.toString(); // 复制到剪切板 ClipboardUtils.copyText(text); // 进行提示 ToastTintUtils.success(ResourceUtils.getString(R.string.copy_suc) + " -> " + text); } }, helper.getView(R.id.vid_akv_linear)); }
Example #10
Source File: ScheduleNewAdapter.java From AcgClub with MIT License | 6 votes |
@Override protected void convert(BaseViewHolder helper, ScheduleNewItem item) { helper.setText(R.id.schedule_new_title, item.getTitle()) .setText(R.id.schedule_new_spot, item.getSpot()) .setText(R.id.schedule_new_type, item.getType()) .setText(R.id.schedule_new_desc, item.getDesc()); mImageLoader.loadImage(getContext(), GlideImageConfig .builder() .url(item.getImgUrl()) .transformation( new MultiTransformation<>(new CenterCrop(), new RoundedCornersTransformation(DimenUtils.dpToPx(getContext(), 4), 0))) .imageView((ImageView) helper.getView(R.id.schedule_new_img)) .build() ); }
Example #11
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 #12
Source File: FirstProvider.java From BaseRecyclerViewAdapterHelper with MIT License | 6 votes |
private void setArrowSpin(BaseViewHolder helper, BaseNode data, boolean isAnimate) { FirstNode entity = (FirstNode) data; ImageView imageView = helper.getView(R.id.iv); if (entity.isExpanded()) { if (isAnimate) { ViewCompat.animate(imageView).setDuration(200) .setInterpolator(new DecelerateInterpolator()) .rotation(0f) .start(); } else { imageView.setRotation(0f); } } else { if (isAnimate) { ViewCompat.animate(imageView).setDuration(200) .setInterpolator(new DecelerateInterpolator()) .rotation(90f) .start(); } else { imageView.setRotation(90f); } } }
Example #13
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 #14
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 #15
Source File: ISHNewsItemAdapter.java From AcgClub with MIT License | 5 votes |
@Override protected void convert(BaseViewHolder helper, SHPostItem item) { helper.setText(R.id.news_title, item.getTitle()) .setText(R.id.news_datetime, TimeUtils.millis2String(item.getTime())); mImageLoader.loadImage(getContext(), GlideImageConfig .builder() .url(item.getThumb()) .imageView((ImageView) helper.getView(R.id.news_img)) .build() ); }
Example #16
Source File: ScheduleRecentAdapter.java From AcgClub with MIT License | 5 votes |
@Override protected void convert(BaseViewHolder helper, ScheduleRecent item) { helper.setText(R.id.tv_schedule_recent, item.getName()) .setText(R.id.tv_schedule_recent_desc, item.getDesc()); mImageLoader.loadImage(getContext(), GlideImageConfig .builder() .url(item.getImgUrl()) .imageView((ImageView) helper.getView(R.id.img_schedule_recent)) .build() ); }
Example #17
Source File: ScheduleCollectionAdapter.java From AcgClub with MIT License | 5 votes |
@Override protected void convert(BaseViewHolder helper, ScheduleCache item) { helper.setText(R.id.tv_schedule_collection_name, item.getName()); mImageLoader.loadImage(getContext(), GlideImageConfig .builder() .url(item.getImgUrl()) .transformation( new MultiTransformation<>(new CenterCrop(), new RoundedCornersTransformation(DimenUtils.dpToPx(getContext(), 4), 0))) .imageView((ImageView) helper.getView(R.id.img_schedule_collection)) .build() ); }
Example #18
Source File: ScheduleDetailEpisodeItemAdapter.java From AcgClub with MIT License | 5 votes |
@Override protected void convert(BaseViewHolder helper, ScheduleEpisode item) { helper.setText(R.id.tv_sd_episode_name, item.getName()); if (helper.getAdapterPosition() == mLastRecordPos) { helper .setBackgroundResource(R.id.tv_sd_episode_name, R.drawable.acgschedule_btn_episode_record) .setTextColor(R.id.tv_sd_episode_name, ContextCompat.getColor(getContext(), R.color.colorPrimary)); } else { helper.setBackgroundResource(R.id.tv_sd_episode_name, R.drawable.acgschedule_btn_episode) .setTextColor(R.id.tv_sd_episode_name, ContextCompat.getColor(getContext(), R.color.grey400)); } }
Example #19
Source File: ScheduleRecommandAdapter.java From AcgClub with MIT License | 5 votes |
@Override protected void convert(BaseViewHolder helper, ScheduleRecommend item) { helper.setText(R.id.tv_schedule_recommand, item.getName()); mImageLoader.loadImage(getContext(), GlideImageConfig .builder() .url(item.getImgUrl()) .transformation( new MultiTransformation<>(new CenterCrop(), new RoundedCornersTransformation(20, 0))) .imageView((ImageView) helper.getView(R.id.img_schedule_recommand)) .build() ); }
Example #20
Source File: ZeroFiveNewsItemAdapter.java From AcgClub with MIT License | 5 votes |
@Override protected void convert(BaseViewHolder helper, ZeroFiveNews item) { helper.setText(R.id.news_title, item.getTitle()) .setText(R.id.news_datetime, item.getDateTime()); mImageLoader.loadImage(getContext(), GlideImageConfig .builder() .url(item.getImgUrl()) .imageView((ImageView) helper.getView(R.id.news_img)) .build() ); }
Example #21
Source File: ImgItemProvider.java From BaseRecyclerViewAdapterHelper with MIT License | 5 votes |
@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 #22
Source File: ItemClickAdapter.java From BaseRecyclerViewAdapterHelper with MIT License | 5 votes |
@Override protected void convert(@NonNull final BaseViewHolder helper, final ClickEntity item) { switch (helper.getItemViewType()) { case ClickEntity.CLICK_ITEM_VIEW: break; case ClickEntity.CLICK_ITEM_CHILD_VIEW: // set img data break; case ClickEntity.LONG_CLICK_ITEM_VIEW: break; case ClickEntity.LONG_CLICK_ITEM_CHILD_VIEW: break; case ClickEntity.NEST_CLICK_ITEM_CHILD_VIEW: // u can set nestview id RecyclerView recyclerView = helper.getView(R.id.nest_list); recyclerView.setHasFixedSize(true); if (recyclerView.getLayoutManager() == null) { recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false)); } if (recyclerView.getAdapter() == null) { NestAdapter nestAdapter = new NestAdapter(); nestAdapter.setOnItemClickListener(this); nestAdapter.setOnItemChildClickListener(this); recyclerView.setAdapter(nestAdapter); } break; default: break; } }
Example #23
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 #24
Source File: FirstProvider.java From BaseRecyclerViewAdapterHelper with MIT License | 5 votes |
@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 #25
Source File: FirstProvider.java From BaseRecyclerViewAdapterHelper with MIT License | 5 votes |
@Override public void convert(@NotNull BaseViewHolder helper, @NotNull BaseNode data, @NotNull List<?> payloads) { for (Object payload : payloads) { if (payload instanceof Integer && (int) payload == NodeTreeAdapter.EXPAND_COLLAPSE_PAYLOAD) { // 增量刷新,使用动画变化箭头 setArrowSpin(helper, data, true); } } }
Example #26
Source File: SecondProvider.java From BaseRecyclerViewAdapterHelper with MIT License | 5 votes |
@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 #27
Source File: SecondProvider.java From BaseRecyclerViewAdapterHelper with MIT License | 5 votes |
@Override public void onClick(@NotNull BaseViewHolder helper, @NotNull View view, BaseNode data, int position) { SecondNode entity = (SecondNode) data; if (entity.isExpanded()) { getAdapter().collapse(position); } else { getAdapter().expandAndCollapseOther(position); } }
Example #28
Source File: SecondNodeProvider.java From BaseRecyclerViewAdapterHelper with MIT License | 5 votes |
@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 #29
Source File: TextImgItemProvider.java From BaseRecyclerViewAdapterHelper with MIT License | 5 votes |
@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); } }
Example #30
Source File: DiffUtilAdapter.java From BaseRecyclerViewAdapterHelper with MIT License | 5 votes |
/** * This method will only be executed when there is payload info * * 当有 payload info 时,只会执行此方法 * * @param helper A fully initialized helper. * @param item The item that needs to be displayed. * @param payloads payload info. */ @Override protected void convert(@NotNull BaseViewHolder helper, @NotNull DiffUtilDemoEntity item, @NotNull List<?> payloads) { for (Object p : payloads) { int payload = (int) p; if (payload == ITEM_0_PAYLOAD) { helper.setText(R.id.tweetName, item.getTitle()) .setText(R.id.tweetText, item.getContent()); } } }