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

Commit e06b816e authored by George Mount's avatar George Mount
Browse files

Protect shared element transitions from removed views.

Bug 37970839

When a view is removed from the hierarchy during the shared element
transition, it should not cause a NullPointerException.

Test: I524d99c7235e5888e5be2567c5410644e187b196
Change-Id: I59cadec15ae782c18d95923ceda9851827649341
parent 080e1657
Loading
Loading
Loading
Loading
+16 −12
Original line number Diff line number Diff line
@@ -570,8 +570,10 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver {
            // Find the location in the view's parent
            ViewGroup parent = (ViewGroup) view.getParent();
            Matrix matrix = new Matrix();
            if (parent != null) {
                parent.transformMatrixToLocal(matrix);
                matrix.postTranslate(parent.getScrollX(), parent.getScrollY());
            }
            mSharedElementParentMatrices.add(matrix);
        }
    }
@@ -861,6 +863,7 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver {
            Matrix tempMatrix = new Matrix();
            for (int i = 0; i < numSharedElements; i++) {
                View view = mSharedElements.get(i);
                if (view.isAttachedToWindow()) {
                    tempMatrix.reset();
                    mSharedElementParentMatrices.get(i).invert(tempMatrix);
                    GhostView.addGhost(view, decor, tempMatrix);
@@ -874,6 +877,7 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver {
                }
            }
        }
    }

    protected boolean moveSharedElementWithParent() {
        return true;
@@ -1065,7 +1069,7 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver {
        @Override
        public boolean onPreDraw() {
            GhostView ghostView = GhostView.getGhost(mView);
            if (ghostView == null) {
            if (ghostView == null || !mView.isAttachedToWindow()) {
                removeListener();
            } else {
                GhostView.calculateMatrix(mView, mDecor, mMatrix);