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) {
|
return if (childSizesMap[pos] != null) {
|
||||||
childSizesMap[pos] ?: 0
|
childSizesMap[pos] ?: 0
|
||||||
} else {
|
} else {
|
||||||
val type = if (childTypeMap[pos] == null) {
|
val type = childTypeMap.getOrPut(pos) { itemViewType ?: 0 }
|
||||||
val t = itemViewType ?: 0
|
|
||||||
childTypeMap[pos] = t
|
|
||||||
t
|
|
||||||
} else {
|
|
||||||
childTypeMap[pos] ?: 0
|
|
||||||
}
|
|
||||||
when {
|
when {
|
||||||
childTypeEstimateMap[type] != null -> childTypeEstimateMap[type] ?: 0
|
childTypeEstimateMap[type] != null -> childTypeEstimateMap[type] ?: 0
|
||||||
childAvgHeightMap[type] == null && !childTypeHeightMap[type]?.values.isNullOrEmpty() -> {
|
childAvgHeightMap[type] == null && !childTypeHeightMap[type]?.values.isNullOrEmpty() -> {
|
||||||
|
|
|
@ -37,11 +37,7 @@ class LinearLayoutManagerAccurateOffset(context: Context?) : LinearLayoutManager
|
||||||
childSizesMap[position] = child.height
|
childSizesMap[position] = child.height
|
||||||
val type = getItemViewType(child)
|
val type = getItemViewType(child)
|
||||||
childTypeMap[position] = type
|
childTypeMap[position] = type
|
||||||
if (childTypeHeightMap[type] != null) {
|
childTypeHeightMap.getOrPut(type) { hashMapOf() }[position] = child.height
|
||||||
childTypeHeightMap[type]!![position] = child.height
|
|
||||||
} else {
|
|
||||||
childTypeHeightMap[type] = hashMapOf(position to child.height)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue