SlideKitkat.java revision 33f66eb67b6457ea75434dfd9f79703ad9e03560
12f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu/*
22f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu * Copyright (C) 2014 The Android Open Source Project
32f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu *
42f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu * Licensed under the Apache License, Version 2.0 (the "License");
52f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu * you may not use this file except in compliance with the License.
62f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu * You may obtain a copy of the License at
72f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu *
82f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu *      http://www.apache.org/licenses/LICENSE-2.0
92f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu *
102f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu * Unless required by applicable law or agreed to in writing, software
112f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu * distributed under the License is distributed on an "AS IS" BASIS,
122f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
132f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu * See the License for the specific language governing permissions and
142f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu * limitations under the License.
152f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu */
1695400e6d31a1ac09e48cb8944a79b7250484aa4cDake Gupackage android.support.v17.leanback.transition;
172f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
182f97594742886d045ca1ce409ebc6e6e780452f6Dake Guimport android.animation.Animator;
192f97594742886d045ca1ce409ebc6e6e780452f6Dake Guimport android.animation.AnimatorListenerAdapter;
202f97594742886d045ca1ce409ebc6e6e780452f6Dake Guimport android.animation.AnimatorSet;
212f97594742886d045ca1ce409ebc6e6e780452f6Dake Guimport android.animation.ObjectAnimator;
222f97594742886d045ca1ce409ebc6e6e780452f6Dake Guimport android.animation.TimeInterpolator;
232f97594742886d045ca1ce409ebc6e6e780452f6Dake Guimport android.animation.ValueAnimator;
242f97594742886d045ca1ce409ebc6e6e780452f6Dake Guimport android.graphics.Rect;
252f97594742886d045ca1ce409ebc6e6e780452f6Dake Guimport android.util.Log;
262f97594742886d045ca1ce409ebc6e6e780452f6Dake Guimport android.util.Property;
272f97594742886d045ca1ce409ebc6e6e780452f6Dake Guimport android.view.View;
282f97594742886d045ca1ce409ebc6e6e780452f6Dake Guimport android.view.ViewGroup;
292f97594742886d045ca1ce409ebc6e6e780452f6Dake Guimport android.view.animation.AccelerateInterpolator;
302f97594742886d045ca1ce409ebc6e6e780452f6Dake Guimport android.view.animation.DecelerateInterpolator;
312f97594742886d045ca1ce409ebc6e6e780452f6Dake Guimport android.transition.Visibility;
322f97594742886d045ca1ce409ebc6e6e780452f6Dake Guimport android.transition.Transition;
332f97594742886d045ca1ce409ebc6e6e780452f6Dake Guimport android.transition.TransitionValues;
3433f66eb67b6457ea75434dfd9f79703ad9e03560Dake Guimport android.support.v17.leanback.R;
352f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
362f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu/**
372f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu * Slide distance toward/from a edge.  The direction and distance are determined by
382f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu * {@link SlideCallback}.
392f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu */
402f97594742886d045ca1ce409ebc6e6e780452f6Dake Guclass Slide extends Visibility {
412f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    private static final String TAG = "Slide";
422f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
432f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    /**
442f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu     * Move Views in or out of the left edge of the scene.
452f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu     * @see #setSlideEdge(int)
462f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu     */
472f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    public static final int LEFT = 0;
482f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
492f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    /**
502f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu     * Move Views in or out of the top edge of the scene.
512f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu     * @see #setSlideEdge(int)
522f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu     */
532f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    public static final int TOP = 1;
542f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
552f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    /**
562f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu     * Move Views in or out of the right edge of the scene.
572f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu     * @see #setSlideEdge(int)
582f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu     */
592f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    public static final int RIGHT = 2;
602f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
612f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    /**
622f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu     * Move Views in or out of the bottom edge of the scene. This is the
632f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu     * default slide direction.
642f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu     * @see #setSlideEdge(int)
652f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu     */
662f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    public static final int BOTTOM = 3;
672f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
682f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    private static final TimeInterpolator sDecelerate = new DecelerateInterpolator();
692f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    private static final TimeInterpolator sAccelerate = new AccelerateInterpolator();
702f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
712f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    private int[] mTempLoc = new int[2];
722f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    SlideCallback mCallback;
732f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    private int[] mTempEdge = new int[1];
742f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    private float[] mTempDistance = new float[1];
752f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
762f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    private interface CalculateSlide {
772f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        /** Returns the translation value for view when it out of the scene */
782f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        float getGone(float slide, View view);
792f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
802f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        /** Returns the translation value for view when it is in the scene */
812f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        float getHere(View view);
822f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
832f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        /** Returns the property to animate translation */
842f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        Property<View, Float> getProperty();
852f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    }
862f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
872f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    private static abstract class CalculateSlideHorizontal implements CalculateSlide {
882f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        @Override
892f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        public float getHere(View view) {
902f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            return view.getTranslationX();
912f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        }
922f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
932f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        @Override
942f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        public Property<View, Float> getProperty() {
952f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            return View.TRANSLATION_X;
962f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        }
972f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    }
982f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
992f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    private static abstract class CalculateSlideVertical implements CalculateSlide {
1002f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        @Override
1012f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        public float getHere(View view) {
1022f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            return view.getTranslationY();
1032f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        }
1042f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
1052f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        @Override
1062f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        public Property<View, Float> getProperty() {
1072f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            return View.TRANSLATION_Y;
1082f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        }
1092f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    }
1102f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
1112f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    private static final CalculateSlide sCalculateLeft = new CalculateSlideHorizontal() {
1122f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        @Override
1132f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        public float getGone(float distance, View view) {
1142f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            return view.getTranslationX() - distance;
1152f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        }
1162f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    };
1172f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
1182f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    private static final CalculateSlide sCalculateTop = new CalculateSlideVertical() {
1192f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        @Override
1202f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        public float getGone(float distance, View view) {
1212f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            return view.getTranslationY() - distance;
1222f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        }
1232f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    };
1242f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
1252f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    private static final CalculateSlide sCalculateRight = new CalculateSlideHorizontal() {
1262f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        @Override
1272f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        public float getGone(float distance, View view) {
1282f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            return view.getTranslationX() + distance;
1292f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        }
1302f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    };
1312f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
1322f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    private static final CalculateSlide sCalculateBottom = new CalculateSlideVertical() {
1332f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        @Override
1342f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        public float getGone(float distance, View view) {
1352f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            return view.getTranslationY() + distance;
1362f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        }
1372f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    };
1382f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
1392f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    public Slide() {
1402f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    }
1412f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
1422f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    public void setCallback(SlideCallback callback) {
1432f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        mCallback = callback;
1442f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    }
1452f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
1462f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    private CalculateSlide getSlideEdge(int slideEdge) {
1472f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        switch (slideEdge) {
1482f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            case LEFT:
1492f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu                return sCalculateLeft;
1502f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            case TOP:
1512f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu                return sCalculateTop;
1522f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            case RIGHT:
1532f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu                return sCalculateRight;
1542f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            case BOTTOM:
1552f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu                return sCalculateBottom;
1562f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            default:
1572f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu                throw new IllegalArgumentException("Invalid slide direction");
1582f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        }
1592f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    }
1602f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
1612f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    private Animator createAnimation(final View view, Property<View, Float> property,
16233f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            float start, float end, float terminalValue, TimeInterpolator interpolator,
16333f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            int finalVisibility) {
16433f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu        float[] startPosition = (float[]) view.getTag(R.id.lb_slide_transition_value);
16533f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu        if (startPosition != null) {
16633f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            start = View.TRANSLATION_Y == property ? startPosition[1] : startPosition[0];
16733f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            view.setTag(R.id.lb_slide_transition_value, null);
1682f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        }
1692f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        final ObjectAnimator anim = ObjectAnimator.ofFloat(view, property, start, end);
1702f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
17133f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu        SlideAnimatorListener listener = new SlideAnimatorListener(view, property, terminalValue, end,
17233f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu                finalVisibility);
1732f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        anim.addListener(listener);
1742f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        anim.addPauseListener(listener);
1752f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        anim.setInterpolator(interpolator);
1762f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        return anim;
1772f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    }
1782f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
1792f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    @Override
1802f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    public Animator onAppear(ViewGroup sceneRoot,
1812f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            TransitionValues startValues, int startVisibility,
1822f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            TransitionValues endValues, int endVisibility) {
1832f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        View view = (endValues != null) ? endValues.view : null;
1842f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        if (view == null) {
1852f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            return null;
1862f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        }
1872f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        if (mCallback == null || !mCallback.getSlide(view, true, mTempEdge, mTempDistance)) {
1882f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            return null;
1892f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        }
1902f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        final CalculateSlide slideCalculator = getSlideEdge(mTempEdge[0]);
1912f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        float end = slideCalculator.getHere(view);
1922f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        float start = slideCalculator.getGone(mTempDistance[0], view);
19333f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu        return createAnimation(view, slideCalculator.getProperty(), start, end, end, sDecelerate,
19433f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu                View.VISIBLE);
1952f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    }
1962f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
1972f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    @Override
1982f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    public Animator onDisappear(ViewGroup sceneRoot,
1992f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            TransitionValues startValues, int startVisibility,
2002f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            TransitionValues endValues, int endVisibility) {
2012f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        View view = (startValues != null) ? startValues.view : null;
2022f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        if (view == null) {
2032f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            return null;
2042f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        }
2052f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        if (mCallback == null || !mCallback.getSlide(view, false, mTempEdge, mTempDistance)) {
2062f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            return null;
2072f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        }
2082f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        final CalculateSlide slideCalculator = getSlideEdge(mTempEdge[0]);
2092f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        float start = slideCalculator.getHere(view);
2102f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        float end = slideCalculator.getGone(mTempDistance[0], view);
2112f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
2122f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        return createAnimation(view, slideCalculator.getProperty(), start, end, start,
21333f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu                sAccelerate, View.INVISIBLE);
2142f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    }
2152f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
2162f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    private static class SlideAnimatorListener extends AnimatorListenerAdapter {
2172f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        private boolean mCanceled = false;
21833f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu        private float mPausedValue;
2192f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        private final View mView;
22033f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu        private final float mEndValue;
22133f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu        private final float mTerminalValue;
22233f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu        private final int mFinalVisibility;
22333f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu        private final Property<View, Float> mProp;
22433f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu
22533f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu        public SlideAnimatorListener(View view, Property<View, Float> prop,
22633f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu                float terminalValue, float endValue, int finalVisibility) {
22733f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            mProp = prop;
2282f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            mView = view;
22933f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            mTerminalValue = terminalValue;
23033f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            mEndValue = endValue;
23133f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            mFinalVisibility = finalVisibility;
23233f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            view.setVisibility(View.VISIBLE);
2332f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        }
2342f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
2352f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        @Override
2362f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        public void onAnimationCancel(Animator animator) {
23733f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            float[] transitionPosition = new float[2];
23833f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            transitionPosition[0] = mView.getTranslationX();
23933f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            transitionPosition[1] = mView.getTranslationY();
24033f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            mView.setTag(R.id.lb_slide_transition_value, transitionPosition);
24133f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            mProp.set(mView, mTerminalValue);
2422f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            mCanceled = true;
2432f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        }
2442f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
2452f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        @Override
2462f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        public void onAnimationEnd(Animator animator) {
2472f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            if (!mCanceled) {
24833f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu                mProp.set(mView, mTerminalValue);
2492f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu            }
25033f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            mView.setVisibility(mFinalVisibility);
2512f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        }
2522f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
2532f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        @Override
2542f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        public void onAnimationPause(Animator animator) {
25533f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            mPausedValue = mProp.get(mView);
25633f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            mProp.set(mView, mEndValue);
25733f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            mView.setVisibility(mFinalVisibility);
2582f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        }
2592f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu
2602f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        @Override
2612f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        public void onAnimationResume(Animator animator) {
26233f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            mProp.set(mView, mPausedValue);
26333f66eb67b6457ea75434dfd9f79703ad9e03560Dake Gu            mView.setVisibility(View.VISIBLE);
2642f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu        }
2652f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu    }
2662f97594742886d045ca1ce409ebc6e6e780452f6Dake Gu}