Skip to content

Commit d9403af

Browse files
committed
Attempted fix of issue 91
1 parent 9360d38 commit d9403af

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apply plugin: 'com.android.library'
22
//apply plugin: 'kotlin-android'
33

4-
def libVersion = '13.2.5'
4+
def libVersion = '13.2.6'
55

66
android {
77
compileSdkVersion 27

lib/src/main/java/com/turingtechnologies/materialscrollbar/ScrollingUtilities.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,10 @@ int scrollToPositionAtProgress(float touchFraction) {
126126
//If the position we wish to scroll to is, say, position 10.5, we scroll to position 10,
127127
//and then offset by 0.5 * rowHeight. This is how we achieve smooth scrolling.
128128
LinearLayoutManager layoutManager = ((LinearLayoutManager) materialScrollBar.recyclerView.getLayoutManager());
129-
layoutManager.scrollToPositionWithOffset(spanCount * exactItemPos / scrollPosState.rowHeight,
130-
-(exactItemPos % scrollPosState.rowHeight));
129+
try {
130+
layoutManager.scrollToPositionWithOffset(spanCount * exactItemPos / scrollPosState.rowHeight,
131+
-(exactItemPos % scrollPosState.rowHeight));
132+
} catch (ArithmeticException e) { /* Avoids issues where children of RV have not yet been laid out */ }
131133
} else {
132134
if(layoutManager == null) {
133135
layoutManager = ((LinearLayoutManager) materialScrollBar.recyclerView.getLayoutManager());

0 commit comments

Comments
 (0)