Index: chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java |
index 6549ec5fe1feca81f3b860b7d38edc3b3ba23241..2b4934d70ba8c5c3ec9601b0f0d2299453869be9 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheet.java |
@@ -151,6 +151,9 @@ public class BottomSheet |
/** The last non-default toolbar view that was attached to mToolbarHolder. */ |
private View mLastToolbarView; |
+ /** Whether the sheet is currently open. */ |
+ private boolean mIsSheetOpen; |
+ |
/** |
* An interface defining content that can be displayed inside of the bottom sheet for Chrome |
* Home. |
@@ -182,6 +185,11 @@ public class BottomSheet |
* Called to destroy the BottomSheetContent when it is no longer in use. |
*/ |
void destroy(); |
+ |
+ /** |
+ * @return The {@link BottomSheetContentController.ContentType} for this content. |
+ */ |
+ int getType(); |
} |
/** |
@@ -271,6 +279,8 @@ public class BottomSheet |
mGestureDetector = new GestureDetector(context, new BottomSheetSwipeDetector()); |
mGestureDetector.setIsLongpressEnabled(false); |
+ |
+ new BottomSheetMetrics(this); |
} |
@Override |
@@ -505,6 +515,11 @@ public class BottomSheet |
} else { |
mDefaultToolbarView.setVisibility(View.VISIBLE); |
} |
+ |
+ |
gone
2017/03/20 20:29:31
nit: too many newlines
Theresa
2017/03/20 20:59:12
Done.
|
+ for (BottomSheetObserver o : mObservers) { |
+ o.onSheetContentChanged(mSheetContent); |
+ } |
} |
/** |
@@ -525,6 +540,9 @@ public class BottomSheet |
* A notification that the sheet is exiting the peek state into one that shows content. |
*/ |
private void onSheetOpened() { |
+ if (mIsSheetOpen) return; |
+ |
+ mIsSheetOpen = true; |
for (BottomSheetObserver o : mObservers) o.onSheetOpened(); |
} |
@@ -532,6 +550,9 @@ public class BottomSheet |
* A notification that the sheet has returned to the peeking state. |
*/ |
private void onSheetClosed() { |
+ if (!mIsSheetOpen) return; |
+ |
+ mIsSheetOpen = false; |
for (BottomSheetObserver o : mObservers) o.onSheetClosed(); |
} |
@@ -728,6 +749,7 @@ public class BottomSheet |
* move there instantly. |
*/ |
public void setSheetState(@SheetState int state, boolean animate) { |
+ boolean stateChanged = state != mCurrentState; |
mCurrentState = state; |
if (animate) { |
@@ -735,6 +757,12 @@ public class BottomSheet |
} else { |
setSheetOffsetFromBottom(getSheetHeightForState(state)); |
} |
+ |
+ if (!stateChanged) return; |
gone
2017/03/20 20:29:31
Why is this check so far down? Seems like you wou
Theresa
2017/03/20 20:59:12
The sheet doesn't end up in the correct place if t
|
+ |
+ for (BottomSheetObserver o : mObservers) { |
+ o.onSheetStateChanged(mCurrentState); |
+ } |
} |
/** |