Skip to content

Commit 1e147f5

Browse files
KryptKodethagikura
authored andcommitted
Fixed issue #474 (#490)
* Fixed issue 474, canScrollHorizontally() throws NPE if the RecyclerView is not attached to the Window
1 parent 7bf1ce7 commit 1e147f5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,7 +1898,7 @@ public boolean canScrollHorizontally() {
18981898
if (mFlexWrap == FlexWrap.NOWRAP) {
18991899
return isMainAxisDirectionHorizontal();
19001900
} else {
1901-
return !isMainAxisDirectionHorizontal() || getWidth() > mParent.getWidth();
1901+
return !isMainAxisDirectionHorizontal() || getWidth() > (mParent != null ? mParent.getWidth() : 0);
19021902
}
19031903
}
19041904

@@ -1907,7 +1907,7 @@ public boolean canScrollVertically() {
19071907
if (mFlexWrap == FlexWrap.NOWRAP) {
19081908
return !isMainAxisDirectionHorizontal();
19091909
} else {
1910-
return isMainAxisDirectionHorizontal() || getHeight() > mParent.getHeight();
1910+
return isMainAxisDirectionHorizontal() || getHeight() > (mParent != null ? mParent.getHeight() : 0);
19111911
}
19121912
}
19131913

0 commit comments

Comments
 (0)