本文整理匯總了Java中com.chad.library.adapter.base.BaseViewHolder類的典型用法代碼示例。如果您正苦於以下問題:Java BaseViewHolder類的具體用法?Java BaseViewHolder怎麽用?Java BaseViewHolder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BaseViewHolder類屬於com.chad.library.adapter.base包,在下文中一共展示了BaseViewHolder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convert
import com.chad.library.adapter.base.BaseViewHolder; //導入依賴的package包/類
@Override
protected void convert(BaseViewHolder helper, LikeBean item) {
helper.setText(R.id.txt_like_title, item.getTitle());
if (item.getType() == Constants.TYPE_WEIXIN) {
helper.setText(R.id.txt_like_type, R.string.weixin);
}
else if(item.getType() == Constants.TYPE_GANK){
helper.setText(R.id.txt_like_type, R.string.gank);
}
helper.setText(R.id.txt_like_date, DateUtil.LongToString(item.getTime()));
GlideApp.with(mContext)
.load(item.getImageUrl())
.centerCrop()
.placeholder(R.drawable.ic_ali)
.priority(Priority.LOW)
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
.into((ImageView) helper.getView(R.id.img_like));
}
示例2: convert
import com.chad.library.adapter.base.BaseViewHolder; //導入依賴的package包/類
@Override
protected void convert(BaseViewHolder holder, Content content) {
if (content != null) {
IconicsImageView typeIndicator = holder.getView(R.id.type);
if (content.isDir()) {
typeIndicator.setIcon(Octicons.Icon.oct_file_directory);
} else if (content.isFile()) {
typeIndicator.setIcon(Octicons.Icon.oct_file_binary);
} else if (content.isSubmodule()) {
typeIndicator.setIcon(Octicons.Icon.oct_file_submodule);
} else {
typeIndicator.setIcon(Octicons.Icon.oct_file_symlink_file);
}
holder.setText(R.id.file_name, content.name);
}
}
示例3: convert
import com.chad.library.adapter.base.BaseViewHolder; //導入依賴的package包/類
@Override
protected void convert(BaseViewHolder helper, VideoListInfo.Video item) {
AppComponent mAppComponent = ((App)helper.getView(R.id.iv_bg).getContext().getApplicationContext())
.getAppComponent();
ImageView imgbg = helper.getView(R.id.iv_bg);
Context context = imgbg.getContext();
mAppComponent.imageLoader().loadImage(context,
ImageConfigImpl
.builder()
.url(item.getData().getCover().getFeed())
.imageView(imgbg)
.build());
helper.setText(R.id.tv_name,item.getData().getTitle())
.setText(R.id.tv_desc,getDetailStr(item));
}
示例4: convert
import com.chad.library.adapter.base.BaseViewHolder; //導入依賴的package包/類
@Override
protected void convert(final BaseViewHolder helper, final HotMovieBean.SubjectsBean item) {
if (helper.getAdapterPosition() % 3 == 0) {
DensityUtil.setViewMargin(helper.itemView, false, 0, 5, 0, 40);
} else if(helper.getAdapterPosition() % 3 == 1){
DensityUtil.setViewMargin(helper.itemView, false, 0, 5, 0, 40);
}else if(helper.getAdapterPosition() % 3 == 2){
DensityUtil.setViewMargin(helper.itemView, false, 0, 0, 0, 40);
}
helper.setText(R.id.tv_item_movie_top_name,item.getTitle());
helper.setText(R.id.tv_item_movie_top_rating,"評分:"+String.valueOf(item.getRating().getAverage()));
GlideUtils.loadImage(3,item.getImages().getLarge(), (ImageView) helper.getView(R.id.iv_item_movie_top));
helper.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onItemClickListener.onItemClickListener(item, helper.getView(R.id.iv_item_movie_top));
}
});
}
示例5: convert
import com.chad.library.adapter.base.BaseViewHolder; //導入依賴的package包/類
@Override
protected void convert(BaseViewHolder helper, ListBean item) {
switch (helper.getItemViewType()) {
case ListItemType.ITEM_NORMAL:
helper.setText(R.id.tv_arrow_text, item.getText());
helper.setText(R.id.tv_arrow_value, item.getValue());
break;
case ListItemType.ITEM_AVATAR:
Glide.with(mContext)
.load(item.getImageUrl())
.diskCacheStrategy(DiskCacheStrategy.ALL).centerCrop().dontAnimate()
.into((ImageView) helper.getView(R.id.img_arrow_avatar));
break;
case ListItemType.ITEM_SWITCH:
helper.setText(R.id.tv_arrow_switch_text,item.getText());
final SwitchCompat switchCompat = helper.getView(R.id.list_item_switch);
switchCompat.setChecked(true);
switchCompat.setOnCheckedChangeListener(item.getOnCheckedChangeListener());
break;
}
}
示例6: renderFooter
import com.chad.library.adapter.base.BaseViewHolder; //導入依賴的package包/類
private void renderFooter(BaseViewHolder helper, final FooterOCEntity item) {
final int type = item.getItemType() + RecyclerViewAdapterHelper.FOOTER_TYPE_DIFFER;
final TextView footer = helper.getView(R.id.item_footer);
String text = String.format("我是底 title:%s flag:%s type:%s", item.getTitle(), item.getFlag(), type);
Log.d("FooterOCEntity", "footer: " + text);
footer.setText(text);
footer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mOnFooterClickListener != null) {
if (Constants.EXPAND.equals(item.getTitle())) {
mOnFooterClickListener.onFooterClick(type, false);
item.setTitle(Constants.FOLD);
} else {
mOnFooterClickListener.onFooterClick(type, true);
item.setTitle(Constants.EXPAND);
}
footer.setText(String.format("我是底 title:%s flag:%s type:%s", item.getTitle(), item.getFlag(), type));
}
}
});
}
示例7: convert
import com.chad.library.adapter.base.BaseViewHolder; //導入依賴的package包/類
@Override
protected void convert(final BaseViewHolder helper, WeatherCity item) {
TextView tvName = helper.getView(R.id.tv_card_city_name);
if (helper.getAdapterPosition() == 0) {
tvName.setCompoundDrawablesWithIntrinsicBounds(null, null,
ThemeUtil.setTintDrawable(R.drawable.ic_location, mContext,
ThemeUtil.getCurrentColorPrimary(mContext)), null);
}
tvName.setText(item.getCityName());
helper.setText(R.id.tv_card_weather, TextUtils.isEmpty(item.getWeatherText()) ? "NA" : item.getWeatherText());
helper.setText(R.id.tv_card_temp, TextUtils.isEmpty(item.getWeatherTemp()) ? "NA" : item.getWeatherTemp() + "℃");
final ImageView imageView = helper.getView(R.id.iv_card_weather);
WeatherUtil.getInstance().getWeatherDict(item.getWeatherCode()).observeOn(AndroidSchedulers.mainThread()).subscribe(new SimpleSubscriber<WeatherBean>() {
@Override
public void onNext(WeatherBean weatherBean) {
Glide.with(mContext).load(weatherBean.getIcon()).diskCacheStrategy(DiskCacheStrategy.ALL).into(imageView);
}
});
}
示例8: convert
import com.chad.library.adapter.base.BaseViewHolder; //導入依賴的package包/類
@Override
protected void convert(BaseViewHolder baseViewHolder, Post post) {
baseViewHolder.setText(R.id.tvUserName, "@" + post.getAuthor().getNickname())
.addOnClickListener(R.id.layoutBaseArticle)
.addOnClickListener(R.id.btnLike)
.addOnClickListener(R.id.btnFollow)
.addOnClickListener(R.id.imgHead)
.addOnClickListener(R.id.tvUserName)
.setText(R.id.tvTopContent, post.getCreatedAt())
.setText(R.id.tvBottomContent, post.getTitle());
ImgLoadUtil.loadHead(mContext, (ImageView) baseViewHolder.getView(R.id.imgHead), post.getAuthor().getHeadPic());
if (post.getCoverPicture() == null) {
baseViewHolder.getView(R.id.imageThumb).setVisibility(View.GONE);
} else {
baseViewHolder.getView(R.id.imageThumb).setVisibility(View.VISIBLE);
ImgLoadUtil.load(mContext, (ImageView) baseViewHolder.getView(R.id.imageThumb), post.getCoverPicture());
}
}
示例9: convert
import com.chad.library.adapter.base.BaseViewHolder; //導入依賴的package包/類
@Override
protected void convert(BaseViewHolder helper, Status item) {
helper.addOnClickListener(R.id.img).addOnClickListener(R.id.tweetName);
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;
}
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);
}
示例10: renderFooter
import com.chad.library.adapter.base.BaseViewHolder; //導入依賴的package包/類
private void renderFooter(BaseViewHolder helper, final CommonFooterEntity item) {
final int type = item.getItemType() + RecyclerViewAdapterHelper.FOOTER_TYPE_DIFFER;
final TextView footer = helper.getView(R.id.item_footer);
footer.setText(item.getTitle());
footer.setOnClickListener(v -> {
if (Constants.EXPAND.equals(item.getTitle())) {
item.setTitle(Constants.FOLD);
mHelper.foldType(type, false);
} else {
item.setTitle(Constants.EXPAND);
mHelper.foldType(type, true);
}
footer.setText(item.getTitle());
});
}
示例11: convert
import com.chad.library.adapter.base.BaseViewHolder; //導入依賴的package包/類
public void convert(BaseViewHolder holder) {
switch (mLoadMoreStatus) {
case STATUS_LOADING:
visibleLoading(holder, true);
visibleLoadFail(holder, false);
visibleLoadEnd(holder, false);
break;
case STATUS_FAIL:
visibleLoading(holder, false);
visibleLoadFail(holder, true);
visibleLoadEnd(holder, false);
break;
case STATUS_END:
visibleLoading(holder, false);
visibleLoadFail(holder, false);
visibleLoadEnd(holder, true);
break;
case STATUS_DEFAULT:
visibleLoading(holder, false);
visibleLoadFail(holder, false);
visibleLoadEnd(holder, false);
break;
}
}
示例12: onItemClicked
import com.chad.library.adapter.base.BaseViewHolder; //導入依賴的package包/類
@Override
protected void onItemClicked(BaseQuickAdapter<TitleEntity, BaseViewHolder> adapter, View view, int position) {
super.onItemClicked(adapter, view, position);
TitleEntity entity = adapter.getItem(position);
if (entity.colorRes != 0) {
isWhite = entity.colorRes == android.R.color.white;
titleBar.setBackgroundResource(entity.colorRes);
titleBar.setLeftTextDrawable(isWhite ? R.drawable.ic_arrow_left : R.drawable.ic_arrow_back_white);
titleBar.setRightTextDrawable(isWhite ? R.drawable.ic_menu : R.drawable.ic_menu_white);
titleBar.setTitleMainTextColor(isWhite ? getResources().getColor(R.color.colorTextBlack) : Color.WHITE);
titleBar.setTitleSubTextColor(isWhite ? getResources().getColor(R.color.colorTextBlack) : Color.WHITE);
if (type > 0 && isImmersible) {
if (isWhite) {
StatusBarUtil.setStatusBarLightMode(mContext);
} else {
StatusBarUtil.setStatusBarDarkMode(mContext);
}
}
} else if (entity.activity != null) {
startActivity(entity.activity);
}
}
示例13: convert
import com.chad.library.adapter.base.BaseViewHolder; //導入依賴的package包/類
@Override
protected void convert(BaseViewHolder helper, MultipleItem item) {
switch (helper.getItemViewType()) {
case MultipleItem.TEXT:
helper.setText(R.id.tv, item.getContent());
break;
case MultipleItem.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;
}
break;
}
}
示例14: setLinearLayout
import com.chad.library.adapter.base.BaseViewHolder; //導入依賴的package包/類
/**
* 設置線性布局
*
* @describe
*/
private void setLinearLayout(BaseViewHolder helper, Note item) {
helper.addOnClickListener(R.id.ll_note_list_line);
helper.addOnLongClickListener(R.id.ll_note_list_line);
// 顯示豎排布局,隱藏網格布局
helper.setVisible(R.id.cv_note_list_grid, false);
helper.setVisible(R.id.ll_note_list_linear, true);
TextView tvContent=helper.getView(R.id.tv_note_list_linear_content);
if(isPrivacyAndRecycle(item))
helper.setText(R.id.tv_note_list_linear_content,Utils.getContext().getResources().getString(R.string.note_privacy_and_recycle));
else
parseTextContent(tvContent,item.getNoteContent());
// 設置便簽的時間顯示
setNoteTime(helper, item.getModifiedTime());
// 設置便簽的分組顯示
setLinearLayoutGroup(helper, item.getCreatedTime());
// 設置多選按鈕
setCheckBox(helper);
}
示例15: convert
import com.chad.library.adapter.base.BaseViewHolder; //導入依賴的package包/類
@Override
protected void convert(BaseViewHolder helper, Status item) {
helper.addOnClickListener(R.id.tweetText);
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;
}
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());
}