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

Commit 08f58581 authored by Rohan Shah's avatar Rohan Shah
Browse files

[Notif] Safeguard animation start

Require the view to be attached to window before trying to start
animations.

Fixes: 77922917
Test: Visually, animations still run with screen on
Change-Id: I448ca30b8a1f35218f3d9b69faec6b4d117a2b12
parent 530c4c1f
Loading
Loading
Loading
Loading
+48 −39
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.accessibility.AccessibilityEvent;
@@ -247,6 +248,7 @@ public class NotificationGuts extends FrameLayout {
    /** Animates in the guts view via either a fade or a circular reveal. */
    private void animateOpen(
            boolean shouldDoCircularReveal, int x, int y, @Nullable Runnable onAnimationEnd) {
        if (isAttachedToWindow()) {
            if (shouldDoCircularReveal) {
                double horz = Math.max(getWidth() - x, x);
                double vert = Math.max(getHeight() - y, y);
@@ -267,12 +269,16 @@ public class NotificationGuts extends FrameLayout {
                        .setListener(new AnimateOpenListener(onAnimationEnd))
                        .start();
            }
        } else {
            Log.w(TAG, "Failed to animate guts open");
        }
    }


    /** Animates out the guts view via either a fade or a circular reveal. */
    @VisibleForTesting
    void animateClose(int x, int y, boolean shouldDoCircularReveal) {
        if (isAttachedToWindow()) {
            if (shouldDoCircularReveal) {
                // Circular reveal originating at (x, y)
                if (x == -1 || y == -1) {
@@ -297,6 +303,9 @@ public class NotificationGuts extends FrameLayout {
                        .setListener(new AnimateCloseListener(this /* view */))
                        .start();
            }
        } else {
            Log.w(TAG, "Failed to animate guts close");
        }
    }

    public void setActualHeight(int actualHeight) {