diff options
| author | 2019-04-09 10:17:40 -0400 | |
|---|---|---|
| committer | 2019-04-09 17:01:09 -0400 | |
| commit | 8b6a3c6c1c8e8417fef57df4796e12c37f652e3c (patch) | |
| tree | 47195009593bbcb7500dfc257ee0b3765ae43d6f | |
| parent | 85e0a90dab4385b5a9a37ca3cb81d66ec3097fe0 (diff) | |
BubbleData [4/n]: Cleanup StackView initializiation
Make lazy-init of BubbleStackView more explicit.
Bug: 123542488
Test: atest BubbleControllerTest
Change-Id: Ibd51517b606e65124d16d6823b1e8c2a9f5da51c
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java index 5acf3c24fd6a..418d052e1858 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java @@ -220,6 +220,26 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe mSurfaceSynchronizer = synchronizer; } + /** + * BubbleStackView is lazily created by this method the first time a Bubble is added. This + * method initializes the stack view and adds it to the StatusBar just above the scrim. + */ + private void ensureStackViewCreated() { + if (mStackView == null) { + mStackView = new BubbleStackView(mContext, mBubbleData, mSurfaceSynchronizer); + ViewGroup sbv = mStatusBarWindowController.getStatusBarView(); + // TODO(b/130237686): When you expand the shade on top of expanded bubble, there is no + // scrim between bubble and the shade + int bubblePosition = sbv.indexOfChild(sbv.findViewById(R.id.scrim_behind)) + 1; + sbv.addView(mStackView, bubblePosition, + new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); + if (mExpandListener != null) { + mStackView.setExpandListener(mExpandListener); + } + mStackView.setOnBlockedListener(this); + } + } + @Override public void onUiModeChanged() { if (mStackView != null) { @@ -325,27 +345,15 @@ public class BubbleController implements BubbleExpandedView.OnBubbleBlockedListe /** * Adds or updates a bubble associated with the provided notification entry. * - * @param notif the notification associated with this bubble. + * @param notif the notification associated with this bubble. */ void updateBubble(NotificationEntry notif) { if (mStackView != null && mBubbleData.getBubble(notif.key) != null) { // It's an update mStackView.updateBubble(notif); } else { - if (mStackView == null) { - mStackView = new BubbleStackView(mContext, mBubbleData, mSurfaceSynchronizer); - ViewGroup sbv = mStatusBarWindowController.getStatusBarView(); - // XXX: Bug when you expand the shade on top of expanded bubble, there is no scrim - // between bubble and the shade - int bubblePosition = sbv.indexOfChild(sbv.findViewById(R.id.scrim_behind)) + 1; - sbv.addView(mStackView, bubblePosition, - new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)); - if (mExpandListener != null) { - mStackView.setExpandListener(mExpandListener); - } - mStackView.setOnBlockedListener(this); - } // It's new + ensureStackViewCreated(); mStackView.addBubble(notif); } if (shouldAutoExpand(notif)) { |