This repository was archived by the owner on Jul 7, 2019. It is now read-only.
File tree 3 files changed +9
-8
lines changed
src/main/java/com/zhukic/sectionedrecyclerview 3 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ The Gradle dependency is available via [jCenter](https://bintray.com/zhukic/mave
12
12
13
13
Add this to your ` build.gradle ` file.
14
14
``` gradle
15
- implementation 'com.github.zhukic:sectioned-recyclerview:1.2.2 '
15
+ implementation 'com.github.zhukic:sectioned-recyclerview:1.2.3 '
16
16
```
17
17
18
18
# How it works
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ apply plugin: 'com.android.library'
3
3
ext {
4
4
PUBLISH_GROUP_ID = ' com.github.zhukic'
5
5
PUBLISH_ARTIFACT_ID = ' sectioned-recyclerview'
6
- PUBLISH_VERSION = ' 1.2.2 '
6
+ PUBLISH_VERSION = ' 1.2.3 '
7
7
}
8
8
9
9
android {
Original file line number Diff line number Diff line change @@ -949,11 +949,12 @@ NotifyResult onItemInserted(int itemPosition) {
949
949
int sectionIndex (@ IntRange (from = 0 , to = Integer .MAX_VALUE ) int adapterPosition ) {
950
950
int sectionIndex = 0 ;
951
951
952
- for (Section section : sections ) {
952
+ for (int i = 0 ; i < sections .size (); i ++) {
953
+ final Section section = sections .get (i );
953
954
if (adapterPosition == section .getSubheaderPosition ()) {
954
- return sections . indexOf ( section ) ;
955
+ return i ;
955
956
} else if (adapterPosition > section .getSubheaderPosition ()) {
956
- sectionIndex = sections . indexOf ( section ) ;
957
+ sectionIndex = i ;
957
958
}
958
959
}
959
960
@@ -1081,14 +1082,14 @@ private Section getLastSection() {
1081
1082
private int sectionIndexByItemPosition (@ IntRange (from = 0 , to = Integer .MAX_VALUE ) int itemPosition ) {
1082
1083
int itemCount = 0 ;
1083
1084
1084
- for (Section section : sections ) {
1085
+ for (int i = 0 ; i < sections .size (); i ++) {
1086
+ final Section section = sections .get (i );
1085
1087
1086
1088
itemCount += section .getItemCount ();
1087
1089
1088
1090
if (itemCount > itemPosition ) {
1089
- return sections . indexOf ( section ) ;
1091
+ return i ;
1090
1092
}
1091
-
1092
1093
}
1093
1094
1094
1095
return sections .size () - 1 ;
You can’t perform that action at this time.
0 commit comments