mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
use getOrPut where possible
This commit is contained in:
parent
6217afb469
commit
467f60ed9b
2 changed files with 2 additions and 12 deletions
|
@ -19,13 +19,7 @@ object EstimatedItemHeight {
|
|||
return if (childSizesMap[pos] != null) {
|
||||
childSizesMap[pos] ?: 0
|
||||
} else {
|
||||
val type = if (childTypeMap[pos] == null) {
|
||||
val t = itemViewType ?: 0
|
||||
childTypeMap[pos] = t
|
||||
t
|
||||
} else {
|
||||
childTypeMap[pos] ?: 0
|
||||
}
|
||||
val type = childTypeMap.getOrPut(pos) { itemViewType ?: 0 }
|
||||
when {
|
||||
childTypeEstimateMap[type] != null -> childTypeEstimateMap[type] ?: 0
|
||||
childAvgHeightMap[type] == null && !childTypeHeightMap[type]?.values.isNullOrEmpty() -> {
|
||||
|
|
|
@ -37,11 +37,7 @@ class LinearLayoutManagerAccurateOffset(context: Context?) : LinearLayoutManager
|
|||
childSizesMap[position] = child.height
|
||||
val type = getItemViewType(child)
|
||||
childTypeMap[position] = type
|
||||
if (childTypeHeightMap[type] != null) {
|
||||
childTypeHeightMap[type]!![position] = child.height
|
||||
} else {
|
||||
childTypeHeightMap[type] = hashMapOf(position to child.height)
|
||||
}
|
||||
childTypeHeightMap.getOrPut(type) { hashMapOf() }[position] = child.height
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue