Skip to content

Commit

Permalink
docs: 更新文档
Browse files Browse the repository at this point in the history
  • Loading branch information
liangjingkanji committed Nov 27, 2023
1 parent 23dc40c commit ea27949
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions docs/performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

## 滑动列表耗时

!!! question "滑动卡顿"
!!! question "最常见的卡顿原因"
卡顿优化重点是避免滑动列表时耗时, 应减少在onBind中耗时行为

`SharedPreferences`(简称sp)在读取数据相对耗时, 建议替换为[Serialze](https://github.com/liangjingkanji/Serialize)
Expand Down Expand Up @@ -62,9 +62,10 @@ data class SimpleModel(var name: String = "BRV") : ItemBind, ItemAttached {
}

override fun onBind(holder: BindingAdapter.BindingViewHolder) {
// 500ms 以后依然可见才会触发加载
holder.itemView.postDelayed({
if (itemVisible) {
// 500ms 以后依然可见才会触发加载
// 此处可以加载图片或其他耗时操作
}
}, 500)
}
Expand All @@ -76,7 +77,7 @@ data class SimpleModel(var name: String = "BRV") : ItemBind, ItemAttached {

## 固定布局优化

如果条目宽高不会因Adapter动态改变, 那么可以使用`setHasFixedSize(true)`来减少测绘次数提高性能
如果条目宽高不会因Adapter动态改变, 可以使用`setHasFixedSize(true)`来减少测绘次数提高性能


## 列表唯一标识
Expand Down

0 comments on commit ea27949

Please sign in to comment.