Java Code Examples for com.chad.library.adapter.base.BaseViewHolder#setImageDrawable()
The following examples show how to use
com.chad.library.adapter.base.BaseViewHolder#setImageDrawable() .
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: OperationListAdapter.java From Focus with GNU General Public License v3.0 | 6 votes |
@Override protected void convert(BaseViewHolder helper, Operation item) { helper.setText(R.id.name,item.getName()); if (StringUtil.trim(item.getInfo()).equals("")){ helper.setText(R.id.info,item.getInfo()); }else { helper.setGone(R.id.text_info,true); } if (item.getDrawable()!=null){ helper.setGone(R.id.icon,true); helper.setImageDrawable(R.id.icon, item.getDrawable()); }else { helper.setGone(R.id.icon,false); } }
Example 2
Source File: OperationListAdapter.java From Focus with GNU General Public License v3.0 | 6 votes |
@Override protected void convert(BaseViewHolder helper, Operation item) { helper.setText(R.id.name,item.getName()); if (StringUtil.trim(item.getInfo()).equals("")){ helper.setText(R.id.info,item.getInfo()); }else { helper.setGone(R.id.text_info,true); } if (item.getDrawable()!=null){ helper.setGone(R.id.icon,true); helper.setImageDrawable(R.id.icon, item.getDrawable()); }else { helper.setGone(R.id.icon,false); } }
Example 3
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 4
Source File: WeChatAdapter.java From WanAndroid with Apache License 2.0 | 6 votes |
@Override protected void convert(BaseViewHolder holder, Article article) { if(article == null) return; holder.setText(R.id.tv_title, Html.fromHtml(article.getTitle())) .setText(R.id.tv_author, "作者:" + article.getAuthor()) .setText(R.id.tv_classify, "分类:" + article.getChapterName()) .setText(R.id.tv_publish_time, article.getNiceDate()) .addOnClickListener(R.id.iv_collection); if(article.isCollect()){ holder.setImageDrawable( R.id.iv_collection, CommonUtil.getTintDrawable( Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.drawable.ic_home_collection)), ColorStateList.valueOf(ContextCompat.getColor(mContext, R.color.colorCollected)) ) ); } else{ holder.setImageResource(R.id.iv_collection, R.drawable.ic_home_collection); } }
Example 5
Source File: ProjectsAdapter.java From WanAndroid with Apache License 2.0 | 6 votes |
@Override protected void convert(BaseViewHolder holder, Article article) { if(article == null) return; holder.setText(R.id.tv_title, Html.fromHtml(article.getTitle())) .setText(R.id.tv_details, article.getDesc()) .setText(R.id.tv_author, "作者:" + article.getAuthor()) .setText(R.id.tv_publish_time, article.getNiceDate()) .addOnClickListener(R.id.iv_collection); ImageUtil.loadImage(mContext, (ImageView)holder.getView(R.id.iv_image), article.getEnvelopePic()); if(article.isCollect()){ holder.setImageDrawable( R.id.iv_collection, CommonUtil.getTintDrawable( Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.drawable.ic_home_collection)), ColorStateList.valueOf(ContextCompat.getColor(mContext, R.color.colorCollected)) ) ); } else{ holder.setImageResource(R.id.iv_collection, R.drawable.ic_home_collection); } }
Example 6
Source File: TodayAdapter.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
private void updateUIByCompletedState(BaseViewHolder helper, Assignment assignment) { boolean completed = assignment.getProgress() == 100; helper.setImageDrawable(R.id.iv_completed, ColorUtils.tintDrawable(PalmApp.getDrawableCompact( completed ? R.drawable.ic_check_box_black_24dp : R.drawable.ic_check_box_outline_blank_black_24dp), ColorUtils.accentColor())); ViewHelper.setAlpha(helper.itemView, completed ? 0.4F : 1F); TextView tvTitle = helper.getView(R.id.tv_title); TextView tvCreatedTime = helper.getView(R.id.tv_time_info); tvTitle.setPaintFlags(completed ? tvTitle.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG : tvTitle.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG)); tvCreatedTime.setPaintFlags(completed ? tvCreatedTime.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG : tvCreatedTime.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG)); }
Example 7
Source File: ModelsPickerAdapter.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void convert(BaseViewHolder helper, T item) { helper.setText(R.id.tv_title, modelsPickerStrategy.getTitle(item)); helper.setText(R.id.tv_sub_title, modelsPickerStrategy.getSubTitle(item)); helper.setVisible(R.id.iv_more, modelsPickerStrategy.shouldShowMore()); helper.setImageDrawable(R.id.iv_icon, modelsPickerStrategy.getIconDrawable(item)); if (modelsPickerStrategy.isMultiple() && item.isSelected()) { helper.itemView.setBackgroundColor(getSelectedColor()); } else { helper.itemView.setBackgroundColor(Color.TRANSPARENT); } }
Example 8
Source File: SubAssignmentsAdapter.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
private void convertBody(BaseViewHolder helper, SubAssignment subAssignment) { SubAssignmentType subAssignmentType = subAssignment.getSubAssignmentType(); boolean showIcon = subAssignmentType == SubAssignmentType.TODO || subAssignmentType == SubAssignmentType.NOTE_WITH_PORTRAIT; helper.addOnClickListener(R.id.tv_sub_assignment); helper.addOnClickListener(R.id.iv_sub_assignment); helper.addOnClickListener(R.id.tv_sub_assignment_note); helper.getView(R.id.tv_sub_assignment).setVisibility(showIcon ? View.VISIBLE : View.GONE); helper.getView(R.id.iv_sub_assignment).setVisibility(showIcon ? View.VISIBLE : View.GONE); helper.getView(R.id.tv_sub_assignment_note).setVisibility(showIcon ? View.GONE : View.VISIBLE); helper.getView(R.id.divider_note).setVisibility(showIcon ? View.GONE : View.VISIBLE); helper.getView(R.id.divider_todo).setVisibility(showIcon ? View.VISIBLE : View.GONE); TextView tvSub = helper.getView(R.id.tv_sub_assignment); tvSub.setText(subAssignment.getContent()); tvSub.setAutoLinkMask(Linkify.ALL); tvSub.setMovementMethod(LinkMovementMethod.getInstance()); tvSub.setPaintFlags(subAssignment.isCompleted() ? tvSub.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG : tvSub.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG)); ViewUtils.setAlpha(tvSub, subAssignment.isCompleted() ? 0.4F : 1F); helper.setImageDrawable(R.id.iv_sub_assignment, ColorUtils.tintDrawable(PalmApp.getDrawableCompact( subAssignmentType == SubAssignmentType.TODO ? subAssignment.isCompleted() ? R.drawable.ic_check_box_black_24dp : R.drawable.ic_check_box_outline_blank_black_24dp : subAssignment.getPortrait().iconRes), ColorUtils.accentColor())); helper.setText(R.id.tv_sub_assignment_note, subAssignment.getContent()); }
Example 9
Source File: AssignmentsAdapter.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
private void updateUIByCompletedState(BaseViewHolder helper, Assignment assignment) { boolean completed = assignment.getProgress() == 100; helper.setImageDrawable(R.id.iv_completed, ColorUtils.tintDrawable( PalmApp.getDrawableCompact(completed ? R.drawable.ic_check_box_black_24dp : R.drawable.ic_check_box_outline_blank_black_24dp), ColorUtils.accentColor())); ViewHelper.setAlpha(helper.itemView, completed ? 0.4F : 1F); TextView tvTitle = helper.getView(R.id.tv_title); TextView tvCreatedTime = helper.getView(R.id.tv_time_info); tvTitle.setPaintFlags(completed ? tvTitle.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG : tvTitle.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG)); tvCreatedTime.setPaintFlags(completed ? tvCreatedTime.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG : tvCreatedTime.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG)); }
Example 10
Source File: ArticlesAdapter.java From WanAndroid with Apache License 2.0 | 5 votes |
@Override protected void convert(BaseViewHolder holder, Article article) { if(article == null) return; holder.setText(R.id.tv_title, Html.fromHtml(article.getTitle())) .setText(R.id.tv_author, "作者:" + article.getAuthor()) .setText(R.id.tv_classify, "分类:" + article.getChapterName()) .setText(R.id.tv_publish_time, article.getNiceDate()) .addOnClickListener(R.id.iv_collection); if(article.isCollect()){ holder.setImageDrawable( R.id.iv_collection, CommonUtil.getTintDrawable( Objects.requireNonNull(ContextCompat.getDrawable(mContext, R.drawable.ic_home_collection)), ColorStateList.valueOf(ContextCompat.getColor(mContext, R.color.colorCollected)) ) ); } else{ holder.setImageResource(R.id.iv_collection, R.drawable.ic_home_collection); } TextView textView = holder.getView(R.id.tv_tags); textView.setVisibility(View.VISIBLE); if(article.isFresh()){ Drawable freshDrawable = ContextCompat.getDrawable(mContext, R.drawable.bg_tag_tv1); ViewCompat.setBackground(textView, freshDrawable); textView.setText("最新"); textView.setTextColor(ContextCompat.getColor(mContext, R.color.colorTag1)); }else if(!CommonUtil.isEmptyList(article.getTags())){ Drawable tagDrawable = ContextCompat.getDrawable(mContext, R.drawable.bg_tag_tv2); ViewCompat.setBackground(textView, tagDrawable); textView.setText(article.getTags().get(0).getName()); textView.setTextColor(ContextCompat.getColor(mContext, R.color.colorTag2)); }else { textView.setVisibility(View.INVISIBLE); } }
Example 11
Source File: DirectoriesAdapter.java From OmniList with GNU Affero General Public License v3.0 | 4 votes |
@Override protected void convert(BaseViewHolder helper, Directory item) { if (ColorUtils.isDarkTheme()) helper.itemView.setBackgroundResource(R.color.dark_theme_background); helper.setText(R.id.tv_title, item.getName()); helper.setImageDrawable(R.id.iv_icon, getDirIcon()); }