Skip to content

Commit 34df6d9

Browse files
committed
[BottomSheet] Fixed NullPointerException when calling updatePeekHeight with null viewRef
PiperOrigin-RevId: 323107185
1 parent 1047370 commit 34df6d9

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lib/java/com/google/android/material/bottomsheet/BottomSheetBehavior.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -770,20 +770,22 @@ public final void setPeekHeight(int peekHeight, boolean animate) {
770770
}
771771
// If sheet is already laid out, recalculate the collapsed offset based on new setting.
772772
// Otherwise, let onLayoutChild handle this later.
773-
if (layout && viewRef != null) {
773+
if (layout) {
774774
updatePeekHeight(animate);
775775
}
776776
}
777777

778778
private void updatePeekHeight(boolean animate) {
779-
calculateCollapsedOffset();
780-
if (state == STATE_COLLAPSED) {
781-
V view = viewRef.get();
782-
if (view != null) {
783-
if (animate) {
784-
settleToStatePendingLayout(state);
785-
} else {
786-
view.requestLayout();
779+
if (viewRef != null) {
780+
calculateCollapsedOffset();
781+
if (state == STATE_COLLAPSED) {
782+
V view = viewRef.get();
783+
if (view != null) {
784+
if (animate) {
785+
settleToStatePendingLayout(state);
786+
} else {
787+
view.requestLayout();
788+
}
787789
}
788790
}
789791
}

0 commit comments

Comments
 (0)