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

Commit 3ca749ba authored by George Mount's avatar George Mount Committed by The Android Automerger
Browse files

Handle null epicenters in EpicenterClipReveal.

Bug 19617067

Change-Id: Ie288288f7a8e0c95ed07d8beb40b78f80048fa98
parent 18a64992
Loading
Loading
Loading
Loading
+27 −6
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.internal.transition;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.RectEvaluator;
import android.content.Context;
@@ -75,13 +76,13 @@ public class EpicenterClipReveal extends Visibility {
            return null;
        }

        final Rect start = getEpicenter();
        final Rect end = getBestRect(endValues);
        final Rect start = getEpicenterOrCenter(end);

        // Prepare the view.
        view.setClipBounds(start);

        return createRectAnimator(view, start, end);
        return createRectAnimator(view, start, end, endValues);
    }

    @Override
@@ -92,12 +93,23 @@ public class EpicenterClipReveal extends Visibility {
        }

        final Rect start = getBestRect(startValues);
        final Rect end = getEpicenter();
        final Rect end = getEpicenterOrCenter(start);

        // Prepare the view.
        view.setClipBounds(start);

        return createRectAnimator(view, start, end);
        return createRectAnimator(view, start, end, endValues);
    }

    private Rect getEpicenterOrCenter(Rect bestRect) {
        final Rect epicenter = getEpicenter();
        if (epicenter != null) {
            return epicenter;
        }

        int centerX = bestRect.centerX();
        int centerY = bestRect.centerY();
        return new Rect(centerX, centerY, centerX, centerY);
    }

    private Rect getBestRect(TransitionValues values) {
@@ -108,8 +120,17 @@ public class EpicenterClipReveal extends Visibility {
        return clipRect;
    }

    private Animator createRectAnimator(View view, Rect start, Rect end) {
    private Animator createRectAnimator(final View view, Rect start, Rect end,
            TransitionValues endValues) {
        final Rect terminalClip = (Rect) endValues.values.get(PROPNAME_CLIP);
        final RectEvaluator evaluator = new RectEvaluator(new Rect());
        return ObjectAnimator.ofObject(view, "clipBounds", evaluator, start, end);
        ObjectAnimator anim = ObjectAnimator.ofObject(view, "clipBounds", evaluator, start, end);
        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                view.setClipBounds(terminalClip);
            }
        });
        return anim;
    }
}