Loading core/java/android/widget/PopupWindow.java +25 −16 Original line number Original line Diff line number Diff line Loading @@ -1834,7 +1834,8 @@ public class PopupWindow { // can expect the OnAttachStateChangeListener to have been called prior // can expect the OnAttachStateChangeListener to have been called prior // to executing this method, so we can rely on that instead. // to executing this method, so we can rely on that instead. final Transition exitTransition = mExitTransition; final Transition exitTransition = mExitTransition; if (mIsAnchorRootAttached && exitTransition != null && decorView.isLaidOut()) { if (exitTransition != null && decorView.isLaidOut() && (mIsAnchorRootAttached || mAnchorRoot == null)) { // The decor view is non-interactive and non-IME-focusable during exit transitions. // The decor view is non-interactive and non-IME-focusable during exit transitions. final LayoutParams p = (LayoutParams) decorView.getLayoutParams(); final LayoutParams p = (LayoutParams) decorView.getLayoutParams(); p.flags |= LayoutParams.FLAG_NOT_TOUCHABLE; p.flags |= LayoutParams.FLAG_NOT_TOUCHABLE; Loading @@ -1842,18 +1843,13 @@ public class PopupWindow { p.flags &= ~LayoutParams.FLAG_ALT_FOCUSABLE_IM; p.flags &= ~LayoutParams.FLAG_ALT_FOCUSABLE_IM; mWindowManager.updateViewLayout(decorView, p); mWindowManager.updateViewLayout(decorView, p); final View anchorRoot = mAnchorRoot != null ? mAnchorRoot.get() : null; final Rect epicenter = getTransitionEpicenter(); // Once we start dismissing the decor view, all state (including // Once we start dismissing the decor view, all state (including // the anchor root) needs to be moved to the decor view since we // the anchor root) needs to be moved to the decor view since we // may open another popup while it's busy exiting. // may open another popup while it's busy exiting. final View anchorRoot = mAnchorRoot != null ? mAnchorRoot.get() : null; decorView.startExitTransition(exitTransition, anchorRoot, epicenter, final Rect epicenter = getTransitionEpicenter(); exitTransition.setEpicenterCallback(new EpicenterCallback() { @Override public Rect onGetEpicenter(Transition transition) { return epicenter; } }); decorView.startExitTransition(exitTransition, anchorRoot, new TransitionListenerAdapter() { new TransitionListenerAdapter() { @Override @Override public void onTransitionEnd(Transition transition) { public void onTransitionEnd(Transition transition) { Loading Loading @@ -2348,8 +2344,9 @@ public class PopupWindow { * its {@code onTransitionEnd} method called even if the transition * its {@code onTransitionEnd} method called even if the transition * never starts; however, it may be called with a {@code null} argument. * never starts; however, it may be called with a {@code null} argument. */ */ public void startExitTransition(Transition transition, final View anchorRoot, public void startExitTransition(@NonNull Transition transition, final TransitionListener listener) { @Nullable final View anchorRoot, @Nullable final Rect epicenter, @NonNull final TransitionListener listener) { if (transition == null) { if (transition == null) { return; return; } } Loading @@ -2357,23 +2354,35 @@ public class PopupWindow { // The anchor view's window may go away while we're executing our // The anchor view's window may go away while we're executing our // transition, in which case we need to end the transition // transition, in which case we need to end the transition // immediately and execute the listener to remove the popup. // immediately and execute the listener to remove the popup. if (anchorRoot != null) { anchorRoot.addOnAttachStateChangeListener(mOnAnchorRootDetachedListener); anchorRoot.addOnAttachStateChangeListener(mOnAnchorRootDetachedListener); } // The exit listener MUST be called for cleanup, even if the // The exit listener MUST be called for cleanup, even if the // transition never starts or ends. Stash it for later. // transition never starts or ends. Stash it for later. mPendingExitListener = new TransitionListenerAdapter() { mPendingExitListener = new TransitionListenerAdapter() { @Override @Override public void onTransitionEnd(Transition transition) { public void onTransitionEnd(Transition t) { if (anchorRoot != null) { anchorRoot.removeOnAttachStateChangeListener(mOnAnchorRootDetachedListener); anchorRoot.removeOnAttachStateChangeListener(mOnAnchorRootDetachedListener); listener.onTransitionEnd(transition); } listener.onTransitionEnd(t); // The listener was called. Our job here is done. // The listener was called. Our job here is done. mPendingExitListener = null; mPendingExitListener = null; t.removeListener(this); } } }; }; final Transition exitTransition = transition.clone(); final Transition exitTransition = transition.clone(); exitTransition.addListener(mPendingExitListener); exitTransition.addListener(mPendingExitListener); exitTransition.setEpicenterCallback(new EpicenterCallback() { @Override public Rect onGetEpicenter(Transition transition) { return epicenter; } }); final int count = getChildCount(); final int count = getChildCount(); for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) { Loading Loading
core/java/android/widget/PopupWindow.java +25 −16 Original line number Original line Diff line number Diff line Loading @@ -1834,7 +1834,8 @@ public class PopupWindow { // can expect the OnAttachStateChangeListener to have been called prior // can expect the OnAttachStateChangeListener to have been called prior // to executing this method, so we can rely on that instead. // to executing this method, so we can rely on that instead. final Transition exitTransition = mExitTransition; final Transition exitTransition = mExitTransition; if (mIsAnchorRootAttached && exitTransition != null && decorView.isLaidOut()) { if (exitTransition != null && decorView.isLaidOut() && (mIsAnchorRootAttached || mAnchorRoot == null)) { // The decor view is non-interactive and non-IME-focusable during exit transitions. // The decor view is non-interactive and non-IME-focusable during exit transitions. final LayoutParams p = (LayoutParams) decorView.getLayoutParams(); final LayoutParams p = (LayoutParams) decorView.getLayoutParams(); p.flags |= LayoutParams.FLAG_NOT_TOUCHABLE; p.flags |= LayoutParams.FLAG_NOT_TOUCHABLE; Loading @@ -1842,18 +1843,13 @@ public class PopupWindow { p.flags &= ~LayoutParams.FLAG_ALT_FOCUSABLE_IM; p.flags &= ~LayoutParams.FLAG_ALT_FOCUSABLE_IM; mWindowManager.updateViewLayout(decorView, p); mWindowManager.updateViewLayout(decorView, p); final View anchorRoot = mAnchorRoot != null ? mAnchorRoot.get() : null; final Rect epicenter = getTransitionEpicenter(); // Once we start dismissing the decor view, all state (including // Once we start dismissing the decor view, all state (including // the anchor root) needs to be moved to the decor view since we // the anchor root) needs to be moved to the decor view since we // may open another popup while it's busy exiting. // may open another popup while it's busy exiting. final View anchorRoot = mAnchorRoot != null ? mAnchorRoot.get() : null; decorView.startExitTransition(exitTransition, anchorRoot, epicenter, final Rect epicenter = getTransitionEpicenter(); exitTransition.setEpicenterCallback(new EpicenterCallback() { @Override public Rect onGetEpicenter(Transition transition) { return epicenter; } }); decorView.startExitTransition(exitTransition, anchorRoot, new TransitionListenerAdapter() { new TransitionListenerAdapter() { @Override @Override public void onTransitionEnd(Transition transition) { public void onTransitionEnd(Transition transition) { Loading Loading @@ -2348,8 +2344,9 @@ public class PopupWindow { * its {@code onTransitionEnd} method called even if the transition * its {@code onTransitionEnd} method called even if the transition * never starts; however, it may be called with a {@code null} argument. * never starts; however, it may be called with a {@code null} argument. */ */ public void startExitTransition(Transition transition, final View anchorRoot, public void startExitTransition(@NonNull Transition transition, final TransitionListener listener) { @Nullable final View anchorRoot, @Nullable final Rect epicenter, @NonNull final TransitionListener listener) { if (transition == null) { if (transition == null) { return; return; } } Loading @@ -2357,23 +2354,35 @@ public class PopupWindow { // The anchor view's window may go away while we're executing our // The anchor view's window may go away while we're executing our // transition, in which case we need to end the transition // transition, in which case we need to end the transition // immediately and execute the listener to remove the popup. // immediately and execute the listener to remove the popup. if (anchorRoot != null) { anchorRoot.addOnAttachStateChangeListener(mOnAnchorRootDetachedListener); anchorRoot.addOnAttachStateChangeListener(mOnAnchorRootDetachedListener); } // The exit listener MUST be called for cleanup, even if the // The exit listener MUST be called for cleanup, even if the // transition never starts or ends. Stash it for later. // transition never starts or ends. Stash it for later. mPendingExitListener = new TransitionListenerAdapter() { mPendingExitListener = new TransitionListenerAdapter() { @Override @Override public void onTransitionEnd(Transition transition) { public void onTransitionEnd(Transition t) { if (anchorRoot != null) { anchorRoot.removeOnAttachStateChangeListener(mOnAnchorRootDetachedListener); anchorRoot.removeOnAttachStateChangeListener(mOnAnchorRootDetachedListener); listener.onTransitionEnd(transition); } listener.onTransitionEnd(t); // The listener was called. Our job here is done. // The listener was called. Our job here is done. mPendingExitListener = null; mPendingExitListener = null; t.removeListener(this); } } }; }; final Transition exitTransition = transition.clone(); final Transition exitTransition = transition.clone(); exitTransition.addListener(mPendingExitListener); exitTransition.addListener(mPendingExitListener); exitTransition.setEpicenterCallback(new EpicenterCallback() { @Override public Rect onGetEpicenter(Transition transition) { return epicenter; } }); final int count = getChildCount(); final int count = getChildCount(); for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) { Loading