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

Commit 3ddc33e2 authored by Chet Haase's avatar Chet Haase Committed by Android Git Automerger
Browse files

am 52485b0b: Merge "Better transition interruption and TextChange fixes" into klp-dev

* commit '52485b0b':
  Better transition interruption and TextChange fixes
parents b889b546 52485b0b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ public class Move extends Transition {
    private static final String PROPNAME_PARENT = "android:move:parent";
    private static final String PROPNAME_WINDOW_X = "android:move:windowX";
    private static final String PROPNAME_WINDOW_Y = "android:move:windowY";
    private static String[] sTransitionProperties = {
    private static final String[] sTransitionProperties = {
            PROPNAME_BOUNDS,
            PROPNAME_PARENT,
            PROPNAME_WINDOW_X,
+32 −3
Original line number Diff line number Diff line
@@ -78,6 +78,10 @@ public class TextChange extends Transition {
     */
    public static final int CHANGE_BEHAVIOR_OUT_IN = 3;

    private static final String[] sTransitionProperties = {
            PROPNAME_TEXT
    };

    /**
     * Sets the type of changing animation that will be run, one of
     * {@link #CHANGE_BEHAVIOR_KEEP} and {@link #CHANGE_BEHAVIOR_OUT_IN}.
@@ -91,6 +95,11 @@ public class TextChange extends Transition {
        }
    }

    @Override
    public String[] getTransitionProperties() {
        return sTransitionProperties;
    }

    @Override
    protected void captureValues(TransitionValues values, boolean start) {
        if (values.view instanceof TextView) {
@@ -111,7 +120,7 @@ public class TextChange extends Transition {
        final TextView view = (TextView) endValues.view;
        Map<String, Object> startVals = startValues.values;
        Map<String, Object> endVals = endValues.values;
        String startText = (String) startVals.get(PROPNAME_TEXT);
        final String startText = (String) startVals.get(PROPNAME_TEXT);
        final String endText = (String) endVals.get(PROPNAME_TEXT);
        if (!startText.equals(endText)) {
            view.setText(startText);
@@ -121,8 +130,11 @@ public class TextChange extends Transition {
                anim.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        if (startText.equals(view.getText())) {
                            // Only set if it hasn't been changed since anim started
                            view.setText(endText);
                        }
                    }
                });
            } else {
                // Fade out start text
@@ -143,8 +155,11 @@ public class TextChange extends Transition {
                    outAnim.addListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            if (startText.equals(view.getText())) {
                                // Only set if it hasn't been changed since anim started
                                view.setText(endText);
                            }
                        }
                    });
                }
                if (mChangeBehavior == CHANGE_BEHAVIOR_OUT_IN ||
@@ -169,6 +184,20 @@ public class TextChange extends Transition {
                    anim = inAnim;
                }
            }
            TransitionListener transitionListener = new TransitionListenerAdapter() {
                boolean mCanceled = false;

                @Override
                public void onTransitionPause(Transition transition) {
                    view.setText(endText);
                }

                @Override
                public void onTransitionResume(Transition transition) {
                    view.setText(startText);
                }
            };
            addListener(transitionListener);
            return anim;
        }
        return null;
+17 −15
Original line number Diff line number Diff line
@@ -843,7 +843,6 @@ public abstract class Transition implements Cloneable {
        for (int i = numOldAnims - 1; i >= 0; i--) {
            Animator anim = runningAnimators.keyAt(i);
            if (anim != null) {
                anim.resume();
                AnimationInfo oldInfo = runningAnimators.get(anim);
                if (oldInfo != null) {
                    boolean cancel = false;
@@ -851,25 +850,28 @@ public abstract class Transition implements Cloneable {
                    View oldView = oldInfo.view;
                    TransitionValues newValues = mEndValues.viewValues != null ?
                            mEndValues.viewValues.get(oldView) : null;
                    if (oldValues == null || newValues == null) {
                        if (oldValues != null || newValues != null) {
                    if (oldValues != null) {
                        // if oldValues null, then transition didn't care to stash values,
                        // and won't get canceled
                        if (newValues == null) {
                            cancel = true;
                        }
                        } else {
                            for (String key : oldValues.values.keySet()) {
                                Object oldValue = oldValues.values.get(key);
                                Object newValue = newValues.values.get(key);
                            if ((oldValue == null && newValue != null) ||
                                    (oldValue != null && !oldValue.equals(newValue))) {
                                if (oldValue != null && newValue != null &&
                                        !oldValue.equals(newValue)) {
                                    cancel = true;
                                    if (DBG) {
                                    Log.d(LOG_TAG, "Transition.play: oldValue != newValue for " +
                                            key + ": old, new = " + oldValue + ", " + newValue);
                                        Log.d(LOG_TAG, "Transition.playTransition: " +
                                                "oldValue != newValue for " + key +
                                                ": old, new = " + oldValue + ", " + newValue);
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    if (cancel) {
                        if (anim.isRunning() || anim.isStarted()) {
                            if (DBG) {
+8 −0
Original line number Diff line number Diff line
@@ -183,9 +183,12 @@ public class TransitionManager {
                    final ArrayMap<ViewGroup, ArrayList<Transition>> runningTransitions =
                            getRunningTransitions();
                    ArrayList<Transition> currentTransitions = runningTransitions.get(sceneRoot);
                    ArrayList<Transition> previousRunningTransitions = null;
                    if (currentTransitions == null) {
                        currentTransitions = new ArrayList<Transition>();
                        runningTransitions.put(sceneRoot, currentTransitions);
                    } else if (currentTransitions.size() > 0) {
                        previousRunningTransitions = new ArrayList<Transition>(currentTransitions);
                    }
                    currentTransitions.add(transition);
                    transition.addListener(new Transition.TransitionListenerAdapter() {
@@ -197,6 +200,11 @@ public class TransitionManager {
                        }
                    });
                    transition.captureValues(sceneRoot, false);
                    if (previousRunningTransitions != null) {
                        for (Transition runningTransition : previousRunningTransitions) {
                            runningTransition.resume();
                        }
                    }
                    transition.playTransition(sceneRoot);

                    // Returning false from onPreDraw() skips the current frame. This is
+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ public abstract class Visibility extends Transition {

    private static final String PROPNAME_VISIBILITY = "android:visibility:visibility";
    private static final String PROPNAME_PARENT = "android:visibility:parent";
    private static String[] sTransitionProperties = {
    private static final String[] sTransitionProperties = {
            PROPNAME_VISIBILITY,
            PROPNAME_PARENT,
    };