am c7f8133f: Merge "Update anchor background on the correct view in PopupWindow" into mnc-dev
* commit 'c7f8133fa1ff78fea5a54974b5987791cb012f84': Update anchor background on the correct view in PopupWindow
This commit is contained in:
@@ -105,7 +105,10 @@ public class PopupWindow {
|
|||||||
/** View that handles event dispatch and content transitions. */
|
/** View that handles event dispatch and content transitions. */
|
||||||
private PopupDecorView mDecorView;
|
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 View mContentView;
|
||||||
|
|
||||||
private boolean mFocusable;
|
private boolean mFocusable;
|
||||||
@@ -1111,18 +1114,18 @@ public class PopupWindow {
|
|||||||
if (aboveAnchor != mAboveAnchor) {
|
if (aboveAnchor != mAboveAnchor) {
|
||||||
mAboveAnchor = aboveAnchor;
|
mAboveAnchor = aboveAnchor;
|
||||||
|
|
||||||
if (mBackground != null) {
|
if (mBackground != null && mBackgroundView != null) {
|
||||||
// If the background drawable provided was a StateListDrawable with above-anchor
|
// If the background drawable provided was a StateListDrawable
|
||||||
// and below-anchor states, use those. Otherwise rely on refreshDrawableState to
|
// with above-anchor and below-anchor states, use those.
|
||||||
// do the job.
|
// Otherwise, rely on refreshDrawableState to do the job.
|
||||||
if (mAboveAnchorBackgroundDrawable != null) {
|
if (mAboveAnchorBackgroundDrawable != null) {
|
||||||
if (mAboveAnchor) {
|
if (mAboveAnchor) {
|
||||||
mDecorView.setBackground(mAboveAnchorBackgroundDrawable);
|
mBackgroundView.setBackground(mAboveAnchorBackgroundDrawable);
|
||||||
} else {
|
} else {
|
||||||
mDecorView.setBackground(mBelowAnchorBackgroundDrawable);
|
mBackgroundView.setBackground(mBelowAnchorBackgroundDrawable);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mDecorView.refreshDrawableState();
|
mBackgroundView.refreshDrawableState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1164,22 +1167,21 @@ public class PopupWindow {
|
|||||||
|
|
||||||
// When a background is available, we embed the content view within
|
// When a background is available, we embed the content view within
|
||||||
// another view that owns the background drawable.
|
// another view that owns the background drawable.
|
||||||
final View backgroundView;
|
|
||||||
if (mBackground != null) {
|
if (mBackground != null) {
|
||||||
backgroundView = createBackgroundView(mContentView);
|
mBackgroundView = createBackgroundView(mContentView);
|
||||||
backgroundView.setBackground(mBackground);
|
mBackgroundView.setBackground(mBackground);
|
||||||
} else {
|
} else {
|
||||||
backgroundView = mContentView;
|
mBackgroundView = mContentView;
|
||||||
}
|
}
|
||||||
|
|
||||||
mDecorView = createDecorView(backgroundView);
|
mDecorView = createDecorView(mBackgroundView);
|
||||||
|
|
||||||
// The background owner should be elevated so that it casts a shadow.
|
// 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
|
// We may wrap that in another view, so we'll need to manually specify
|
||||||
// the surface insets.
|
// 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.surfaceInsets.set(surfaceInset, surfaceInset, surfaceInset, surfaceInset);
|
||||||
p.hasManualSurfaceInsets = true;
|
p.hasManualSurfaceInsets = true;
|
||||||
|
|
||||||
@@ -1650,6 +1652,7 @@ public class PopupWindow {
|
|||||||
// This needs to stay until after all transitions have ended since we
|
// This needs to stay until after all transitions have ended since we
|
||||||
// need the reference to cancel transitions in preparePopup().
|
// need the reference to cancel transitions in preparePopup().
|
||||||
mDecorView = null;
|
mDecorView = null;
|
||||||
|
mBackgroundView = null;
|
||||||
mIsTransitioningToDismiss = false;
|
mIsTransitioningToDismiss = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user