Java Code Examples for com.chad.library.adapter.base.BaseViewHolder#setTextColor()
The following examples show how to use
com.chad.library.adapter.base.BaseViewHolder#setTextColor() .
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: ZhihuAdapter.java From YiZhi with Apache License 2.0 | 6 votes |
@Override protected void convert(final BaseViewHolder helper, ZhihuDailyItemBean item) { if (DBUtils.getDB(mContext).isRead(DBConfig.TABLE_ZHIHU, item.getId(), ItemState .STATE_IS_READ)) { helper.setTextColor(R.id.tv_item_title, Color.GRAY); } else { if (SpUtils.getNightModel(mContext)) { helper.setTextColor(R.id.tv_item_title, Color.WHITE); } else { helper.setTextColor(R.id.tv_item_title, Color.BLACK); } } helper.setText(R.id.tv_item_title, item.getTitle()); Glide.with(mContext).load(item.getImages()[0]).crossFade().into((ImageView) helper.getView(R .id.iv_item_image)); }
Example 2
Source File: LivePlayChatAdapter.java From C9MJ with Apache License 2.0 | 6 votes |
@Override protected void convert(BaseViewHolder viewHolder, DanmuBean bean) { String name = TextUtils.isEmpty(bean.getData().getFrom().getNickName()) ? bean.getData().getFrom().getUserName() : bean.getData().getFrom().getNickName(); if (TextUtils.isEmpty(name)) { name = "游客"; } String content = bean.getData().getContent(); viewHolder.setText(R.id.tv_nickname, name)//昵称 .setTextColor(R.id.tv_nickname, ContextCompat.getColor(mContext, R.color.color_primary_dark)) .setText(R.id.tv_content, content);//弹幕内容 if (!TextUtils.isEmpty(name) && mContext != null) { if (name.equals(mContext.getString(R.string.chat_name))) { viewHolder.setTextColor(R.id.tv_nickname, ContextCompat.getColor(mContext, R.color.color_accent)); } } }
Example 3
Source File: BookAdapter.java From SmallGdufe-Android with GNU General Public License v3.0 | 6 votes |
@Override protected void convert(final BaseViewHolder viewHolder, Book item) { viewHolder.setText(R.id.tv_book_bookName,item.getName()+" / "+item.getAuthor()) .setText(R.id.tv_book_barId,""+item.getBarId()) .setText(R.id.tv_book_borrowedTime,""+item.getBorrowedTime()) .setText(R.id.tv_book_returnTime, item.getReturnTime()) .setText(R.id.tv_book_location, item.getLocation()) .addOnClickListener(R.id.tv_book_renew) ; //当前借阅的情况下考虑显示续借按钮和过期书籍的红色字体显示 if(doWhat == BookActivity.doCurrentBook){ if(curTime > TimeUtils.timeString2TimeStamp(item.getReturnTime()) ){ //过期书籍 viewHolder.setTextColor(R.id.tv_book_returnTime, mContext.getResources().getColor(R.color.goal_item_failed_color)); }else{ viewHolder.setVisible(R.id.tv_book_renew,item.getRenewTimes() == 0); //当前借阅且是未到期情况下 续借按钮可见 viewHolder.setTextColor(R.id.tv_book_returnTime, mContext.getResources().getColor(R.color.normal_item_text_color)); //恢复颜色,不然会显示bug,这个adapter框架的问题 } }else{ viewHolder.setVisible(R.id.tv_book_renew,false); //BaseQuickAdapter的bug,还是得手动设置 } }
Example 4
Source File: WangyiAdapter.java From YiZhi with Apache License 2.0 | 6 votes |
@Override protected void convert(BaseViewHolder helper, WangyiNewsItemBean item) { if (DBUtils.getDB(mContext).isRead(DBConfig.TABLE_WANGYI, item.getDocid(), ItemState .STATE_IS_READ)) { helper.setTextColor(R.id.tv_item_title, Color.GRAY); } else { if (SpUtils.getNightModel(mContext)) { helper.setTextColor(R.id.tv_item_title, Color.WHITE); } else { helper.setTextColor(R.id.tv_item_title, Color.BLACK); } } helper.setText(R.id.tv_item_title, item.getTitle()); helper.setText(R.id.tv_item_who, item.getSource()); helper.setText(R.id.tv_item_time, item.getPtime()); Glide.with(mContext).load(item.getImgsrc()).crossFade().into((ImageView) helper.getView(R .id.iv_item_image)); }
Example 5
Source File: WeixinAdapter.java From YiZhi with Apache License 2.0 | 6 votes |
@Override protected void convert(BaseViewHolder helper, WeixinChoiceItemBean item) { if (DBUtils.getDB(mContext).isRead(DBConfig.TABLE_WEIXIN, item.getId(), ItemState .STATE_IS_READ)) { helper.setTextColor(R.id.tv_item_title, Color.GRAY); } else { if (SpUtils.getNightModel(mContext)) { helper.setTextColor(R.id.tv_item_title, Color.WHITE); } else { helper.setTextColor(R.id.tv_item_title, Color.BLACK); } } helper.setText(R.id.tv_item_title, item.getTitle()); helper.setText(R.id.tv_item_who, item.getSource()); Glide.with(mContext).load(item.getFirstImg()).crossFade().into((ImageView) helper.getView(R .id.iv_item_image)); }
Example 6
Source File: UserFeedPostsVerticalAdapter.java From Focus with GNU General Public License v3.0 | 6 votes |
private void updateUI(final BaseViewHolder helper,FeedItem item){ if (item.isRead()){ // ALog.d("是否已读" + item.isRead()); helper.setTextColor(R.id.post_title,activity.getResources().getColor(read_color)); helper.setTextColor(R.id.rss_name,activity.getResources().getColor(read_content_color)); helper.setTextColor(R.id.post_summay,activity.getResources().getColor(read_content_color)); helper.setTextColor(R.id.post_time,activity.getResources().getColor(read_content_color)); // helper.setText(R.id.markRead,"标记未读"); }else { helper.setTextColor(R.id.post_title,activity.getResources().getColor(not_read_color)); helper.setTextColor(R.id.rss_name,activity.getResources().getColor(not_read_content_color)); helper.setTextColor(R.id.post_summay,activity.getResources().getColor(not_read_content_color)); helper.setTextColor(R.id.post_time,activity.getResources().getColor(not_read_content_color)); // helper.setText(R.id.markRead,"标记已读"); } if (item.isFavorite()){ helper.getView(R.id.favorite).setVisibility(View.VISIBLE); // helper.setText(R.id.star,"取消收藏"); }else { helper.getView(R.id.favorite).setVisibility(View.GONE); // helper.setText(R.id.star,"收藏"); } }
Example 7
Source File: ThemesAdapter.java From OmniList with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void convert(BaseViewHolder helper, Colorful.ThemeColor themeColor) { int primaryColor = context.getResources().getColor(themeColor.getColorRes()); helper.setImageResource(R.id.civ_color, themeColor.getColorRes()); helper.setText(R.id.tv_theme_name, themeColor.getDisplayName()); helper.setTextColor(R.id.tv_theme_name, primaryColor); if (selectedTheme != null && themeColor.getIdentifyName().equals(selectedTheme.getIdentifyName())) { helper.setVisible(R.id.civ_checked_bg, true); helper.setImageResource(R.id.civ_checked_bg, isDarkTheme ? R.color.dark_theme_background : R.color.light_theme_background); helper.setVisible(R.id.iv_checked, true); helper.setImageDrawable(R.id.iv_checked, ColorUtils.tintDrawable( context.getResources().getDrawable(R.drawable.ic_check_circle_black_24dp), primaryColor)); ((CircleImageView) helper.getView(R.id.civ_selected)).setFillingCircleColor(primaryColor); } else { helper.setVisible(R.id.civ_checked_bg, false); helper.setVisible(R.id.iv_checked, false); ((CircleImageView) helper.getView(R.id.civ_selected)).setFillingCircleColor(Color.LTGRAY); } }
Example 8
Source File: UserFeedPostsVerticalAdapter.java From Focus with GNU General Public License v3.0 | 6 votes |
private void updateUI(final BaseViewHolder helper,FeedItem item){ if (item.isRead()){ // ALog.d("是否已读" + item.isRead()); helper.setTextColor(R.id.post_title,activity.getResources().getColor(read_color)); helper.setTextColor(R.id.rss_name,activity.getResources().getColor(read_content_color)); helper.setTextColor(R.id.post_summay,activity.getResources().getColor(read_content_color)); helper.setTextColor(R.id.post_time,activity.getResources().getColor(read_content_color)); // helper.setText(R.id.markRead,"标记未读"); }else { helper.setTextColor(R.id.post_title,activity.getResources().getColor(not_read_color)); helper.setTextColor(R.id.rss_name,activity.getResources().getColor(not_read_content_color)); helper.setTextColor(R.id.post_summay,activity.getResources().getColor(not_read_content_color)); helper.setTextColor(R.id.post_time,activity.getResources().getColor(not_read_content_color)); // helper.setText(R.id.markRead,"标记已读"); } if (item.isFavorite()){ helper.getView(R.id.favorite).setVisibility(View.VISIBLE); // helper.setText(R.id.star,"取消收藏"); }else { helper.getView(R.id.favorite).setVisibility(View.GONE); // helper.setText(R.id.star,"收藏"); } }
Example 9
Source File: SubAssignmentsAdapter.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
private void convertHeader(BaseViewHolder helper) { helper.addOnClickListener(R.id.tv_title); helper.addOnClickListener(R.id.ll_alarm); helper.addOnClickListener(R.id.siv_clear); helper.setTextColor(R.id.tv_title, ColorUtils.primaryColor()); helper.setText(R.id.tv_title, TextUtils.isEmpty(title) ? PalmApp.getStringCompact(R.string.click_to_add_title) : title); helper.setText(R.id.tv_assignment_alarm, alarm == null ? PalmApp.getStringCompact(R.string.set_date_and_notifications) : alarm.getAlarmInfo(mContext)); helper.getView(R.id.siv_clear).setVisibility(alarm == null ? View.GONE : View.VISIBLE); }
Example 10
Source File: TimeLinesAdapter.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void convert(BaseViewHolder helper, TimeLine timeLine) { helper.setText(R.id.tv, getOperation(timeLine)); helper.setImageResource(R.id.iv_operation, timeLine.getModelType().drawableRes); ((CircleImageView) helper.getView(R.id.civ)).setFillingCircleColor( UserPreferences.getInstance().getTimeLineColor(timeLine.getOperation())); helper.setText(R.id.tv_date, TimeUtils.getShortDate(context, timeLine.getAddedTime())); helper.setText(R.id.tv_time, TimeUtils.shortTime(timeLine.getAddedTime())); helper.setText(R.id.tv_sub, timeLine.getModelName()); helper.setTextColor(R.id.tv_sub, ColorUtils.accentColor()); ((Timeline) helper.getView(R.id.timeLine)).setAtomDrawable(atomDrawable()); }
Example 11
Source File: ExampleBasicFragment.java From SmartRefreshHorizontal with Apache License 2.0 | 5 votes |
@Override protected void convert(BaseViewHolder holder, Void item) { int position = holder.getAdapterPosition(); holder.itemView.getLayoutParams().width = -2;//DensityUtil.dp2px(100); holder.itemView.getLayoutParams().height = -1; holder.itemView.setBackgroundResource(colorIds[position%colorIds.length]); holder.setText(android.R.id.text1, getString(R.string.item_example_number_title, position)); holder.setTextColor(android.R.id.text1, 0xffffffff); }
Example 12
Source File: GankIoCustomAdapter.java From YiZhi with Apache License 2.0 | 5 votes |
private void initTitleColor(BaseViewHolder helper, GankIoCustomItemBean item) { if (DBUtils.getDB(mContext).isRead(DBConfig.TABLE_GANKIO_CUSTOM, item.getType() + item .get_id(), ItemState.STATE_IS_READ)) { helper.setTextColor(R.id.tv_item_title, Color.GRAY); } else { if (SpUtils.getNightModel(mContext)) { helper.setTextColor(R.id.tv_item_title, Color.WHITE); } else { helper.setTextColor(R.id.tv_item_title, Color.BLACK); } } }
Example 13
Source File: CardHistoryAdapter.java From SmallGdufe-Android with GNU General Public License v3.0 | 5 votes |
@Override protected void convert(final BaseViewHolder viewHolder, CardConsumeItem item) { viewHolder.setText(R.id.tv_item_card_shop,item.getShop()) .setText(R.id.tv_item_card_time,item.getTime()) .setText(R.id.tv_item_card_cash,""+item.getCash()) .setText(R.id.tv_item_card_amount,""+item.getChange()); if(item.getChange().charAt(0) != '-'){ viewHolder.setTextColor(R.id.tv_item_card_amount, mContext.getResources().getColor(R.color.goal_item_passed_color)); }else{ viewHolder.setTextColor(R.id.tv_item_card_amount, mContext.getResources().getColor(R.color.goal_item_failed_color)); } }
Example 14
Source File: SearchBookStoreAdapter.java From SmallGdufe-Android with GNU General Public License v3.0 | 5 votes |
@Override protected void convert(final BaseViewHolder viewHolder, SearchBookStoreItem item) { viewHolder.setText(R.id.tv_search_book_store_barId, item.getBarId()) .setText(R.id.tv_search_book_location, "" + item.getLocation()) .setText(R.id.tv_search_book_volume, "" + item.getVolume()) .setText(R.id.tv_search_book_state, item.getState()) .setText(R.id.tv_search_book_store_serial, item.getSerial()) ; if(item.getState().equals("可借")){ viewHolder.setTextColor(R.id.tv_search_book_state, mContext.getResources().getColor(R.color.goal_item_passed_color)); } }
Example 15
Source File: ScoreAdapter.java From SmallGdufe-Android with GNU General Public License v3.0 | 5 votes |
private void colorTextViewByScore(BaseViewHolder viewHolder,int textViewId, int score) { if( score < 60) { viewHolder.setTextColor(textViewId, mContext.getResources().getColor(R.color.goal_item_failed_color)); // if(textViewId == R.id.tv_score){ //给标题加红的话,下拉上滑后就乱标红色了,框架的复用item有问题 // viewHolder.setTextColor(R.id.tv_course_name, mContext.getResources().getColor(R.color.goal_item_failed_color)); // }else{ // viewHolder.setTextColor(R.id.tv_course_name, mContext.getResources().getColor(R.color.normal_item_passed_text_color)); // } }else{ viewHolder.setTextColor(textViewId, mContext.getResources().getColor(R.color.goal_item_passed_color)); } }
Example 16
Source File: VerifyBackupMnemonicWordsAdapter.java From Upchain-wallet with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void convert(BaseViewHolder helper, VerifyMnemonicWordTag verifyMnemonicWordTag) { if (verifyMnemonicWordTag.isSelected()) { helper.setBackgroundColor(R.id.lly_tag, mContext.getResources().getColor(R.color.search_ico_upload_token)); helper.setTextColor(R.id.tv_mnemonic_word,mContext.getResources().getColor(R.color.white)); } else { helper.setBackgroundColor(R.id.lly_tag, mContext.getResources().getColor(R.color.item_divider_bg_color)); helper.setTextColor(R.id.tv_mnemonic_word,mContext.getResources().getColor(R.color.discovery_application_text_color)); } helper.setText(R.id.tv_mnemonic_word, verifyMnemonicWordTag.getMnemonicWord()); }
Example 17
Source File: TodayAdapter.java From OmniList with GNU Affero General Public License v3.0 | 4 votes |
private void convertHeader(BaseViewHolder helper, MultiItem item) { helper.setText(R.id.tv_section_title, item.title); helper.setTextColor(R.id.tv_section_title, ColorUtils.primaryColor()); }
Example 18
Source File: TransactionsAdapter.java From Upchain-wallet with GNU Affero General Public License v3.0 | 4 votes |
@Override protected void convert(BaseViewHolder helper, Transaction transaction) { LogUtils.d(TAG, "convert: helper:" + helper + ", transaction:" + transaction); boolean isSent = transaction.from.toLowerCase().equals(defaultAddress.toLowerCase()); boolean isCreateContract = TextUtils.isEmpty(transaction.to); if (isSent) { if (isCreateContract) { helper.setText(R.id.type, R.string.create); } else { helper.setText(R.id.type, R.string.sent); } } else { helper.setText(R.id.type, R.string.received); } if (!TextUtils.isEmpty(transaction.error)) { helper.setImageResource(R.id.type_icon, R.drawable.ic_error_outline_black_24dp); } else if (isSent) { helper.setImageResource(R.id.type_icon, R.drawable.ic_arrow_upward_black_24dp); } else { helper.setImageResource(R.id.type_icon, R.drawable.ic_arrow_downward_black_24dp); } if (isCreateContract) { helper.setText(R.id.address, transaction.contract); } else { helper.setText(R.id.address, isSent ? transaction.to : transaction.from); } helper.setTextColor(R.id.value, ContextCompat.getColor(mContext, isSent ? R.color.red : R.color.green)); String valueStr = ""; // If operations include token transfer, display token transfer instead TransactionOperation operation = transaction.operations == null || transaction.operations.length == 0 ? null : transaction.operations[0]; if (operation == null || operation.contract == null) { // default to ether transaction valueStr = transaction.value; if (valueStr.equals("0")) { valueStr = "0 " + symbol; } else { valueStr = (isSent ? "-" : "+") + getScaledValue(valueStr, ETHER_DECIMALS) + " " + symbol; } } else { valueStr = operation.value; if (valueStr.equals("0")) { valueStr = "0 " + symbol; } else { valueStr = (isSent ? "-" : "+") + getScaledValue(valueStr, operation.contract.decimals) + " " + symbol; } } helper.setText(R.id.value, valueStr); }