Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/widget/BottomSheet.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/BottomSheet.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/BottomSheet.java |
| index 83dbfd4c07a7a341742f61cddb230a028b3c5bcc..fe103bda1b8018e6f417a1dbee1e3acf112049c5 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/widget/BottomSheet.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/BottomSheet.java |
| @@ -222,7 +222,9 @@ public class BottomSheet extends LinearLayout { |
| int oldLeft, int oldTop, int oldRight, int oldBottom) { |
| mContainerHeight = bottom - top; |
| updateSheetPeekHeight(mToolbarHeight, mContainerHeight); |
| - setSheetState(mCurrentState, false); |
| + |
| + // If animating, don't reset the sheet position. |
| + if (!isRunningSettleAnimation()) setSheetState(mCurrentState, false); |
|
Ian Wen
2017/01/17 19:23:59
I think you could cancel the current animation, an
mdjones
2017/01/17 21:59:31
This was for when the keyboard shows, onLayoutChan
|
| } |
| }); |
| @@ -232,7 +234,9 @@ public class BottomSheet extends LinearLayout { |
| int oldLeft, int oldTop, int oldRight, int oldBottom) { |
| mToolbarHeight = bottom - top; |
| updateSheetPeekHeight(mToolbarHeight, mContainerHeight); |
| - setSheetState(mCurrentState, false); |
| + |
| + // If animating, don't reset the sheet position. |
| + if (!isRunningSettleAnimation()) setSheetState(mCurrentState, false); |
| } |
| }); |
| } |
| @@ -340,7 +344,7 @@ public class BottomSheet extends LinearLayout { |
| * @param animate If true, the sheet will animate to the provided state, otherwise it will |
| * move there instantly. |
| */ |
| - private void setSheetState(int state, boolean animate) { |
| + public void setSheetState(int state, boolean animate) { |
| mCurrentState = state; |
| if (animate) { |
| @@ -351,6 +355,22 @@ public class BottomSheet extends LinearLayout { |
| } |
| /** |
| + * @return The current state of the bottom sheet. If the sheet is animating, this will be the |
| + * state the sheet is animating to. |
| + */ |
| + public int getSheetState() { |
| + return mCurrentState; |
| + } |
| + |
| + /** |
| + * If the animation to settle the sheet in one of its states is running. |
| + * @return True if the animation is running. |
| + */ |
| + private boolean isRunningSettleAnimation() { |
| + return mSettleAnimator != null; |
| + } |
| + |
| + /** |
| * Get the height of the bottom sheet based on a provided state. |
| * @param state The state to get the height from. |
| * @return The height of the sheet at the provided state. |