Java Code Examples for com.chad.library.adapter.base.BaseViewHolder#setText()

The following examples show how to use com.chad.library.adapter.base.BaseViewHolder#setText() . 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: EyepetizerAdapter.java    From Ency with Apache License 2.0 6 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, VideoBean.ItemListBean item) {
    helper.setText(R.id.txt_video_duration, SystemUtil.second2Minute(item.getData().getContent().getData().getDuration()));
    helper.setText(R.id.txt_video_title, item.getData().getContent().getData().getTitle());
    helper.setText(R.id.txt_video_content, item.getData().getHeader().getTitle() + " / "
            + item.getData().getHeader().getDescription());
    ImageLoader.loadAllNoPlaceHolder(mContext, item.getData().getContent().getData().getCover().getDetail()
            , (RoundedImageView) helper.getView(R.id.img_video));
    ImageLoader.loadAllNoPlaceHolder(mContext, item.getData().getHeader().getIcon()
            , (RoundedImageView) helper.getView(R.id.img_video_author));
    ImageView imgDaily = helper.getView(R.id.img_dialy);
    if (item.getData().getHeader().getDescription().contains("每日编辑精选")) {
        imgDaily.setVisibility(View.VISIBLE);
    } else {
        imgDaily.setVisibility(View.GONE);
    }
}
 
Example 2
Source File: AqiAdapter.java    From FakeWeather with Apache License 2.0 6 votes vote down vote up
/**
 * Implement this method and use the helper to adapt the view to the given item.
 *
 * @param helper A fully initialized helper.
 * @param item   The item that needs to be displayed.
 */
@Override
protected void convert(BaseViewHolder helper, AqiDetailBean item) {
    helper.setText(R.id.tv_aqi_name, item.getName());
    helper.setText(R.id.tv_aqi_desc, item.getDesc());
    if (TextUtils.isEmpty(item.getValue())) {
        item.setValue("-1");
    }
    helper.setText(R.id.tv_aqi_value, item.getValue() + "");
    int value = TextUtils.isDigitsOnly(item.getValue()) ? Integer.parseInt(item.getValue()) : 0;
    if (value <= 50) {
        helper.setBackgroundColor(R.id.view_aqi_qlty, 0xFF6BCD07);
    } else if (value <= 100) {
        helper.setBackgroundColor(R.id.view_aqi_qlty, 0xFFFBD029);
    } else if (value <= 150) {
        helper.setBackgroundColor(R.id.view_aqi_qlty, 0xFFFE8800);
    } else if (value <= 200) {
        helper.setBackgroundColor(R.id.view_aqi_qlty, 0xFFFE0000);
    } else if (value <= 300) {
        helper.setBackgroundColor(R.id.view_aqi_qlty, 0xFF970454);
    } else {
        helper.setBackgroundColor(R.id.view_aqi_qlty, 0xFF62001E);
    }
}
 
Example 3
Source File: NotificationAdapter.java    From JianshuApp with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void convert(BaseViewHolder holder, NotificationMenu entity) {
    holder.setTag(R.id.item_root, entity);

    holder.setImageResource(R.id.image_left, entity.icon);
    holder.setText(R.id.txt_head, entity.title);
    if (entity.hasSubtitle()) {
        holder.setVisible(R.id.txt_subhead, true);
        holder.setText(R.id.txt_subhead, entity.subtitle);
    } else {
        holder.setVisible(R.id.txt_subhead, false);
    }

    if (entity.unreadCount > 0) {
        holder.setVisible(R.id.txt_unread_count, true);
        holder.setText(R.id.txt_unread_count, (entity.unreadCount > 99 ? "99+" : String.valueOf(entity.unreadCount)));
    } else {
        holder.setVisible(R.id.txt_unread_count, false);
    }

    holder.setTag(R.id.item_root, holder.getLayoutPosition());
    holder.setOnClickListener(R.id.item_root, this);
}
 
Example 4
Source File: PostDetailListAdapter.java    From Focus with GNU General Public License v3.0 6 votes vote down vote up
@Override
    protected void convert(BaseViewHolder helper, final FeedItem item) {

        //根据偏好设置的背景颜色,设置标题栏位置的背景颜色
        if (!SkinPreference.getInstance().getSkinName().equals("night")){
//            helper.setBackgroundColor(R.id.container, PostSetting.getBackgroundInt(context));
            helper.setBackgroundColor(R.id.post_title, PostSetting.getBackgroundInt(context));
            helper.setBackgroundColor(R.id.post_turn, PostSetting.getBackgroundInt(context));
        }

        scrollView = helper.getView(R.id.post_turn);
        //设置文章内容
        PostUtil.setContent(context, item, ((WebView) helper.getView(R.id.post_content)), (ViewGroup) helper.getView(R.id.container));
        helper.setText(R.id.post_title, item.getTitle());
        helper.setText(R.id.post_time, DateUtil.getTimeStringByInt(item.getDate()));
        helper.setText(R.id.feed_name, item.getFeedName());

        if (!item.isRead()) {
            //如果这个文章没有阅读过则滚动到顶部
            scrollView.fullScroll(ScrollView.FOCUS_UP);
        }

        refreshLayout = helper.getView(R.id.refreshLayout);

        initListener(item);
    }
 
Example 5
Source File: ProxyAdapter.java    From v9porn with MIT License 5 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, ProxyModel item) {
    helper.setText(R.id.tv_item_proxy_ip_address, item.getProxyIp());
    helper.setText(R.id.tv_item_proxy_port, item.getProxyPort());
    helper.setText(R.id.tv_item_proxy_anonymous, item.getAnonymous());
    helper.setText(R.id.tv_item_proxy_delay_time, item.getResponseTime());
    helper.setText(R.id.tv_item_proxy_type, item.getTypeShowStr());
    if (helper.getLayoutPosition() == clickPosition) {
        helper.itemView.setBackgroundColor(ContextCompat.getColor(helper.itemView.getContext(), R.color.colorPrimary));
    } else {
        helper.itemView.setBackgroundColor(ContextCompat.getColor(helper.itemView.getContext(), R.color.common_background));
    }
}
 
Example 6
Source File: TriggerListFragment.java    From AndroidSDK with MIT License 5 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, TriggerItem item) {
    helper.setText(R.id.title, item.getTitle());
    helper.setText(R.id.ds_id, getResources().getString(R.string.ds_id) + ":" + item.getDsId());
    helper.setText(R.id.create_time, getResources().getString(R.string.create_time) + ":" + item.getCreateTime());
    helper.setText(R.id.url, getResources().getString(R.string.url_address) + ":" + item.getUrl());
}
 
Example 7
Source File: BookCustomAdapter.java    From YiZhi with Apache License 2.0 5 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, BookItemBean item) {
    helper.setText(R.id.tv_item_title, "《" + item.getTitle() + "》");
    helper.setText(R.id.tv_item_author, "作者:" + item.getAuthorsString());
    helper.setText(R.id.tv_item_publisher, "出版社:" + item.getPublisher());
    helper.setText(R.id.tv_item_pubdate, "出版日期:" + item.getPubdate());
    helper.setText(R.id.tv_item_rate, "评分:" + item.getRating().getAverage());
    Glide.with(mContext).load(item.getImage()).crossFade(300).into((ImageView) helper.getView
            (R.id.iv_item_image));
}
 
Example 8
Source File: FavoriteAdapter.java    From v9porn with MIT License 5 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, V9PornItem item) {
    helper.setText(R.id.tv_91porn_item_title, item.getTitle() + "  (" + item.getDuration() + ")");
    helper.setText(R.id.tv_91porn_item_info, item.getInfo());
    ImageView simpleDraweeView = helper.getView(R.id.iv_91porn_item_img);
    Uri uri = Uri.parse(item.getImgUrl());
    GlideApp.with(helper.itemView).load(uri).placeholder(R.drawable.placeholder).transition(new DrawableTransitionOptions().crossFade(300)).into(simpleDraweeView);

    helper.addOnClickListener(R.id.right_menu_delete);
}
 
Example 9
Source File: FeedListAdapter.java    From Focus with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, Feed item) {
    helper.setText(R.id.name,item.getName());
    helper.setText(R.id.desc,item.getDesc());
    if (!StringUtil.trim(item.getIcon()).equals("")){//显示图标
        ImageLoader.getInstance().displayImage(StringUtil.trim(String.valueOf(item.getIcon())), (ImageView) helper.getView(R.id.account_avatar),ImageLoaderManager.getSubsciptionIconOptions(activity));
    }else {
        helper.setImageResource(R.id.account_avatar,R.drawable.ic_rss_feed_grey_24dp);
    }
}
 
Example 10
Source File: MessageAdapter.java    From Anti-recall with GNU Affero General Public License v3.0 5 votes vote down vote up
private void init(BaseViewHolder helper, Messages item) {
    helper.setText(R.id.cell_title_fold, item.getName());
    helper.setText(R.id.cell_title_unfold, item.getName());
    helper.setText(R.id.cell_name, item.getSubName());
    helper.setText(R.id.cell_time, formatTime(item.getTime()));
    helper.setText(R.id.cell_message_text, item.getText());

    switch (theme) {
        case App.THEME_BLUE:
            helper.setBackgroundColor(R.id.cell_name, context.getResources().getColor(R.color.bgNameBlue));
            helper.setBackgroundColor(R.id.item_message, context.getResources().getColor(R.color.bgContentBlue));
            helper.setBackgroundColor(R.id.cell_title_fold_bg, context.getResources().getColor(R.color.bgTitleBlue));
            helper.setBackgroundColor(R.id.cell_title_unfold_bg, context.getResources().getColor(R.color.bgTitleBlue));
            break;
        case App.THEME_RED:
            helper.setBackgroundColor(R.id.cell_name, context.getResources().getColor(R.color.bgNameRed));
            helper.setBackgroundColor(R.id.item_message, context.getResources().getColor(R.color.bgContentRed));
            helper.setBackgroundColor(R.id.cell_title_fold_bg, context.getResources().getColor(R.color.bgTitleRed));
            helper.setBackgroundColor(R.id.cell_title_unfold_bg, context.getResources().getColor(R.color.bgTitleRed));
            break;
        case App.THEME_GREEN:
            helper.setBackgroundColor(R.id.cell_name, context.getResources().getColor(R.color.bgNameGreen));
            helper.setBackgroundColor(R.id.item_message, context.getResources().getColor(R.color.bgContentGreen));
            helper.setBackgroundColor(R.id.cell_title_fold_bg, context.getResources().getColor(R.color.bgTitleGreen));
            helper.setBackgroundColor(R.id.cell_title_unfold_bg, context.getResources().getColor(R.color.bgTitleGreen));
            break;

    }
}
 
Example 11
Source File: ProxyAdapter.java    From v9porn with MIT License 5 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, ProxyModel item) {
    helper.setText(R.id.tv_item_proxy_ip_address, item.getProxyIp());
    helper.setText(R.id.tv_item_proxy_port, item.getProxyPort());
    helper.setText(R.id.tv_item_proxy_anonymous, item.getAnonymous());
    helper.setText(R.id.tv_item_proxy_delay_time, item.getResponseTime());
    helper.setText(R.id.tv_item_proxy_type, item.getTypeShowStr());
    if (helper.getLayoutPosition() == clickPosition) {
        helper.itemView.setBackgroundColor(ContextCompat.getColor(helper.itemView.getContext(), R.color.colorPrimary));
    } else {
        helper.itemView.setBackgroundColor(ContextCompat.getColor(helper.itemView.getContext(), R.color.common_background));
    }
}
 
Example 12
Source File: MultiMessagesAdapter.java    From Anti-recall with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, Messages item) {
    Log.v(TAG, "convert: " + item.getText() + " id: " + item.getId());
    helper.setText(R.id.cell_name, item.getSubName());
    helper.setText(R.id.cell_time, sdfSec.format(item.getTime()));
    formatTime(item.getTime());
    // TODO: image之后改成可以左右滑动的
    if (item.getImages() != null && item.getImages().length() != 0) {
        helper.setImageBitmap(R.id.cell_message_image, ImageHelper.getBitmap(item.getImage()));
        helper.setText(R.id.cell_message_text, "");
    } else {
        helper.setImageBitmap(R.id.cell_message_image, null);
        helper.setText(R.id.cell_message_text, item.getText());
    }
    switch (theme) {
        case App.THEME_BLUE:
            helper.setBackgroundColor(R.id.cell_name, context.getResources().getColor(R.color.bgNameBlue));
            helper.setBackgroundColor(R.id.item_message, context.getResources().getColor(R.color.bgContentBlue));
            break;
        case App.THEME_RED:
            helper.setBackgroundColor(R.id.cell_name, context.getResources().getColor(R.color.bgNameRed));
            helper.setBackgroundColor(R.id.item_message, context.getResources().getColor(R.color.bgContentRed));
            break;
        case App.THEME_GREEN:
            helper.setBackgroundColor(R.id.cell_name, context.getResources().getColor(R.color.bgNameGreen));
            helper.setBackgroundColor(R.id.item_message, context.getResources().getColor(R.color.bgContentGreen));
            break;
    }
}
 
Example 13
Source File: SectionAdapter.java    From FastWaiMai with MIT License 4 votes vote down vote up
@Override
protected void convert(final BaseViewHolder helper, MultipleItemEntity item) {
       switch (helper.getItemViewType()){
           case ContentItemType.ITEM_NORMAL:
               final String goodsName = item.getField(MultipleFields.TEXT);
               final String goodsSpec = item.getField(MultipleFields.SPEC);
               final String goodsThumb = item.getField(MultipleFields.IMAGE_URL);
               final String price = item.getField(ShopCartItemFields.PRICE);
               final String originPrice = item.getField(ShopCartItemFields.ORIGIN_PRICE);
               //设置Text
               helper.setText(R.id.tv_goods_name, goodsName);
               helper.setText(R.id.tv_goods_detail, goodsSpec);
               helper.setText(R.id.tv_price, "¥" + price);
               final TextView originPriceView = helper.getView(R.id.tv_origin_price);
               //添加下划线
               originPriceView.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
               helper.setText(R.id.tv_origin_price, "¥" + originPrice);
               //商品图片
               final AppCompatImageView imageView = helper.getView(R.id.iv);
               Glide.with(mContext)
                       .applyDefaultRequestOptions(RECYCLE_OPTIONS)
                       .load(goodsThumb)
                       .into(imageView);
               //加入购物车图标
               final ImageView shopCartImageView = helper.getView(R.id.iv_add_shopcart);
               shopCartImageView.setOnClickListener(new View.OnClickListener(){
                   @Override
                   public void onClick(View v) {
                       //添加到购物车
                       Toast.makeText(Latte.getApplication(), goodsName + "已经加入购物车", Toast.LENGTH_SHORT).show();
                    final CircleImageView circleImageView = new CircleImageView(Latte.getApplication());
                    Glide.with(Latte.getApplication())
		                    .applyDefaultRequestOptions(RECYCLE_OPTIONS)
		                    .load(goodsThumb)
		                    .into(circleImageView);
                    final FrameLayout fromView = helper.getView(R.id.fl_section_shopcart);
                    float[] minPosition = new float[2];
                    minPosition[0] = 0;
                    minPosition[1] = -500;
                    float[] targetPosition = new float[2];
                    targetPosition[0] = 0;
                    targetPosition[1] = 2000;
                    BazierAnimation.addToShopCart(circleImageView, fromView, minPosition, targetPosition);
                   }
               });
               break;
           default:
               break;
       }
}
 
Example 14
Source File: AxgleAdapter.java    From v9porn with MIT License 4 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, AxgleVideo item) {
    helper.setText(R.id.tv_item_axgle_title, item.getTitle());
    AppCompatImageView imageView = helper.getView(R.id.iv_item_axgle_img);
    GlideApp.with(helper.itemView).load(item.getPreview_url()).placeholder(R.drawable.placeholder).transition(new DrawableTransitionOptions().crossFade(300)).into(imageView);
}
 
Example 15
Source File: DownloadVideoAdapter.java    From v9porn with MIT License 4 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, V9PornItem item) {
    helper.setText(R.id.tv_91porn_item_title, item.getTitleWithDuration());
    ImageView simpleDraweeView = helper.getView(R.id.iv_91porn_item_img);
    Uri uri = Uri.parse(item.getImgUrl());
    GlideApp.with(helper.itemView).load(uri).placeholder(R.drawable.placeholder).transition(new DrawableTransitionOptions().crossFade(300)).into(simpleDraweeView);
    helper.setProgress(R.id.progressBar_download, item.getProgress());
    helper.setText(R.id.tv_download_progress, String.valueOf(item.getProgress()) + "%");
    helper.setText(R.id.tv_download_filesize, Formatter.formatFileSize(helper.itemView.getContext(), item.getSoFarBytes()).replace("MB", "") + "/ " + Formatter.formatFileSize(helper.itemView.getContext(), item.getTotalFarBytes()));
    if (item.getStatus() == FileDownloadStatus.completed) {
        helper.setText(R.id.tv_download_speed, "已完成");
        helper.setVisible(R.id.iv_download_control, false);
    } else {
        //未下载完成,显示控制
        helper.setVisible(R.id.iv_download_control, true);
        if (FileDownloader.getImpl().isServiceConnected()) {
            helper.setImageResource(R.id.iv_download_control, R.drawable.pause_download);
            if (item.getStatus() == FileDownloadStatus.progress) {
                helper.setText(R.id.tv_download_speed, item.getSpeed() + " KB/s");
            } else if (item.getStatus() == FileDownloadStatus.paused) {
                helper.setText(R.id.tv_download_speed, "暂停中");
                helper.setImageResource(R.id.iv_download_control, R.drawable.start_download);
            } else if (item.getStatus() == FileDownloadStatus.pending) {
                helper.setText(R.id.tv_download_speed, "准备中");
            } else if (item.getStatus() == FileDownloadStatus.started) {
                helper.setText(R.id.tv_download_speed, "开始下载");
            } else if (item.getStatus() == FileDownloadStatus.connected) {
                helper.setText(R.id.tv_download_speed, "连接中");
            } else if (item.getStatus() == FileDownloadStatus.error) {
                helper.setText(R.id.tv_download_speed, "下载错误");
                helper.setImageResource(R.id.iv_download_control, R.drawable.start_download);
            } else if (item.getStatus() == FileDownloadStatus.retry) {
                helper.setText(R.id.tv_download_speed, "重试中");
            } else if (item.getStatus() == FileDownloadStatus.warn) {
                helper.setText(R.id.tv_download_speed, "警告");
                helper.setImageResource(R.id.iv_download_control, R.drawable.start_download);
            }

        } else {
            helper.setText(R.id.tv_download_speed, "暂停中");
            helper.setImageResource(R.id.iv_download_control, R.drawable.start_download);
        }
    }
    helper.addOnClickListener(R.id.iv_download_control);
    helper.addOnClickListener(R.id.right_menu_delete);
}
 
Example 16
Source File: SelectSdcardAdapter.java    From AndroidDownload with Apache License 2.0 4 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, String item) {
    helper.setText(R.id.tv_item_select_sdcard,item);
}
 
Example 17
Source File: AppKeyConfigAdapter.java    From VideoOS-Android-SDK with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, ConfigBean item) {
    String appKey = item.getAppKey();
    helper.setText(R.id.info_config, TextUtils.isEmpty(appKey) ? "" : appKey);
}
 
Example 18
Source File: PxgavAdapter.java    From v9porn with MIT License 4 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, PxgavModel item) {
    helper.setText(R.id.tv_item_pig_av_title, item.getTitle());
    AppCompatImageView imageView = helper.getView(R.id.iv_item_pig_av_img);
    GlideApp.with(helper.itemView).load(item.getImgUrl()).placeholder(R.drawable.placeholder).transition(new DrawableTransitionOptions().crossFade(300)).into(imageView);
}
 
Example 19
Source File: TrendAdapter.java    From JianshuApp with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void convert(BaseViewHolder holder, TrendArticle entity) {
    holder.setText(R.id.last_compiled_time, formatTime(entity.getPublishTime()));
    holder.setText(R.id.collection_tag, getSubjectTitle(entity));

    String avatarUrl = getAvatar(entity);
    if (!TextUtils.isEmpty(avatarUrl)) {
        UniversalDraweeView draweeViewAuthorAvatar = holder.getView(R.id.author_avatar);
        draweeViewAuthorAvatar.setImageURI(avatarUrl);
    }

    TextView tvAuthorName = holder.getView(R.id.author_name);
    TextView tvTitle = holder.getView(R.id.title);
    TextView tvExtraInfo = holder.getView(R.id.extra_info);
    UniversalDraweeView draweeViewImage = holder.getView(R.id.image);
    RelativeLayout rlAvatarName = holder.getView(R.id.avatar_name);
    FrameLayout flCollectionTagContainer = holder.getView(R.id.collection_tag_container);

    boolean shouldSetSelected = ArticleDetailDao.isRead(entity.getId());
    String userNickname = getNickname(entity);
    if (!TextUtils.isEmpty(userNickname)) {
        tvAuthorName.setText(userNickname);
        tvAuthorName.setSelected(shouldSetSelected);
    }
    tvTitle.setText(entity.getTitle());
    tvTitle.setSelected(shouldSetSelected);
    tvExtraInfo.setText(getExtraInfo(entity));
    tvExtraInfo.setCompoundDrawablesWithIntrinsicBounds(entity.isHasVideo() ? mDefaultVideoIcon : null, null, null, null);
    if (TextUtils.isEmpty(entity.getImage())) {
        draweeViewImage.setVisibility(View.GONE);
    } else {
        draweeViewImage.setVisibility(View.VISIBLE);
        String thumbUrl = ImageUtils.format(entity.getImage(), DisplayInfo.dp2px(80));
        draweeViewImage.setImageURI(thumbUrl);
    }

    rlAvatarName.setTag(holder.getLayoutPosition());
    rlAvatarName.setOnClickListener(this);

    flCollectionTagContainer.setTag(holder.getLayoutPosition());
    flCollectionTagContainer.setOnClickListener(this);
    if (TextUtils.isEmpty(getSubjectTitle(entity))) {
        flCollectionTagContainer.setVisibility(View.GONE);
    } else {
        flCollectionTagContainer.setVisibility(View.VISIBLE);
    }

    holder.setTag(R.id.root_view, holder.getLayoutPosition());
    holder.setOnClickListener(R.id.root_view, this);
}
 
Example 20
Source File: AnimationAty.java    From KUtils with Apache License 2.0 2 votes vote down vote up
/**
 * Implement this method and use the helper to adapt the view to the given item.
 *
 * @param helper A fully initialized helper.
 * @param item   The item that needs to be displayed.
 */
@Override
protected void convert(BaseViewHolder helper, String item) {
    helper.setText(R.id.tv_title, item.substring(item.lastIndexOf(".") + 1));
    helper.setTag(R.id.tv_title,Techniques.values()[helper.getPosition()]);
}