Skip to content

Commit

Permalink
perf: adjust the RecyclerView cache size
Browse files Browse the repository at this point in the history
  • Loading branch information
nopdan authored and WhiredPlanck committed Feb 21, 2024
1 parent 6014451 commit aeb81e8
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ class LiquidKeyboard : KoinComponent, ClipboardHelper.OnClipboardUpdateListener
adapterType = AdapterType.SIMPLE
keyboardView.apply {
layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
adapter =
simpleAdapter
adapter = simpleAdapter
setItemViewCacheSize(10)
setHasFixedSize(true)
// 添加分割线
// 设置添加删除动画
Expand Down Expand Up @@ -263,6 +263,7 @@ class LiquidKeyboard : KoinComponent, ClipboardHelper.OnClipboardUpdateListener
keyboardView.apply {
layoutManager = getOneColumnStaggeredGrid()
adapter = dbAdapter
setItemViewCacheSize(10)
setHasFixedSize(false)
// 调用ListView的setSelected(!ListView.isSelected())方法,这样就能及时刷新布局
isSelected = true
Expand Down Expand Up @@ -298,6 +299,7 @@ class LiquidKeyboard : KoinComponent, ClipboardHelper.OnClipboardUpdateListener
keyboardView.apply {
layoutManager = getFlexbox()
adapter = candidateAdapter
setItemViewCacheSize(50)
setHasFixedSize(false)
isSelected = true
}
Expand Down Expand Up @@ -353,6 +355,7 @@ class LiquidKeyboard : KoinComponent, ClipboardHelper.OnClipboardUpdateListener
keyboardView.apply {
layoutManager = getFlexbox()
adapter = varLengthAdapter
setItemViewCacheSize(50)
setHasFixedSize(false)
keyboardView.isSelected = true
}
Expand Down

0 comments on commit aeb81e8

Please sign in to comment.