Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 329b6504 authored by Mateusz Cicheński's avatar Mateusz Cicheński
Browse files

Remove dismiss target only when it's attached to a parent.

Bug: 258120818
Change-Id: I63bd5b5cf43db7c794cba84d680b5e168f0e2350
Test: n/a
parent b8b7a230
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -235,21 +235,14 @@ public class PipDismissTargetHandler implements ViewTreeObserver.OnPreDrawListen

    /** Adds the magnetic target view to the WindowManager so it's ready to be animated in. */
    public void createOrUpdateDismissTarget() {
        if (!mTargetViewContainer.isAttachedToWindow()) {
        if (mTargetViewContainer.getParent() == null) {
            mTargetViewContainer.cancelAnimators();

            mTargetViewContainer.setVisibility(View.INVISIBLE);
            mTargetViewContainer.getViewTreeObserver().removeOnPreDrawListener(this);
            mHasDismissTargetSurface = false;

            try {
            mWindowManager.addView(mTargetViewContainer, getDismissTargetLayoutParams());
            } catch (IllegalStateException e) {
                // This shouldn't happen, but if the target is already added, just update its layout
                // params.
                mWindowManager.updateViewLayout(
                        mTargetViewContainer, getDismissTargetLayoutParams());
            }
        } else {
            mWindowManager.updateViewLayout(mTargetViewContainer, getDismissTargetLayoutParams());
        }
@@ -306,7 +299,7 @@ public class PipDismissTargetHandler implements ViewTreeObserver.OnPreDrawListen
     * Removes the dismiss target and cancels any pending callbacks to show it.
     */
    public void cleanUpDismissTarget() {
        if (mTargetViewContainer.isAttachedToWindow()) {
        if (mTargetViewContainer.getParent() != null) {
            mWindowManager.removeViewImmediate(mTargetViewContainer);
        }
    }