We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
瀑布流布局+分割线+header,然后再添加一些数据,会导致分割线计算的时候 layoutParams 拿到是 null,导致 NPE
以下代码通过 demo 增加 header 和 addModels 可稳定复现
class StaggeredDividerFragment : BaseDividerFragment<FragmentStaggeredDividerBinding>(R.layout.fragment_staggered_divider) { override fun initView() { binding.rv.staggered(3, RecyclerView.VERTICAL).divider { setDrawable(R.drawable.divider_horizontal) // includeVisible = true }.setup { addType<HeaderFooterFragment.Header>(R.layout.item_header) addType<DividerModel>(R.layout.item_divider_vertical) onBind { when (itemViewType) { R.layout.item_divider_vertical -> { // 设置动态高度 val layoutParams = itemView.layoutParams layoutParams.height = getModel<DividerModel>().height itemView.layoutParams = layoutParams } R.layout.item_header -> { val layoutParams = itemView.layoutParams as? StaggeredGridLayoutManager.LayoutParams layoutParams?.isFullSpan = true itemView.layoutParams = layoutParams } } } }.models = getData() CoroutineScope(Dispatchers.Main).launch { val data = mutableListOf<Any>() delay(500) data.add(DividerModel(300)) delay(500) data.add(DividerModel(2000)) binding.rv.addModels(data, index = 3) } } private fun getData(): List<Any> { val data = mutableListOf<Any>() // 生成动态宽高 for (i in 0..9) { when (i) { 2 -> data.add(DividerModel(400)) 3 -> data.add(DividerModel(500)) 4 -> data.add(DividerModel(700)) 5 -> data.add(DividerModel(1000)) 8 -> data.add(DividerModel(200)) else -> data.add(DividerModel()) } } data.add(HeaderFooterFragment.Header()) return data } override fun initData() { } }
由于本项目参与者的技术及精力有限无法满足大部分开发者的需求, 欢迎开发者参与贡献
The text was updated successfully, but these errors were encountered:
fdd9fd6
已修复在1.5.6
1.5.6
Sorry, something went wrong.
No branches or pull requests
描述
瀑布流布局+分割线+header,然后再添加一些数据,会导致分割线计算的时候 layoutParams 拿到是 null,导致 NPE
理由
参考实现
以下代码通过 demo 增加 header 和 addModels 可稳定复现
是否可以参与实现
The text was updated successfully, but these errors were encountered: