Skip to content

1.2.1

Compare
Choose a tag to compare
@youlookwhat youlookwhat released this 22 Nov 04:35
· 31 commits to master since this release

[完善] 使用refreshNotifyItemChanged(position, payload);不继承bindViewPayloads时,默认使用bindView处理。

//  设置要局部刷新的position及payload
adapter.refreshNotifyItemChanged(position, PayloadAdapter.PAYLOAD_COLLECT);

// adapter里额外再继承 bindViewPayloads 方法
@Override
protected void bindViewPayloads(@NonNull BaseBindingHolder holder, @NonNull DataItemBean bean, @NonNull ItemPayloadBinding binding, int position, @NonNull List<Object> payloads) {
     // 删除掉这一行,自己处理,不走bindView()
     // super.bindViewPayloads(holder, bean, binding, position, payloads);
    for (Object p : payloads) {
        int code = (int) p;
        switch (code) {
            case PAYLOAD_ZAN:
                binding.tvZan.setText(bean.getIsZan() == 1 ? "已赞" : "点赞");
                break;
            case PAYLOAD_COLLECT:
                binding.tvCollect.setText(bean.getIsCollect() == 1 ? "已收藏" : "收藏");
                break;
            default:
                break;
        }
    }
}