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

The following examples show how to use com.chad.library.adapter.base.BaseViewHolder#getView() . 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: SearchAddressAdapter.java    From FastWaiMai with MIT License 6 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, PoiInfo item) {

    final ImageView ivPointImage = helper.getView(R.id.iv_point);
    final TextView tvName = helper.getView(R.id.tv_name);
    final TextView tvAddress = helper.getView(R.id.tv_address);
    final TextView tvDistance = helper.getView(R.id.tv_distance);
    LatLng latLng = item.getLocation();

    double distance = DistanceUtil.getDistance(currentLatLng, latLng);
    if(helper.getPosition() == 0){
        ivPointImage.setImageResource(R.drawable.point_orange);
        tvName.setTextColor(Latte.getApplication().getResources().getColor(R.color.orange));
    }else{
        ivPointImage.setImageResource(R.drawable.point_gray);
        tvName.setTextColor(Latte.getApplication().getResources().getColor(R.color.black));
    }
    tvName.setText(item.getName());
    tvAddress.setText(item.getAddress());
    tvDistance.setText(formatDistance(distance));
}
 
Example 2
Source File: RvNoteListAdapter.java    From SuperNote with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 设置网格布局
 *
 * @describe
 */
private void setGridLayout(BaseViewHolder helper, Note item) {

    helper.addOnClickListener(R.id.cv_note_list_grid);
    helper.addOnLongClickListener(R.id.cv_note_list_grid);

    helper.setVisible(R.id.ll_note_list_linear, false);
    helper.setVisible(R.id.cv_note_list_grid, true);

    TextView tvContent=helper.getView(R.id.tv_note_list_grid_content);
    if(isPrivacyAndRecycle(item))
        helper.setText(R.id.tv_note_list_grid_content,Utils.getContext().getResources().getString(R.string.note_privacy_and_recycle));
    else
        parseTextContent(tvContent,item.getNoteContent());

    // 设置便签的时间显示
    setNoteTime(helper, item.getModifiedTime());
    // 设置多选按钮
    setCheckBox(helper);
}
 
Example 3
Source File: ReplyAdapter.java    From Aurora with Apache License 2.0 6 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, ReplySection item) {
    ImageView img = helper.getView(R.id.iv_pic);
    AppComponent mAppComponent = ((App)img.getContext().getApplicationContext())
            .getAppComponent();
    if (item.t.getData().getUser()!=null){
        mAppComponent.imageLoader().loadImage(img.getContext(),
                ImageConfigImpl
                        .builder()
                        .transformation(new GlideCircleTransform())
                        .url(item.t.getData().getUser().getAvatar())
                        .imageView(img)
                        .build());
    }
    DateFormat df = new SimpleDateFormat("yyyy/MM/dd");
    if (item.t.getData().getUser()!=null){
        helper.setText(R.id.tv_nickname,item.t.getData().getUser().getNickname());
    }
    helper.setText(R.id.tv_comment,item.t.getData().getMessage())
            .setText(R.id.tv_good_num,item.t.getData().getLikeCount()+"")
            .setText(R.id.tv_reply_time,df.format(item.t.getData().getCreateTime()));
}
 
Example 4
Source File: UserListAdapter.java    From HaiNaBaiChuan with Apache License 2.0 5 votes vote down vote up
@Override
protected void convert(BaseViewHolder baseViewHolder, User user) {
    baseViewHolder.setText(R.id.tvUserName, "@" + user.getNickname())
            .setText(R.id.tvTopContent, user.getSign());
    ImageView headPic = baseViewHolder.getView(R.id.imgHead);
    ImgLoadUtil.loadHead(mContext, headPic, user.getHeadPic());
}
 
Example 5
Source File: EssMediaAdapter.java    From FilePicker with MIT License 5 votes vote down vote up
@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 6
Source File: SearchAdapter.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@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));
}
 
Example 7
Source File: DouBanAdapter.java    From v9porn with MIT License 5 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, DouBanMeizi item) {
    ImageView imageView = helper.getView(R.id.iv_meizhi);
    GlideApp.with(helper.itemView.getContext()).load(item.getUrl()).transition(new DrawableTransitionOptions().crossFade(300)).into(imageView);
    helper.setText(R.id.tv_title, item.getTitle());

    imageView.setTag(R.string.app_name, item.getUrl());
}
 
Example 8
Source File: MovieListFragment.java    From AFBaseLibrary with Apache License 2.0 5 votes vote down vote up
@Override
        protected void convert(BaseViewHolder helper, MovieEntity item) {
            helper.setText(R.id.tv_name, item.getMovieName());
            helper.setText(R.id.tv_type, "类型:" + item.getStyle());
            helper.setText(R.id.tv_score, "评分:" + item.getScoreNumber());
            helper.setText(R.id.tv_quote, item.getQuote());
            helper.setText(R.id.tv_rank, String.valueOf(helper.getLayoutPosition() + 1));

            ImageView imgArticle = helper.getView(R.id.img_article);
//            AFGlideUtil.loadImage(item.getArticleUrl(), imgArticle);
        }
 
Example 9
Source File: FastLoadMoreView.java    From FastLib with Apache License 2.0 5 votes vote down vote up
private void initView(BaseViewHolder holder) {
    if (holder == null) {
        return;
    }

    holder.setText(R.id.tv_loadingFastLoadMore, mLoadingText)
            .setTextColor(R.id.tv_loadingFastLoadMore, mLoadingTextColor)
            .setText(R.id.tv_loadFailFastLoadMore, mLoadFailText)
            .setTextColor(R.id.tv_loadFailFastLoadMore, mLoadFailTextColor)
            .setText(R.id.tv_loadEndFastLoadMore, mLoadEndText)
            .setTextColor(R.id.tv_loadEndFastLoadMore, mLoadEndTextColor);
    TextView tvLoading = holder.getView(R.id.tv_loadingFastLoadMore);
    TextView tvLoadFail = holder.getView(R.id.tv_loadFailFastLoadMore);
    TextView tvLoadEnd = holder.getView(R.id.tv_loadEndFastLoadMore);
    ProgressBar pbLoading = holder.getView(R.id.pb_loadingFastLoadMore);
    tvLoading.setTextSize(TypedValue.COMPLEX_UNIT_PX, mLoadingTextSize);
    tvLoading.getPaint().setFakeBoldText(mLoadingTextFakeBold);
    tvLoadFail.setTextSize(TypedValue.COMPLEX_UNIT_PX, mLoadFailTextSize);
    tvLoadFail.getPaint().setFakeBoldText(mLoadFailTextFakeBold);
    tvLoadEnd.setTextSize(TypedValue.COMPLEX_UNIT_PX, mLoadEndTextSize);
    tvLoadEnd.getPaint().setFakeBoldText(mLoadEndTextFakeBold);
    if (mLoadingSize >= 0) {
        pbLoading.getIndeterminateDrawable().setBounds(0, 0, mLoadingSize, mLoadingSize);
        ViewGroup.LayoutParams params = pbLoading.getLayoutParams();
        params.width = mLoadingSize;
        params.height = mLoadingSize;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        pbLoading.setIndeterminateTintList(ColorStateList.valueOf(mLoadingProgressColor));
    }
    if (mLoadingProgressDrawable != null) {
        mLoadingProgressDrawable.setBounds(pbLoading.getIndeterminateDrawable().getBounds());
        pbLoading.setIndeterminateDrawable(mLoadingProgressDrawable);
    }
}
 
Example 10
Source File: ModuleAdapter.java    From FakeWeather with Apache License 2.0 5 votes vote down vote up
@Override
protected void convert(final BaseViewHolder helper, final Module item) {
    TextView tvName = helper.getView(R.id.tv_module_name);
    tvName.setText(item.getName());
    tvName.setCompoundDrawablesWithIntrinsicBounds(ThemeUtil.setTintDrawable(mContext.getDrawable(item.getResIcon()), mContext), null, null, null);
    SwitchCompat switchCompat = helper.getView(R.id.switch_module_enable);
    switchCompat.setChecked(item.isEnable());
    switchCompat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            item.setEnable(isChecked);
        }
    });

}
 
Example 11
Source File: RelateVideoAdapter.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, RelateVideoSection item) {
    helper.setText(R.id.tv_title,item.t.getData().getTitle())
            .setText(R.id.tv_type,getDetailStr(item.t));
    ImageView img = helper.getView(R.id.iv_left);
    AppComponent mAppComponent = ((App)img.getContext().getApplicationContext())
            .getAppComponent();
    Context context = img.getContext();
    mAppComponent.imageLoader().loadImage(context,
            ImageConfigImpl
                    .builder()
                    .url(item.t.getData().getCover().getFeed())
                    .imageView(img)
                    .build());
}
 
Example 12
Source File: HistoryAdapter.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 13
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 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: NearbyAddressAdapter.java    From FastWaiMai with MIT License 4 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, PoiInfo item) {
	final TextView tvName = helper.getView(R.id.tv_nearby_address);
	tvName.setText(item.getName());
}
 
Example 16
Source File: LoadMoreRecyclerViewAdapter.java    From SmoothRefreshLayout with MIT License 4 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, String item) {
    helper.setText(R.id.textView_list_item, String.valueOf(helper.getAdapterPosition()));
    ImageView view = helper.getView(R.id.imageView_list_item);
    Glide.with(mContext).asBitmap().load(item).into(view);
}
 
Example 17
Source File: CacheAdapter.java    From Aurora with Apache License 2.0 4 votes vote down vote up
@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 18
Source File: RvEditFolderAdapter.java    From SuperNote with GNU General Public License v3.0 4 votes vote down vote up
private void setFirstItemOrNormal(BaseViewHolder helper){

        ImageView ivRename=helper.getView(R.id.iv_edit_folder_rename);
        CheckBox checkBox=helper.getView(R.id.cb_edit_folder);
        RelativeLayout rlRoot=helper.getView(R.id.rl_edit_folder);

        // 第一行(随手记)不可编辑
        if(helper.getLayoutPosition()==0){

            checkBox.setAlpha(0.26F);
            rlRoot.setClickable(false);

        } else {

            ivRename.setAlpha(0.54F);
            ivRename.setClickable(true);

            checkBox.setAlpha(0.87F);
            rlRoot.setClickable(true);

        }
    }
 
Example 19
Source File: AccountListAdapter.java    From AccountBook with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, Account item) {
    SpannableString moneySpan = new SpannableString(item.getMoneyStr());
    moneySpan.setSpan(mSizeMinSpan, 0, 1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);

    // 设置类型
    helper.setImageResource(R.id.img_type, AppConfig.TYPE_COST == item.getType() ?
            R.mipmap.ic_type_cost : R.mipmap.ic_type_income)
            // 设置金额
            .setText(R.id.txt_money, moneySpan)
            // 设置分类
            .setVisible(R.id.txt_type, !TextUtils.isEmpty(item.getCType()))
            .setText(R.id.txt_type, item.getCType())
            // 设置日期
            .setText(R.id.txt_date, DateUtils.getDateText(item.getDate(), DateUtils.FORMAT));

    // 设置备注
    TextView txtNote = helper.getView(R.id.txt_note);
    String note = item.getNote();
    if(TextUtils.isEmpty(note)){
        txtNote.setVisibility(View.INVISIBLE);
    }else{
        txtNote.setVisibility(View.VISIBLE);
        txtNote.setText(note);
    }

    // 设置记账用户信息
    ImageView imgAvatar = helper.getView(R.id.img_avatar);
    User owner = item.getOwner();
    if(owner != null && isShowAvatar){
        // 设置头像
        imgAvatar.setVisibility(View.VISIBLE);
        AVFile avatar = owner.getAvatar();
        if(avatar != null){
            ImageLoader.getIns(mContext).loadIcon(avatar.getUrl(), imgAvatar);
        }else{
            imgAvatar.setImageResource(R.mipmap.ic_def_icon);
        }
    }else{
        imgAvatar.setVisibility(View.GONE);
    }

    if(item.getItemType() == Account.TYPE_DATE){
        // 设置当天日期
        helper.setText(R.id.txt_day_date,
                DateUtils.getWeekDate(item.getDate(), DateUtils.FORMAT_MONTH_DAY));
        // 设置当天总收入、支出
        helper.setText(R.id.txt_day_money, getDayMoney(data, item.getDate()));
    }
}
 
Example 20
Source File: VerticalTabActivity.java    From FlowHelper with Apache License 2.0 4 votes vote down vote up
@Override
protected void convert(@NonNull BaseViewHolder helper, NaviBean item) {
    helper.setText(R.id.item_navi_title,item.getName());
    LabelFlowLayout flowLayout = helper.getView(R.id.labelflow);
    flowLayout.setAdapter(new LabelAdapter(R.layout.item_textview,item.getArticles()));
}