當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。