CymChad / CymChad/BaseRecyclerViewAdapterHelper
mAdapter.notifyItemChanged(position,ITEM_0_PAYLOAD) 程序未响应
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 24.6k
- Forks
- 5.2k
- PR merge metrics
- No merged PRs in 30d
Description
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.快速点击时,程序提示未响应,导致卡死
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the BankCardAdapter child-click listener and its notifyItemChanged call, then trace the two convert overloads that handle the payload. Reproduce the rapid tapping case and determine whether the partial update causes the reported ANR; done means rapid clicks no longer freeze the app while the bank-card icon and masked number remain correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100