Java Code Examples for com.chad.library.adapter.base.BaseViewHolder#addOnClickListener()
The following examples show how to use
com.chad.library.adapter.base.BaseViewHolder#addOnClickListener() .
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: RvNoteListAdapter.java From SuperNote with GNU General Public License v3.0 | 6 votes |
/** * 设置线性布局 * * @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); }
Example 2
Source File: AlbumImgAdapter.java From ImageLoader with Apache License 2.0 | 6 votes |
@Override protected void convert(@NonNull final BaseViewHolder helper, final Image item) { helper.getView(R.id.item_iv).setTag(R.id.item_iv,item); helper.addOnClickListener(R.id.item_iv); ImageLoader.with(helper.itemView.getContext()) .url(item.path) .loading(R.drawable.iv_loading_trans) .error(R.drawable.im_item_list_opt_error) .into(helper.getView(R.id.item_iv)); if(item.width != 0){ helper.setText(R.id.tv_info,item.width+"x"+item.height+","+ MyUtil.formatFileSize(item.fileSize)); }else { int[] wh = MyUtil.getImageWidthHeight(item.path); item.width = wh[0]; item.height = wh[1]; item.fileSize = new File(item.path).length(); helper.setText(R.id.tv_info,item.width+"x"+item.height+","+ MyUtil.formatFileSize(item.fileSize)); } }
Example 3
Source File: AssignmentsAdapter.java From OmniList with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void convert(BaseViewHolder helper, Assignment assignment) { helper.itemView.setBackgroundColor(PalmApp.getColorCompact(ColorUtils.isDarkTheme() ? R.color.dark_theme_background : R.color.light_theme_background)); helper.setText(R.id.tv_title, assignment.getName()); updateUIByCompletedState(helper, assignment); helper.addOnClickListener(R.id.iv_completed); helper.addOnClickListener(R.id.rl_item); helper.setImageResource(R.id.iv_priority, assignment.getPriority().iconRes); String strCreatedTime = mContext.getString(R.string.text_last_modified_time) + ": " + TimeUtils.getPrettyTime(assignment.getLastModifiedTime()); helper.setText(R.id.tv_time_info, strCreatedTime); helper.getView(R.id.iv_files).setVisibility(assignment.getAttachments() != 0 ? View.VISIBLE : View.GONE); helper.getView(R.id.iv_alarm).setVisibility(assignment.getAlarms() != 0 ? View.VISIBLE : View.GONE); }
Example 4
Source File: FavoriteAdapter.java From v9porn with MIT License | 5 votes |
@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 5
Source File: HomeAdapter.java From XMVP with Apache License 2.0 | 5 votes |
@Override protected void convert(final BaseViewHolder baseViewHolder, final FileEntity multiItemEntity) { TextView name = baseViewHolder.getView(R.id.name); baseViewHolder.addOnClickListener(R.id.name); name.setText(multiItemEntity.getFile().getName()); final int level = multiItemEntity.getLevel(); if (level < bgRes.size()) { name.setBackgroundResource(bgRes.get(level)); } RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) name.getLayoutParams(); params.leftMargin = (level + 1) * App.getInstanse().getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin); name.setLayoutParams(params); // Log.e("convert", multiItemEntity.getLevel() + "; file = " + multiItemEntity.getFile()); // expandAll(baseViewHolder.getAdapterPosition(), true); name.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int pos = baseViewHolder.getAdapterPosition(); if (multiItemEntity.isExpanded()) { collapse(pos, false); } else { expand(pos, false); } File file = multiItemEntity.getFile(); if (listener != null && file.isFile()) { listener.open(file); } } }); }
Example 6
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 7
Source File: CategoriesAdapter.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
@Override protected void convert(BaseViewHolder helper, Category category) { final int categoryColor = category.getColor(); if (isDarkTheme) helper.itemView.setBackgroundResource(R.color.dark_theme_background); helper.setText(R.id.tv_title, category.getName()); helper.setText(R.id.tv_sub_title, context.getResources().getQuantityString(R.plurals.assignments_number, category.getCount(), category.getCount())); ((CircleImageView) helper.getView(R.id.iv_folder_background)).setFillingCircleColor(categoryColor); helper.addOnClickListener(R.id.iv_more); helper.setImageResource(R.id.iv_folder_portrait, category.getPortrait().iconRes); }
Example 8
Source File: HistoryAdapter.java From v9porn with MIT License | 5 votes |
@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: FavoriteAdapter.java From v9porn with MIT License | 5 votes |
@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 10
Source File: FeedFolderListMainAdapter.java From Focus with GNU General Public License v3.0 | 5 votes |
@Override protected void convert(BaseViewHolder helper, FeedFolder item) { helper.setText(R.id.title,item.getName()); helper.setGone(R.id.move_logo,false); helper.addOnClickListener(R.id.item_view); helper.getView(R.id.main_logo).setPadding(60,0,0,0); }
Example 11
Source File: EssMediaAdapter.java From FilePicker with MIT License | 5 votes |
@Override protected void convert(BaseViewHolder helper, EssFile item) { if (item.getItemType() == EssFile.CAPTURE) { helper.getView(R.id.media).setVisibility(View.GONE); helper.getView(R.id.capture).setVisibility(View.VISIBLE); helper.itemView.setLayoutParams(new ViewGroup.LayoutParams(mImageResize- UiUtils.dpToPx(mContext,4), mImageResize)); helper.addOnClickListener(R.id.capture); } else { helper.getView(R.id.capture).setVisibility(View.GONE); helper.getView(R.id.media).setVisibility(View.VISIBLE); helper.itemView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, mImageResize)); ImageView imageView = helper.getView(R.id.media_thumbnail); RequestOptions options = new RequestOptions() .centerCrop() .override(mImageResize, mImageResize) .placeholder(SelectOptions.getInstance().placeHolder == null ? mContext.getResources().getDrawable(R.mipmap.png_holder) : SelectOptions.getInstance().placeHolder); Glide .with(mContext) .load(item.getUri()) .apply(options) .into(imageView); if(SelectOptions.getInstance().isSingle || SelectOptions.getInstance().maxCount == 1){ helper.setVisible(R.id.check_view,false); }else { AppCompatCheckBox checkBox = helper.getView(R.id.check_view); helper.setVisible(R.id.check_view,true); helper.addOnClickListener(R.id.check_view); helper.addOnClickListener(R.id.media_thumbnail); checkBox.setChecked(item.isChecked()); } } }
Example 12
Source File: EssMediaAdapter.java From AndroidDownload with Apache License 2.0 | 5 votes |
@Override protected void convert(BaseViewHolder helper, EssFile item) { if (item.getItemType() == EssFile.CAPTURE) { helper.getView(R.id.media).setVisibility(View.GONE); helper.getView(R.id.capture).setVisibility(View.VISIBLE); helper.itemView.setLayoutParams(new ViewGroup.LayoutParams(mImageResize- UiUtils.dpToPx(mContext,4), mImageResize)); helper.addOnClickListener(R.id.capture); } else { helper.getView(R.id.capture).setVisibility(View.GONE); helper.getView(R.id.media).setVisibility(View.VISIBLE); helper.itemView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, mImageResize)); ImageView imageView = helper.getView(R.id.media_thumbnail); RequestOptions options = new RequestOptions() .centerCrop() .override(mImageResize, mImageResize) .placeholder(SelectOptions.getInstance().placeHolder == null ? mContext.getResources().getDrawable(R.mipmap.png_holder) : SelectOptions.getInstance().placeHolder); Glide .with(mContext) .load(item.getUri()) .apply(options) .into(imageView); if(SelectOptions.getInstance().isSingle || SelectOptions.getInstance().maxCount == 1){ helper.setVisible(R.id.check_view,false); }else { AppCompatCheckBox checkBox = helper.getView(R.id.check_view); helper.setVisible(R.id.check_view,true); helper.addOnClickListener(R.id.check_view); helper.addOnClickListener(R.id.media_thumbnail); checkBox.setChecked(item.isChecked()); } } }
Example 13
Source File: FeedFolderListMainAdapter.java From Focus with GNU General Public License v3.0 | 5 votes |
@Override protected void convert(BaseViewHolder helper, FeedFolder item) { helper.setText(R.id.title,item.getName()); helper.setGone(R.id.move_logo,false); helper.addOnClickListener(R.id.item_view); helper.getView(R.id.main_logo).setPadding(60,0,0,0); }
Example 14
Source File: ComplexAdapter.java From EasyPopup with Apache License 2.0 | 4 votes |
@Override protected void convert(BaseViewHolder helper, String item) { helper.setText(R.id.tv_complex_item,item); helper.addOnClickListener(R.id.btn_complex_delete); }
Example 15
Source File: TodayAdapter.java From OmniList with GNU Affero General Public License v3.0 | 4 votes |
private void convertAssignment(BaseViewHolder helper, Assignment assignment) { helper.itemView.setBackgroundColor(PalmApp.getColorCompact(ColorUtils.isDarkTheme() ? R.color.dark_theme_background : R.color.light_theme_background)); helper.setText(R.id.tv_title, assignment.getName()); updateUIByCompletedState(helper, assignment); helper.addOnClickListener(R.id.iv_completed); helper.addOnClickListener(R.id.rl_item); helper.setImageResource(R.id.iv_priority, assignment.getPriority().iconRes); String strCreatedTime = mContext.getString(R.string.text_last_modified_time) + ": " + TimeUtils.getPrettyTime(assignment.getLastModifiedTime()); helper.setText(R.id.tv_time_info, strCreatedTime); helper.getView(R.id.iv_files).setVisibility(assignment.getAttachments() != 0 ? View.VISIBLE : View.GONE); helper.getView(R.id.iv_alarm).setVisibility(assignment.getAlarms() != 0 ? View.VISIBLE : View.GONE); }
Example 16
Source File: CacheAdapter.java From Aurora with Apache License 2.0 | 4 votes |
@Override protected void convert(BaseViewHolder helper, VideoDownLoadInfo item) { AppComponent mAppComponent = ((App)helper.getView(R.id.iv_bg).getContext().getApplicationContext()) .getAppComponent(); ImageView imgMian = helper.getView(R.id.iv_bg); Context context = imgMian.getContext(); helper.setText(R.id.tv_title,item.getVideo().getTitle()); if (item.getVideo().getAuthor()!=null){ helper.setText(R.id.tv_author,item.getVideo().getAuthor().getName()); } helper.setText(R.id.tv_size, StringUtils.getPrintSize(item.getContentLength() == null ?0:item.getContentLength(),true)); helper.addOnClickListener(R.id.iv_more); helper.addOnClickListener(R.id.ll_detail); helper.addOnClickListener(R.id.ll_progress); helper.addOnClickListener(R.id.ctl_layout); if (!type.contains("正在")){ helper.getView(R.id.ll_detail).setVisibility(View.VISIBLE); }else { helper.getView(R.id.ll_detail).setVisibility(View.GONE); } if (item.getFinish()){ helper.getView(R.id.ll_progress).setVisibility(View.GONE); helper.getView(R.id.tv_size).setVisibility(View.VISIBLE); }else { helper.getView(R.id.tv_size).setVisibility(View.GONE); // if (downPosition == helper.getLayoutPosition()){ // helper.getView(R.id.ll_progress).setVisibility(View.VISIBLE); // helper.getView(R.id.sb_progress).setVisibility(View.VISIBLE); // ((SeekBar)helper.getView(R.id.sb_progress)).setProgress(item.getPercent()); // String size = StringUtils.getPrintSize(item.getCurrentBytes() == null ?0:item.getContentLength(),false) + "/" + StringUtils.getPrintSize(item.getContentLength() == null ?0:item.getContentLength(),true); // helper.setText(R.id.tv_pause,size); // }else { if (item.isPending()){ helper.setText(R.id.tv_pause,"正在连接中..."); ((ProgressBar)helper.getView(R.id.sb_progress)).setIndeterminate(true); helper.getView(R.id.ll_progress).setVisibility(View.VISIBLE); helper.getView(R.id.sb_progress).setVisibility(View.VISIBLE); }else { if (item.isLineUp()){ helper.setText(R.id.tv_pause,"排队中"); }else { helper.setText(R.id.tv_pause,"已暂停"); } helper.getView(R.id.ll_progress).setVisibility(View.VISIBLE); helper.getView(R.id.sb_progress).setVisibility(View.GONE); } // } } mAppComponent.imageLoader().loadImage(context, ImageConfigImpl .builder() .url(item.getVideo().getCover().getFeed()) .imageView(imgMian) .build()); }
Example 17
Source File: SubAssignmentsAdapter.java From OmniList with GNU Affero General Public License v3.0 | 4 votes |
private void convertFooter(BaseViewHolder helper) { helper.addOnClickListener(R.id.ll_add_comment); helper.addOnClickListener(R.id.ll_add_sub_assignment); helper.setText(R.id.tv_write_comments, TextUtils.isEmpty(comment) ? PalmApp.getStringCompact(R.string.click_to_add_comments) : comment); }
Example 18
Source File: GankIoDayAdapter.java From YiZhi with Apache License 2.0 | 4 votes |
@Override protected void convert(BaseViewHolder helper, GankIoDayItemBean item) { helper.setText(R.id.tv_type_item_title, item.getType()); helper.setText(R.id.tv_item_title, item.getDesc()); switch (item.getType()) { case "福利": helper.setImageResource(R.id.iv_type_item_title, R.drawable .ic_vector_title_welfare); Glide.with(mContext).load(item.getUrl()).crossFade().into((ImageView) helper .getView(R.id.iv_item_title)); break; case "Android": helper.setImageResource(R.id.iv_type_item_title, R.drawable .ic_vector_title_android); helper.setImageResource(R.id.iv_item_title, mResAndroid[mAndroidIndex % 6]); break; case "iOS": helper.setImageResource(R.id.iv_type_item_title, R.drawable.ic_vector_title_ios); helper.setImageResource(R.id.iv_item_title, mResIOS[mIOSIndex % 3]); break; case "前端": helper.setImageResource(R.id.iv_type_item_title, R.drawable.ic_vector_title_front); helper.setImageResource(R.id.iv_item_title, R.mipmap.gank_io_day_item_web); break; case "休息视频": helper.setImageResource(R.id.iv_type_item_title, R.drawable.ic_vector_title_video); helper.setImageResource(R.id.iv_item_title, R.mipmap.gank_io_day_item_video); break; case "瞎推荐": helper.setImageResource(R.id.iv_type_item_title, R.drawable.ic_vector_item_tuijian); break; case "拓展资源": helper.setImageResource(R.id.iv_type_item_title, R.drawable.ic_vector_item_tuozhan); break; case "App": helper.setImageResource(R.id.iv_type_item_title, R.drawable.ic_vector_item_app); break; } switch (helper.getItemViewType()) { case GankIoDayItemBean.GANK_IO_DAY_ITEM_DAY_NORMAL: helper.addOnClickListener(R.id.ll_more); break; case GankIoDayItemBean.GANK_IO_DAY_ITEM_DAY_REFESH: helper.addOnClickListener(R.id.ll_more).addOnClickListener(R.id.ll_refesh); break; default: break; } //GankIo 返回数据中,很多没有images,这里不用GankIo的图,直接写死 // if(item.getImages() == null) // return; // // Glide.with(mContext).load(item.getImages().get(0)).crossFade().into((ImageView) // helper.getView(R.id.iv_item_title)); }
Example 19
Source File: SearchHistoryAdapterWithThirdLib.java From JReadHub with GNU General Public License v3.0 | 4 votes |
@Override protected void convert(BaseViewHolder holder, SearchHistoryBean item) { holder.setText(R.id.tv_keyword, item.getKeyWord()); holder.addOnClickListener(R.id.img_close); }
Example 20
Source File: ImgItemProvider.java From AndroidQuick with MIT License | 4 votes |
@Override public void convert(BaseViewHolder helper, CBean data, int position) { helper.addOnClickListener(R.id.iv_img); helper.setImageResource(R.id.iv_img, R.mipmap.ic_launcher); }