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

Commit 17982084 authored by George Mount's avatar George Mount Committed by Android (Google) Code Review
Browse files

Merge "Fix blinking animation during Visibility transitions."

parents fb421641 4c20ea29
Loading
Loading
Loading
Loading
+29 −23
Original line number Diff line number Diff line
@@ -673,7 +673,7 @@ public abstract class Transition implements Cloneable {
                            startDelays.put(mAnimators.size(), delay);
                            minStartDelay = Math.min(delay, minStartDelay);
                        }
                        AnimationInfo info = new AnimationInfo(view, getName(),
                        AnimationInfo info = new AnimationInfo(view, getName(), this,
                                sceneRoot.getWindowId(), infoValues);
                        runningAnimators.put(animator, info);
                        mAnimators.add(animator);
@@ -1587,30 +1587,10 @@ public abstract class Transition implements Cloneable {
                AnimationInfo oldInfo = runningAnimators.get(anim);
                if (oldInfo != null && oldInfo.view != null &&
                        oldInfo.view.getContext() == sceneRoot.getContext()) {
                    boolean cancel = false;
                    TransitionValues oldValues = oldInfo.values;
                    View oldView = oldInfo.view;
                    TransitionValues newValues = mEndValues.viewValues.get(oldView);
                    if (oldValues != null) {
                        // if oldValues null, then transition didn't care to stash values,
                        // and won't get canceled
                        if (newValues != null) {
                            for (String key : oldValues.values.keySet()) {
                                Object oldValue = oldValues.values.get(key);
                                Object newValue = newValues.values.get(key);
                                if (oldValue != null && newValue != null &&
                                        !oldValue.equals(newValue)) {
                                    cancel = true;
                                    if (DBG) {
                                        Log.d(LOG_TAG, "Transition.playTransition: " +
                                                "oldValue != newValue for " + key +
                                                ": old, new = " + oldValue + ", " + newValue);
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    boolean cancel = oldInfo.transition.areValuesChanged(oldValues, newValues);
                    if (cancel) {
                        if (anim.isRunning() || anim.isStarted()) {
                            if (DBG) {
@@ -1632,6 +1612,29 @@ public abstract class Transition implements Cloneable {
        runAnimators();
    }

    boolean areValuesChanged(TransitionValues oldValues, TransitionValues newValues) {
        boolean valuesChanged = false;
        // if oldValues null, then transition didn't care to stash values,
        // and won't get canceled
        if (oldValues != null && newValues != null) {
            for (String key : oldValues.values.keySet()) {
                Object oldValue = oldValues.values.get(key);
                Object newValue = newValues.values.get(key);
                if (oldValue != null && newValue != null &&
                        !oldValue.equals(newValue)) {
                    valuesChanged = true;
                    if (DBG) {
                        Log.d(LOG_TAG, "Transition.playTransition: " +
                                "oldValue != newValue for " + key +
                                ": old, new = " + oldValue + ", " + newValue);
                    }
                    break;
                }
            }
        }
        return valuesChanged;
    }

    /**
     * This is a utility method used by subclasses to handle standard parts of
     * setting up and running an Animator: it sets the {@link #getDuration()
@@ -2070,12 +2073,15 @@ public abstract class Transition implements Cloneable {
        String name;
        TransitionValues values;
        WindowId windowId;
        Transition transition;

        AnimationInfo(View view, String name, WindowId windowId, TransitionValues values) {
        AnimationInfo(View view, String name, Transition transition,
                WindowId windowId, TransitionValues values) {
            this.view = view;
            this.name = name;
            this.values = values;
            this.windowId = windowId;
            this.transition = transition;
        }
    }

+10 −10
Original line number Diff line number Diff line
@@ -331,16 +331,6 @@ public abstract class Visibility extends Transition {
                    public void onAnimationEnd(Animator animation) {
                        finalSceneRoot.getOverlay().remove(finalOverlayView);
                    }

                    @Override
                    public void onAnimationPause(Animator animation) {
                        finalSceneRoot.getOverlay().remove(finalOverlayView);
                    }

                    @Override
                    public void onAnimationResume(Animator animation) {
                        finalSceneRoot.getOverlay().add(finalOverlayView);
                    }
                });
            }
            return animator;
@@ -409,6 +399,16 @@ public abstract class Visibility extends Transition {
        return overlayView;
    }

    @Override
    boolean areValuesChanged(TransitionValues oldValues, TransitionValues newValues) {
        VisibilityInfo changeInfo = getVisibilityChangeInfo(oldValues, newValues);
        if (oldValues == null && newValues == null) {
            return false;
        }
        return changeInfo.visibilityChange && (changeInfo.startVisibility == View.VISIBLE ||
            changeInfo.endVisibility == View.VISIBLE);
    }

    /**
     * The default implementation of this method returns a null Animator. Subclasses should
     * override this method to make targets disappear with the desired transition. The