Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

动态添加一条数据,更新后item没有间距 #457

Open
13253863229 opened this issue Sep 12, 2024 · 4 comments
Open

动态添加一条数据,更新后item没有间距 #457

13253863229 opened this issue Sep 12, 2024 · 4 comments

Comments

@13253863229
Copy link

问题描述

第一次加载的数据,有间距。向列表中动态添加一条数据后,列表数据更新后,没有间距

期望结果

更新后,有间距

如何复现

rcv.mutable.add(bean)
rcv.bindingAdapter.notifyItemInserted(list.size - 1)

希望快速解决请Fork仓库复现问题并附上链接, 否则只能等有空才能排查
凭空猜测只会让问题晦涩难懂, 浪费本项目可持续维护时间

截图

image
image
image

异常堆栈信息或者手机截图/视频(拖拽到输入框即可上传)

版本

  • BRV:1.6.0
  • Android:
  • Gradle:
  • Android Studio:
@13253863229
Copy link
Author

notifyItemInserted局部刷新不行,notifyDataSetChanged()没问题

@Gao-hao-nan
Copy link

notifyItemInserted() 仅通知插入新项而不是重新计算所有 Item 的布局你是通过 ItemDecoration 来设置间距的它可能没有触发重新计算所有项的布局导致新插入的项没有应用到 ItemDecoration 的间距规则,你可以使用notifyDataSetChanged来解决问题这个并不是框架的问题

@13253863229
Copy link
Author

13253863229 commented Sep 13, 2024 via email

@liangjingkanji
Copy link
Owner

liangjingkanji commented Sep 13, 2024

这属于RecyclerView知识, BRV并未自定义RecycleView, 和本框架关系不大

考虑到可能其他人也会遇到还是同步到BRV文档下 通知更新

@Gao-hao-nan 他说的分析内容很正确, 或者你也可以尝试使用 invalidateItemDecorations()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants