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

The following examples show how to use com.chad.library.adapter.base.BaseViewHolder#getLayoutPosition() . 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: VideoCommentAdapter.java    From v9porn with MIT License 6 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, VideoComment item) {
    helper.setText(R.id.tv_item_video_comment_title_info, item.getTitleInfo());
    stringBuilder.delete(0, stringBuilder.length());
    int size = item.getCommentQuoteList().size();
    for (int i = 0; i < size; i++) {
        stringBuilder.append(item.getCommentQuoteList().get(i));
        if (i < size - 1) {
            stringBuilder.append("\n");
        }
    }
    helper.setText(R.id.tv_item_video_comment_content, stringBuilder.toString());
    helper.setText(R.id.tv_item_video_comment_replytime, item.getuName() + " ----" + item.getReplyTime());
    if (helper.getLayoutPosition() == clickPosition) {
        helper.itemView.setBackgroundColor(ContextCompat.getColor(context, R.color.colorPrimary));
    } else {
        helper.itemView.setBackgroundColor(ContextCompat.getColor(context, R.color.common_background));
    }
}
 
Example 2
Source File: VideoCommentAdapter.java    From v9porn with MIT License 6 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, VideoComment item) {
    helper.setText(R.id.tv_item_video_comment_title_info, item.getTitleInfo());
    stringBuilder.delete(0, stringBuilder.length());
    int size = item.getCommentQuoteList().size();
    for (int i = 0; i < size; i++) {
        stringBuilder.append(item.getCommentQuoteList().get(i));
        if (i < size - 1) {
            stringBuilder.append("\n");
        }
    }
    helper.setText(R.id.tv_item_video_comment_content, stringBuilder.toString());
    helper.setText(R.id.tv_item_video_comment_replytime, item.getuName() + " ----" + item.getReplyTime());
    if (helper.getLayoutPosition() == clickPosition) {
        helper.itemView.setBackgroundColor(ContextCompat.getColor(context, R.color.colorPrimary));
    } else {
        helper.itemView.setBackgroundColor(ContextCompat.getColor(context, R.color.common_background));
    }
}
 
Example 3
Source File: RvNoteFolderAdapter.java    From SuperNote with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, NoteFolder item) {
    helper.setText(R.id.tv_folder_list_title, item.getFolderName())
            .setText(R.id.tv_folder_list_count, item.getNoteCount() + "");


    RelativeLayout rlItem=helper.getView(R.id.rl_folder_root);
    TextView tvTitle=helper.getView(R.id.tv_folder_list_title);
    TextView tvCount=helper.getView(R.id.tv_folder_list_count);
    ImageView ivIcon=helper.getView(R.id.iv_folder_list_ic);

    if(Constans.currentFolder == helper.getLayoutPosition()-getHeaderLayoutCount()){
        rlItem.setSelected(true);
        tvTitle.setTextColor(ThemeUtils.getColorPrimary(mContext));
        tvCount.setTextColor(ThemeUtils.getColorPrimary(mContext));
        ivIcon.setBackground(MyDrawable.getIcFolderSelectedDrawable( ThemeUtils.getColorPrimary(mContext)));
    } else {
        rlItem.setSelected(false);
        tvTitle.setTextColor(MainApplication.getContext().getResources().getColor(R.color.colorBlackAlpha87));
        tvCount.setTextColor(MainApplication.getContext().getResources().getColor(R.color.colorBlackAlpha54));
        ivIcon.setBackgroundResource(R.drawable.ic_folder_un_selected);
    }
}
 
Example 4
Source File: RvEditFolderAdapter.java    From SuperNote with GNU General Public License v3.0 6 votes vote down vote up
private void setSelectedItem(BaseViewHolder helper, NoteFolder item){
    if(EditFolderConstans.selectedItem==helper.getLayoutPosition()){
        helper.setVisible(R.id.tv_edit_folder_name,false)
                .setVisible(R.id.textinput_edit_folder_name,true)
                .setText(R.id.et_edit_folder_name,item.getFolderName())
                .setImageResource(R.id.iv_edit_folder_rename,R.drawable.ic_done_black_24dp);
        if(EditFolderConstans.isNewFolder){
            editItem(helper);
        }
    } else {
        helper.setVisible(R.id.tv_edit_folder_name,true)
                .setVisible(R.id.textinput_edit_folder_name,false)
                .setText(R.id.tv_edit_folder_name,item.getFolderName())
                .setImageResource(R.id.iv_edit_folder_rename,R.drawable.ic_create_black_24dp);
    }
}
 
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: 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 7
Source File: ReplyAdapter.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Override
protected void convertHead(BaseViewHolder helper, ReplySection item) {
    helper.setText(R.id.tv_name,item.t.getData().getText());
    helper.getView(R.id.iv_arrow).setVisibility(View.GONE);
    helper.addOnClickListener(R.id.iv_arrow_right);
    if (helper.getLayoutPosition() == 0){
        helper.getView(R.id.iv_arrow_right).setVisibility(View.VISIBLE);
        helper.getView(R.id.view).setVisibility(View.VISIBLE);
    }else {
        helper.getView(R.id.view).setVisibility(View.GONE);
        helper.getView(R.id.iv_arrow_right).setVisibility(View.GONE);
    }
}
 
Example 8
Source File: RelateVideoAdapter.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Override
protected void convertHead(BaseViewHolder helper, RelateVideoSection item) {
    helper.setText(R.id.tv_name,item.t.getData().getText());
    if (helper.getLayoutPosition() == 0){
        helper.getView(R.id.iv_arrow_right).setVisibility(View.VISIBLE);
        helper.getView(R.id.view).setVisibility(View.VISIBLE);
    }else {
        helper.getView(R.id.view).setVisibility(View.GONE);
    }
    helper.getView(R.id.iv_arrow_right).setVisibility(View.GONE);
}
 
Example 9
Source File: RvNoteListAdapter.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 设置线性布局时,列表的分组
 *
 * @param helper
 * @param time   时间戳
 * @describe
 */
private void setLinearLayoutGroup(BaseViewHolder helper, long time) {

    // 当前position
    int position = helper.getLayoutPosition();


    // 如果是列表第一项,或者与上一个便签的创建时间不是在同一月,显示分组信息
    if (position == 0 ||
            !DateUtils.isInSameMonth(time, getData().get(position - 1).getCreatedTime())) {
        showLineraLayoutGroup(true, helper, time);
        return;
    }
    showLineraLayoutGroup(false, helper, time);
}
 
Example 10
Source File: RvEditFolderAdapter.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void convert(BaseViewHolder helper, NoteFolder item) {

    int position=helper.getLayoutPosition();

    helper.setText(R.id.tv_edit_folder_count,"包含: "+item.getNoteCount()+"个便签")
            .setChecked(R.id.cb_edit_folder,mCheckList.get(position))
            .addOnClickListener(R.id.iv_edit_folder_rename);
    setSelectedItem(helper,item);
    setFirstItemOrNormal(helper);
}
 
Example 11
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);

        }
    }