Skip to content

Commit

Permalink
Fix non-scrollable bottomsheet corners when set directly to STATE_EXP…
Browse files Browse the repository at this point in the history
…ANDED

PiperOrigin-RevId: 230933282
  • Loading branch information
melaniegoetz authored and ymarian committed Jan 25, 2019
1 parent 30c2612 commit c94b520
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ public void setBottomSheetCallback(BottomSheetCallback callback) {
* or {@link #STATE_HALF_EXPANDED}.
*/
public final void setState(@State int state) {
@State int previousState = this.state;
if (state == this.state) {
return;
}
Expand All @@ -692,6 +693,7 @@ public final void setState(@State int state) {
return;
}
startSettlingAnimationPendingLayout(state);
updateDrawableOnStateChange(state, previousState);
}

private void startSettlingAnimationPendingLayout(@State int state) {
Expand Down Expand Up @@ -761,12 +763,14 @@ void setStateInternal(@State int state) {

private void updateDrawableOnStateChange(@State int state, @State int previousState) {
if (materialShapeDrawable != null) {
if (state == STATE_EXPANDED && (parentHeight <= viewRef.get().getHeight())) {
// If the bottomsheet is fully expanded, change ShapeAppearance to sharp corners to
// indicate the bottomsheet has no more content to scroll.
// Overriding of this style may be performed in the bottomsheet callback.
materialShapeDrawable.getShapeAppearanceModel().setCornerRadius(0);
materialShapeDrawable.invalidateSelf();
// If the BottomSheetBehavior's state is set directly to STATE_EXPANDED from
// STATE_HIDDEN or STATE_COLLAPSED, bypassing STATE_DRAGGING, the corner transition animation
// will not be triggered automatically, so we will trigger it here.
if (state == STATE_EXPANDED
&& (previousState == STATE_HIDDEN || previousState == STATE_COLLAPSED)
&& interpolatorAnimator != null
&& interpolatorAnimator.getAnimatedFraction() == 1) {
interpolatorAnimator.reverse();
}
if (state == STATE_DRAGGING
&& previousState == STATE_EXPANDED && interpolatorAnimator != null) {
Expand Down

0 comments on commit c94b520

Please sign in to comment.