File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed
library/src/main/java/com/xiangning/sectionadapter/core Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -3,13 +3,24 @@ package com.xiangning.sectionadapter.core
3
3
/* *
4
4
* 分组信息封装
5
5
*/
6
- data class SectionInfo <T >
6
+ class SectionInfo <T >
7
7
@JvmOverloads
8
- constructor (val section: T , var start: Int , var count: Int = 0 ) {
9
- val end: Int
10
- get() = start + count
8
+ constructor (val section: T , start: Int , count: Int = 0 ) {
9
+ var start: Int = start
10
+ set(value) {
11
+ end + = value - start
12
+ field = value
13
+ }
14
+ var end: Int = start + count
15
+ private set
11
16
12
- operator fun contains (fullPos : Int ): Boolean = fullPos in start until start + count
17
+ var count: Int
18
+ get() = end - start
19
+ set(value) {
20
+ end = start + value
21
+ }
22
+
23
+ operator fun contains (fullPos : Int ): Boolean = fullPos in start until end
13
24
14
25
fun toSectionPos (fullPos : Int ) = fullPos - start
15
26
fun toFullPosition (sectionPos : Int ) = start + sectionPos
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ class SectionListCounter<T : Any> {
13
13
14
14
private val hitInfo = HitInfo <T >()
15
15
16
- private val indexes = LinkedHashMap <T , Int >()
16
+ private val indexes = HashMap <T , Int >()
17
17
private val sectionInfoList = mutableListOf<SectionInfo <T >>()
18
18
19
19
@JvmOverloads
You can’t perform that action at this time.
0 commit comments