BaseRecyclerViewAdapterHelper mAdapter.notifyItemChanged(position,ITEM_0_PAYLOAD) 程序未响应

e1xvtsh3  于 4个月前  发布在  其他
关注(0)|答案(1)|浏览(103)

1.mAdapter.setOnItemChildClickListener((adapter, view, position) -> {
if (view.getId() == R.id.tv_copy) {
BaseAppUtil.copyToSystem(BankCardActivity.this, mAdapter.getItem(position).bankNo);
} else if (view.getId() == R.id.tv_detail) {
mViewModel.toBankDetail(mAdapter.getItem(position).accountId);
} else if (view.getId() == R.id.cash_checked) {
HomeBankBean.ListBean item = mAdapter.getItem(position);
item.hide = !item.hide;
mAdapter.getData().set(position, item);
mAdapter.notifyItemChanged(position, BankCardAdapter.ITEM_0_PAYLOAD);
}
});
2. public BankCardAdapter() {
super(R.layout.adapter_member_bankcard);
addChildClickViewIds(R.id.tv_copy, R.id.tv_detail, R.id.cash_checked);
}

@Override
protected void convert(@NotNull BaseViewHolder holder, HomeBankBean.ListBean item) {
    holder
            .setText(R.id.tv_member_bankname, item.bankName)
            .setText(R.id.tv_member_mantissa, item.hide ? item.bankNo : BaseAppUtil.bankFormat(item.bankNo))
            .setText(R.id.tv_member_bankfrom, item.bankType)
            .setGone(R.id.tv_detail, item.hasDetail == 0)
            .setImageResource(R.id.cash_checked, item.hide ? R.drawable.eyes_main_open : R.drawable.eyes_main_close);
    GlideUtil.loadImage(getContext(), item.bankIcon, holder.getView(R.id.iv_member_form));
    CardView cardView = holder.getView(R.id.cv_bankcard);
    try {
        cardView.setCardBackgroundColor(Color.parseColor(BaseAppUtil.getBankColor(item.bankColor)));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

public static final int ITEM_0_PAYLOAD = 1;

@Override
protected void convert(@NotNull BaseViewHolder holder, HomeBankBean.ListBean item, @NotNull List<?> payloads) {
    for (Object p : payloads) {
        int payload = (int) p;
        if (payload == ITEM_0_PAYLOAD) {
            holder.setImageResource(R.id.cash_checked, item.hide ? R.drawable.eyes_main_open : R.drawable.eyes_main_close)
                    .setText(R.id.tv_member_mantissa, item.hide ? item.bankNo : BaseAppUtil.bankFormat(item.bankNo));
        }
    }
}

3.快速点击时,程序提示未响应,导致卡死

相关问题