diff options
| author | Alan Viverette <alanv@google.com> | 2015-08-06 12:36:47 -0400 |
|---|---|---|
| committer | Alan Viverette <alanv@google.com> | 2015-08-06 12:36:47 -0400 |
| commit | 697804e8de9f0a838a90c571baad19c5ed4d1647 (patch) | |
| tree | a72279180e0ef55925e84d10a2a06f2be4dd604c /core/java | |
| parent | d5a6df6d228036258d616245502c1a4f85ba4b2e (diff) | |
| download | frameworks_base-697804e8de9f0a838a90c571baad19c5ed4d1647.zip frameworks_base-697804e8de9f0a838a90c571baad19c5ed4d1647.tar.gz frameworks_base-697804e8de9f0a838a90c571baad19c5ed4d1647.tar.bz2 | |
Update anchor background on the correct view in PopupWindow
We were always setting the background of the decor view when the
"above anchor" state changed, rather than the background view.
Bug: 22970244
Change-Id: I3cd7202767ee47cb415736bb3c07369801abccd8
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/widget/PopupWindow.java | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java index b4cbf35..f9fa027 100644 --- a/core/java/android/widget/PopupWindow.java +++ b/core/java/android/widget/PopupWindow.java @@ -105,7 +105,10 @@ public class PopupWindow { /** View that handles event dispatch and content transitions. */ private PopupDecorView mDecorView; - /** The contents of the popup. */ + /** View that holds the background and may animate during a transition. */ + private View mBackgroundView; + + /** The contents of the popup. May be identical to the background view. */ private View mContentView; private boolean mFocusable; @@ -1111,18 +1114,18 @@ public class PopupWindow { if (aboveAnchor != mAboveAnchor) { mAboveAnchor = aboveAnchor; - if (mBackground != null) { - // If the background drawable provided was a StateListDrawable with above-anchor - // and below-anchor states, use those. Otherwise rely on refreshDrawableState to - // do the job. + if (mBackground != null && mBackgroundView != null) { + // If the background drawable provided was a StateListDrawable + // with above-anchor and below-anchor states, use those. + // Otherwise, rely on refreshDrawableState to do the job. if (mAboveAnchorBackgroundDrawable != null) { if (mAboveAnchor) { - mDecorView.setBackground(mAboveAnchorBackgroundDrawable); + mBackgroundView.setBackground(mAboveAnchorBackgroundDrawable); } else { - mDecorView.setBackground(mBelowAnchorBackgroundDrawable); + mBackgroundView.setBackground(mBelowAnchorBackgroundDrawable); } } else { - mDecorView.refreshDrawableState(); + mBackgroundView.refreshDrawableState(); } } } @@ -1164,22 +1167,21 @@ public class PopupWindow { // When a background is available, we embed the content view within // another view that owns the background drawable. - final View backgroundView; if (mBackground != null) { - backgroundView = createBackgroundView(mContentView); - backgroundView.setBackground(mBackground); + mBackgroundView = createBackgroundView(mContentView); + mBackgroundView.setBackground(mBackground); } else { - backgroundView = mContentView; + mBackgroundView = mContentView; } - mDecorView = createDecorView(backgroundView); + mDecorView = createDecorView(mBackgroundView); // The background owner should be elevated so that it casts a shadow. - backgroundView.setElevation(mElevation); + mBackgroundView.setElevation(mElevation); // We may wrap that in another view, so we'll need to manually specify // the surface insets. - final int surfaceInset = (int) Math.ceil(backgroundView.getZ() * 2); + final int surfaceInset = (int) Math.ceil(mBackgroundView.getZ() * 2); p.surfaceInsets.set(surfaceInset, surfaceInset, surfaceInset, surfaceInset); p.hasManualSurfaceInsets = true; @@ -1650,6 +1652,7 @@ public class PopupWindow { // This needs to stay until after all transitions have ended since we // need the reference to cancel transitions in preparePopup(). mDecorView = null; + mBackgroundView = null; mIsTransitioningToDismiss = false; } |
