Commit 0b8923b4 authored by Friedrich Horschig's avatar Friedrich Horschig Committed by Commit Bot

[Android][BottomSheet] Handle internal states for thresholds

Unfortunate timing may lead the threshold calculation to request a
height for an internal state (e.g. calling expand() right after
requestShowContent() before the animation finishes).

Transition from/to internal states should always succeed, so consider a
threshold cleared if one of the states in transition is internal.

Bug: 1028783
Change-Id: I8650845c23e1ba9f13fd8c79c7e021637d824777
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1939414
Commit-Queue: Friedrich [CET] <fhorschig@chromium.org>
Auto-Submit: Friedrich [CET] <fhorschig@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721056}
parent 6792e22d
...@@ -1030,6 +1030,8 @@ class BottomSheet extends FrameLayout ...@@ -1030,6 +1030,8 @@ class BottomSheet extends FrameLayout
private boolean hasCrossedThresholdToNextState( private boolean hasCrossedThresholdToNextState(
@SheetState int prev, @SheetState int next, float sheetHeight, boolean sheetMovesDown) { @SheetState int prev, @SheetState int next, float sheetHeight, boolean sheetMovesDown) {
if (next == prev) return false; if (next == prev) return false;
// Moving from an internal/temporary state always works:
if (prev == SheetState.NONE || prev == SheetState.SCROLLING) return true;
float lowerBound = getSheetHeightForState(prev); float lowerBound = getSheetHeightForState(prev);
float distance = getSheetHeightForState(next) - lowerBound; float distance = getSheetHeightForState(next) - lowerBound;
return Math.abs((sheetHeight - lowerBound) / distance) return Math.abs((sheetHeight - lowerBound) / distance)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment