[状态栏]由单排改成双排

[状态栏]由单排改成双排

[状态栏]xxxx

[状态栏]xxxx
This commit is contained in:
renwj
2022-08-04 10:16:26 +08:00
parent d16fc6a98a
commit 1e27c6da97
10 changed files with 141 additions and 123 deletions

View File

@@ -31,12 +31,15 @@ class CommonDividerItemDecoration internal constructor(builder: Builder) : ItemD
private var mSpanCountTBCare = false
private val mHorizontalExternalSpace: Int
private val mVerticalExternalSpace: Int
private var mLastRight = 0
private var mLastBottom = 0
private var mFromPosition = 0
private var mHorizontalDelta: Pair<Int, Int>? = null
private var mVerticalDelta: Pair<Int, Int>? = null
private var mRightCache: HashMap<Int, Int> = HashMap()
private var mLeftCache: HashMap<Int, Int> = HashMap()
private var mBottomCache: HashMap<Int, Int> = HashMap()
private var mTopCache: HashMap<Int, Int> = HashMap()
/**
* 外部间隔结束位置是否需要
*/
@@ -84,23 +87,28 @@ class CommonDividerItemDecoration internal constructor(builder: Builder) : ItemD
}
} else {
val averageDistance = (((spanCount - 1) * mHorizontalInnerSpace + 2 * mHorizontalExternalSpace + deltaHL + deltaHR) * 1.0f / spanCount).toInt()
Log.d("UUUU", "step::0::$averageDistance: lastRight: $mLastRight : state: $state " )
if (spanIndex == 0) {
outRect.left = mHorizontalExternalSpace + deltaHL
outRect.right = averageDistance - outRect.left
mLastRight = outRect.right
Log.d("UUUU", "step::1::$averageDistance: lastRight: $mLastRight" )
if (state.didStructureChange()) {
mRightCache[position] = outRect.right
}
Log.d("UUUU", "step::1::$averageDistance: outRect.right: ${outRect.right} ::outRect.left: ${outRect.left}:: position: $position :: state: $state" )
} else if (spanIndex == spanCount - 1) {
outRect.right = mHorizontalExternalSpace + deltaHR
outRect.left = averageDistance - outRect.right
Log.d("UUUU", "step::2::$averageDistance: lastRight: $mLastRight ::outRect.left: ${outRect.left}" )
Log.d("UUUU", "step::2::$averageDistance: outRect.right: ${outRect.right} ::outRect.left: ${outRect.left} :: position: $position :: state: $state" )
} else {
outRect.left = mHorizontalInnerSpace - mLastRight
outRect.right = averageDistance - outRect.left
if (state.didStructureChange()) {
mLastRight = outRect.right
outRect.left = mHorizontalInnerSpace - (mRightCache[position - 1] ?: 0)
outRect.right = averageDistance - outRect.left
mLeftCache[position] = outRect.left
mRightCache[position] = outRect.right
} else {
outRect.left = mLeftCache[position]!!
outRect.right = mRightCache[position]!!
}
Log.d("UUUU", "step::2::$averageDistance: lastRight: $mLastRight ::outRect.left: ${outRect.left}" )
Log.d("UUUU", "step::2::$averageDistance: outRect.right: ${outRect.right} ::outRect.left: ${outRect.left} :: position: $position :: state: $state" )
}
} //所在的行数
if (lookUp.getSpanGroupIndex(childPosition, spanCount) == lookUp.getSpanGroupIndex(mFromPosition, spanCount)) {
@@ -130,15 +138,21 @@ class CommonDividerItemDecoration internal constructor(builder: Builder) : ItemD
if (spanIndex == 0) {
outRect.top = mVerticalExternalSpace + deltaVT
outRect.bottom = averageDistance - outRect.top
mLastBottom = outRect.bottom
if (state.didStructureChange()) {
mBottomCache[position] = outRect.bottom
}
} else if (spanIndex == spanCount - 1) {
outRect.top = mVerticalExternalSpace + deltaVB
outRect.bottom = averageDistance - outRect.top
} else {
outRect.top = mVerticalInnerSpace - mLastBottom
outRect.bottom = averageDistance - outRect.top
if (state.didStructureChange()) {
mLastBottom = outRect.bottom
outRect.top = mVerticalInnerSpace - (mBottomCache[position - 1] ?: 0 )
outRect.bottom = averageDistance - outRect.top
mBottomCache[position] = outRect.bottom
mTopCache[position] = outRect.top
} else {
outRect.top = mTopCache[position]!!
outRect.bottom = mBottomCache[position]!!
}
}
}
@@ -223,15 +237,21 @@ class CommonDividerItemDecoration internal constructor(builder: Builder) : ItemD
if (spanIndex == 0) {
outRect.left = mHorizontalExternalSpace + deltaHL
outRect.right = averageDistance - outRect.left
mLastRight = outRect.right
if (state.didStructureChange()) {
mRightCache[position] = outRect.right
}
} else if (spanIndex == spanCount - 1) {
outRect.right = mHorizontalExternalSpace + deltaHR
outRect.left = averageDistance - outRect.right
} else {
outRect.left = mHorizontalInnerSpace - mLastRight
outRect.right = averageDistance - outRect.left
if (state.didStructureChange()) {
mLastRight = outRect.right
outRect.left = mHorizontalInnerSpace - (mRightCache[position - 1] ?: 0)
outRect.right = averageDistance - outRect.left
mLeftCache[position] = outRect.left
mRightCache[position] = outRect.right
} else {
outRect.left = mLeftCache[position]!!
outRect.right = mRightCache[position]!!
}
}
}
@@ -282,15 +302,22 @@ class CommonDividerItemDecoration internal constructor(builder: Builder) : ItemD
if (spanIndex == 0) {
outRect.top = mVerticalExternalSpace + deltaVT
outRect.bottom = averageDistance - outRect.top
mLastBottom = outRect.bottom
if (state.didStructureChange()) {
mBottomCache[position] = outRect.bottom
}
} else if (spanIndex == spanCount - 1) {
outRect.top = mVerticalExternalSpace + deltaVB
outRect.bottom = averageDistance - outRect.top
} else {
outRect.top = mVerticalInnerSpace - mLastBottom
outRect.bottom = averageDistance - outRect.top
if (state.didStructureChange()) {
mLastBottom = outRect.bottom
outRect.top = mVerticalInnerSpace - (mBottomCache[position - 1] ?: 0)
outRect.bottom = averageDistance - outRect.top
mBottomCache[position] = outRect.bottom
mTopCache[position] = outRect.top
} else {
outRect.top = mTopCache[position]!!
outRect.bottom = mBottomCache[position]!!
}
}
}