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 0006219836b57d466c7e94c0250ea1ddcf072c55..2803eaf15c22d83309b2e195f49546711dde237d 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 |
| @@ -232,8 +232,16 @@ public class BottomSheet extends LinearLayout { |
| root.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { |
| public void onLayoutChange(View v, int left, int top, int right, int bottom, |
| int oldLeft, int oldTop, int oldRight, int oldBottom) { |
| + // Make sure the size of the layout actually changed. |
|
gone
2017/01/20 19:04:08
Can't you just do equality checks? Subtraction of
mdjones
2017/01/20 20:11:47
Yeah, not really sure what I was thinking here. Fi
|
| + if (top - oldTop == 0 && bottom - oldBottom == 0 && left - oldLeft == 0 |
| + && right - oldRight == 0) { |
| + return; |
| + } |
| + |
| mContainerHeight = bottom - top; |
| updateSheetPeekHeight(); |
| + |
| + cancelAnimation(); |
| setSheetState(mCurrentState, false); |
| } |
| }); |
| @@ -242,8 +250,16 @@ public class BottomSheet extends LinearLayout { |
| controlContainer.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { |
| public void onLayoutChange(View v, int left, int top, int right, int bottom, |
| int oldLeft, int oldTop, int oldRight, int oldBottom) { |
| + // Make sure the size of the layout actually changed. |
| + if (top - oldTop == 0 && bottom - oldBottom == 0 && left - oldLeft == 0 |
| + && right - oldRight == 0) { |
| + return; |
| + } |
| + |
| mToolbarHeight = bottom - top; |
| updateSheetPeekHeight(); |
| + |
| + cancelAnimation(); |
| setSheetState(mCurrentState, false); |
| } |
| }); |
| @@ -350,7 +366,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(@SheetState int state, boolean animate) { |
| + public void setSheetState(@SheetState int state, boolean animate) { |
| mCurrentState = state; |
| if (animate) { |
| @@ -361,6 +377,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; |
| + } |
| + |
| + /** |
| * Gets 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. |