Skip to content

Commit

Permalink
Make AnchoredPopupWindow update the popup layout when the view does.
Browse files Browse the repository at this point in the history
This CL makes AnchoredPopupWindow listen to layout changes of the list
menu's content view, updating the layout of the popup in response.

(cherry picked from commit 23c7af9)

Bug: 1316392
Change-Id: I541234181392b55df065fba52d08c436b32676ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3594445
Reviewed-by: Lijin Shen <lazzzis@google.com>
Commit-Queue: Scott Little <sclittle@chromium.org>
Auto-Submit: Scott Little <sclittle@chromium.org>
Reviewed-by: Theresa Sullivan <twellington@chromium.org>
Commit-Queue: Theresa Sullivan <twellington@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#994321}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3606568
Cr-Commit-Position: refs/branch-heads/5005@{#151}
Cr-Branched-From: 5b4d945-refs/heads/main@{#992738}
  • Loading branch information
scott-little authored and Chromium LUCI CQ committed Apr 25, 2022
1 parent 9b59717 commit a5d4793
Showing 1 changed file with 14 additions and 0 deletions.
Expand Up @@ -138,6 +138,9 @@ public void run() {
public void onDismiss() {
if (mIgnoreDismissal) return;

mPopupWindow.getContentView().removeOnLayoutChangeListener(
mContentViewOnLayoutChangeListener);

mHandler.removeCallbacks(mDismissRunnable);
for (OnDismissListener listener : mDismissListeners) listener.onDismiss();

Expand Down Expand Up @@ -186,6 +189,15 @@ public void onDismiss() {
private boolean mUpdateOrientationOnChange;
private boolean mSmartAnchorWithMaxWidth;

private final View.OnLayoutChangeListener mContentViewOnLayoutChangeListener =
new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
if (mPopupWindow.isShowing()) updatePopupLayout();
}
};

/**
* Constructs an {@link AnchoredPopupWindow} instance.
* @param context Context to draw resources from.
Expand Down Expand Up @@ -222,6 +234,8 @@ public void show() {

updatePopupLayout();
showPopupWindow();

mPopupWindow.getContentView().addOnLayoutChangeListener(mContentViewOnLayoutChangeListener);
}

/**
Expand Down

0 comments on commit a5d4793

Please sign in to comment.