当前位置: 首页>>代码示例>>Java>>正文


Java BaseViewHolder类代码示例

本文整理汇总了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));
}
 
开发者ID:xiarunhao123,项目名称:Ency,代码行数:19,代码来源:LikeAdapter.java

示例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);
    }
}
 
开发者ID:Jusenr,项目名称:androidgithub,代码行数:17,代码来源:RepoContentAdapter.java

示例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));
}
 
开发者ID:Zweihui,项目名称:Aurora,代码行数:16,代码来源:SearchAdapter.java

示例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));
        }
    });

}
 
开发者ID:paterWang,项目名称:EasyReader,代码行数:21,代码来源:MovieTopAdapter.java

示例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;

    }
}
 
开发者ID:remerber,项目名称:FastEc,代码行数:25,代码来源:ListAdapter.java

示例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));
            }
        }
    });

}
 
开发者ID:crazysunj,项目名称:MultiTypeRecyclerViewAdapter,代码行数:24,代码来源:OpenCloseAdapter.java

示例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);
        }
    });
}
 
开发者ID:li-yu,项目名称:FakeWeather,代码行数:20,代码来源:CardWeatherAdapter.java

示例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());
    }
}
 
开发者ID:weimin96,项目名称:shareNote,代码行数:20,代码来源:MainBottomRecyclerAdapter.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:AnimationAdapter.java

示例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());
    });

}
 
开发者ID:crazysunj,项目名称:MultiTypeRecyclerViewAdapter,代码行数:17,代码来源:MyAdapter.java

示例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;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:LoadMoreView.java

示例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);
    }
}
 
开发者ID:AriesHoo,项目名称:TitleBarView,代码行数:23,代码来源:MainActivity.java

示例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;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:MultipleItemQuickAdapter.java

示例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);
}
 
开发者ID:ifadai,项目名称:SuperNote,代码行数:29,代码来源:RvNoteListAdapter.java

示例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());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:NestAdapter.java


注:本文中的com.chad.library.adapter.base.BaseViewHolder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。