Search in sources :

Example 1 with FloatArrayEvaluator

use of android.animation.FloatArrayEvaluator in project android_frameworks_base by ResurrectionRemix.

the class ChangeTransform method createTransformAnimator.

private ObjectAnimator createTransformAnimator(TransitionValues startValues, TransitionValues endValues, final boolean handleParentChange) {
    Matrix startMatrix = (Matrix) startValues.values.get(PROPNAME_MATRIX);
    Matrix endMatrix = (Matrix) endValues.values.get(PROPNAME_MATRIX);
    if (startMatrix == null) {
        startMatrix = Matrix.IDENTITY_MATRIX;
    }
    if (endMatrix == null) {
        endMatrix = Matrix.IDENTITY_MATRIX;
    }
    if (startMatrix.equals(endMatrix)) {
        return null;
    }
    final Transforms transforms = (Transforms) endValues.values.get(PROPNAME_TRANSFORMS);
    // clear the transform properties so that we can use the animation matrix instead
    final View view = endValues.view;
    setIdentityTransforms(view);
    final float[] startMatrixValues = new float[9];
    startMatrix.getValues(startMatrixValues);
    final float[] endMatrixValues = new float[9];
    endMatrix.getValues(endMatrixValues);
    final PathAnimatorMatrix pathAnimatorMatrix = new PathAnimatorMatrix(view, startMatrixValues);
    PropertyValuesHolder valuesProperty = PropertyValuesHolder.ofObject(NON_TRANSLATIONS_PROPERTY, new FloatArrayEvaluator(new float[9]), startMatrixValues, endMatrixValues);
    Path path = getPathMotion().getPath(startMatrixValues[Matrix.MTRANS_X], startMatrixValues[Matrix.MTRANS_Y], endMatrixValues[Matrix.MTRANS_X], endMatrixValues[Matrix.MTRANS_Y]);
    PropertyValuesHolder translationProperty = PropertyValuesHolder.ofObject(TRANSLATIONS_PROPERTY, null, path);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(pathAnimatorMatrix, valuesProperty, translationProperty);
    final Matrix finalEndMatrix = endMatrix;
    AnimatorListenerAdapter listener = new AnimatorListenerAdapter() {

        private boolean mIsCanceled;

        private Matrix mTempMatrix = new Matrix();

        @Override
        public void onAnimationCancel(Animator animation) {
            mIsCanceled = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!mIsCanceled) {
                if (handleParentChange && mUseOverlay) {
                    setCurrentMatrix(finalEndMatrix);
                } else {
                    view.setTagInternal(R.id.transitionTransform, null);
                    view.setTagInternal(R.id.parentMatrix, null);
                }
            }
            view.setAnimationMatrix(null);
            transforms.restore(view);
        }

        @Override
        public void onAnimationPause(Animator animation) {
            Matrix currentMatrix = pathAnimatorMatrix.getMatrix();
            setCurrentMatrix(currentMatrix);
        }

        @Override
        public void onAnimationResume(Animator animation) {
            setIdentityTransforms(view);
        }

        private void setCurrentMatrix(Matrix currentMatrix) {
            mTempMatrix.set(currentMatrix);
            view.setTagInternal(R.id.transitionTransform, mTempMatrix);
            transforms.restore(view);
        }
    };
    animator.addListener(listener);
    animator.addPauseListener(listener);
    return animator;
}
Also used : Path(android.graphics.Path) FloatArrayEvaluator(android.animation.FloatArrayEvaluator) Matrix(android.graphics.Matrix) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) PropertyValuesHolder(android.animation.PropertyValuesHolder) GhostView(android.view.GhostView) View(android.view.View)

Example 2 with FloatArrayEvaluator

use of android.animation.FloatArrayEvaluator in project android_frameworks_base by crdroidandroid.

the class ChangeTransform method createTransformAnimator.

private ObjectAnimator createTransformAnimator(TransitionValues startValues, TransitionValues endValues, final boolean handleParentChange) {
    Matrix startMatrix = (Matrix) startValues.values.get(PROPNAME_MATRIX);
    Matrix endMatrix = (Matrix) endValues.values.get(PROPNAME_MATRIX);
    if (startMatrix == null) {
        startMatrix = Matrix.IDENTITY_MATRIX;
    }
    if (endMatrix == null) {
        endMatrix = Matrix.IDENTITY_MATRIX;
    }
    if (startMatrix.equals(endMatrix)) {
        return null;
    }
    final Transforms transforms = (Transforms) endValues.values.get(PROPNAME_TRANSFORMS);
    // clear the transform properties so that we can use the animation matrix instead
    final View view = endValues.view;
    setIdentityTransforms(view);
    final float[] startMatrixValues = new float[9];
    startMatrix.getValues(startMatrixValues);
    final float[] endMatrixValues = new float[9];
    endMatrix.getValues(endMatrixValues);
    final PathAnimatorMatrix pathAnimatorMatrix = new PathAnimatorMatrix(view, startMatrixValues);
    PropertyValuesHolder valuesProperty = PropertyValuesHolder.ofObject(NON_TRANSLATIONS_PROPERTY, new FloatArrayEvaluator(new float[9]), startMatrixValues, endMatrixValues);
    Path path = getPathMotion().getPath(startMatrixValues[Matrix.MTRANS_X], startMatrixValues[Matrix.MTRANS_Y], endMatrixValues[Matrix.MTRANS_X], endMatrixValues[Matrix.MTRANS_Y]);
    PropertyValuesHolder translationProperty = PropertyValuesHolder.ofObject(TRANSLATIONS_PROPERTY, null, path);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(pathAnimatorMatrix, valuesProperty, translationProperty);
    final Matrix finalEndMatrix = endMatrix;
    AnimatorListenerAdapter listener = new AnimatorListenerAdapter() {

        private boolean mIsCanceled;

        private Matrix mTempMatrix = new Matrix();

        @Override
        public void onAnimationCancel(Animator animation) {
            mIsCanceled = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!mIsCanceled) {
                if (handleParentChange && mUseOverlay) {
                    setCurrentMatrix(finalEndMatrix);
                } else {
                    view.setTagInternal(R.id.transitionTransform, null);
                    view.setTagInternal(R.id.parentMatrix, null);
                }
            }
            view.setAnimationMatrix(null);
            transforms.restore(view);
        }

        @Override
        public void onAnimationPause(Animator animation) {
            Matrix currentMatrix = pathAnimatorMatrix.getMatrix();
            setCurrentMatrix(currentMatrix);
        }

        @Override
        public void onAnimationResume(Animator animation) {
            setIdentityTransforms(view);
        }

        private void setCurrentMatrix(Matrix currentMatrix) {
            mTempMatrix.set(currentMatrix);
            view.setTagInternal(R.id.transitionTransform, mTempMatrix);
            transforms.restore(view);
        }
    };
    animator.addListener(listener);
    animator.addPauseListener(listener);
    return animator;
}
Also used : Path(android.graphics.Path) FloatArrayEvaluator(android.animation.FloatArrayEvaluator) Matrix(android.graphics.Matrix) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) PropertyValuesHolder(android.animation.PropertyValuesHolder) GhostView(android.view.GhostView) View(android.view.View)

Example 3 with FloatArrayEvaluator

use of android.animation.FloatArrayEvaluator in project android_frameworks_base by DirtyUnicorns.

the class ChangeTransform method createTransformAnimator.

private ObjectAnimator createTransformAnimator(TransitionValues startValues, TransitionValues endValues, final boolean handleParentChange) {
    Matrix startMatrix = (Matrix) startValues.values.get(PROPNAME_MATRIX);
    Matrix endMatrix = (Matrix) endValues.values.get(PROPNAME_MATRIX);
    if (startMatrix == null) {
        startMatrix = Matrix.IDENTITY_MATRIX;
    }
    if (endMatrix == null) {
        endMatrix = Matrix.IDENTITY_MATRIX;
    }
    if (startMatrix.equals(endMatrix)) {
        return null;
    }
    final Transforms transforms = (Transforms) endValues.values.get(PROPNAME_TRANSFORMS);
    // clear the transform properties so that we can use the animation matrix instead
    final View view = endValues.view;
    setIdentityTransforms(view);
    final float[] startMatrixValues = new float[9];
    startMatrix.getValues(startMatrixValues);
    final float[] endMatrixValues = new float[9];
    endMatrix.getValues(endMatrixValues);
    final PathAnimatorMatrix pathAnimatorMatrix = new PathAnimatorMatrix(view, startMatrixValues);
    PropertyValuesHolder valuesProperty = PropertyValuesHolder.ofObject(NON_TRANSLATIONS_PROPERTY, new FloatArrayEvaluator(new float[9]), startMatrixValues, endMatrixValues);
    Path path = getPathMotion().getPath(startMatrixValues[Matrix.MTRANS_X], startMatrixValues[Matrix.MTRANS_Y], endMatrixValues[Matrix.MTRANS_X], endMatrixValues[Matrix.MTRANS_Y]);
    PropertyValuesHolder translationProperty = PropertyValuesHolder.ofObject(TRANSLATIONS_PROPERTY, null, path);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(pathAnimatorMatrix, valuesProperty, translationProperty);
    final Matrix finalEndMatrix = endMatrix;
    AnimatorListenerAdapter listener = new AnimatorListenerAdapter() {

        private boolean mIsCanceled;

        private Matrix mTempMatrix = new Matrix();

        @Override
        public void onAnimationCancel(Animator animation) {
            mIsCanceled = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!mIsCanceled) {
                if (handleParentChange && mUseOverlay) {
                    setCurrentMatrix(finalEndMatrix);
                } else {
                    view.setTagInternal(R.id.transitionTransform, null);
                    view.setTagInternal(R.id.parentMatrix, null);
                }
            }
            view.setAnimationMatrix(null);
            transforms.restore(view);
        }

        @Override
        public void onAnimationPause(Animator animation) {
            Matrix currentMatrix = pathAnimatorMatrix.getMatrix();
            setCurrentMatrix(currentMatrix);
        }

        @Override
        public void onAnimationResume(Animator animation) {
            setIdentityTransforms(view);
        }

        private void setCurrentMatrix(Matrix currentMatrix) {
            mTempMatrix.set(currentMatrix);
            view.setTagInternal(R.id.transitionTransform, mTempMatrix);
            transforms.restore(view);
        }
    };
    animator.addListener(listener);
    animator.addPauseListener(listener);
    return animator;
}
Also used : Path(android.graphics.Path) FloatArrayEvaluator(android.animation.FloatArrayEvaluator) Matrix(android.graphics.Matrix) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) PropertyValuesHolder(android.animation.PropertyValuesHolder) GhostView(android.view.GhostView) View(android.view.View)

Example 4 with FloatArrayEvaluator

use of android.animation.FloatArrayEvaluator in project platform_frameworks_base by android.

the class ChangeTransform method createTransformAnimator.

private ObjectAnimator createTransformAnimator(TransitionValues startValues, TransitionValues endValues, final boolean handleParentChange) {
    Matrix startMatrix = (Matrix) startValues.values.get(PROPNAME_MATRIX);
    Matrix endMatrix = (Matrix) endValues.values.get(PROPNAME_MATRIX);
    if (startMatrix == null) {
        startMatrix = Matrix.IDENTITY_MATRIX;
    }
    if (endMatrix == null) {
        endMatrix = Matrix.IDENTITY_MATRIX;
    }
    if (startMatrix.equals(endMatrix)) {
        return null;
    }
    final Transforms transforms = (Transforms) endValues.values.get(PROPNAME_TRANSFORMS);
    // clear the transform properties so that we can use the animation matrix instead
    final View view = endValues.view;
    setIdentityTransforms(view);
    final float[] startMatrixValues = new float[9];
    startMatrix.getValues(startMatrixValues);
    final float[] endMatrixValues = new float[9];
    endMatrix.getValues(endMatrixValues);
    final PathAnimatorMatrix pathAnimatorMatrix = new PathAnimatorMatrix(view, startMatrixValues);
    PropertyValuesHolder valuesProperty = PropertyValuesHolder.ofObject(NON_TRANSLATIONS_PROPERTY, new FloatArrayEvaluator(new float[9]), startMatrixValues, endMatrixValues);
    Path path = getPathMotion().getPath(startMatrixValues[Matrix.MTRANS_X], startMatrixValues[Matrix.MTRANS_Y], endMatrixValues[Matrix.MTRANS_X], endMatrixValues[Matrix.MTRANS_Y]);
    PropertyValuesHolder translationProperty = PropertyValuesHolder.ofObject(TRANSLATIONS_PROPERTY, null, path);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(pathAnimatorMatrix, valuesProperty, translationProperty);
    final Matrix finalEndMatrix = endMatrix;
    AnimatorListenerAdapter listener = new AnimatorListenerAdapter() {

        private boolean mIsCanceled;

        private Matrix mTempMatrix = new Matrix();

        @Override
        public void onAnimationCancel(Animator animation) {
            mIsCanceled = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!mIsCanceled) {
                if (handleParentChange && mUseOverlay) {
                    setCurrentMatrix(finalEndMatrix);
                } else {
                    view.setTagInternal(R.id.transitionTransform, null);
                    view.setTagInternal(R.id.parentMatrix, null);
                }
            }
            view.setAnimationMatrix(null);
            transforms.restore(view);
        }

        @Override
        public void onAnimationPause(Animator animation) {
            Matrix currentMatrix = pathAnimatorMatrix.getMatrix();
            setCurrentMatrix(currentMatrix);
        }

        @Override
        public void onAnimationResume(Animator animation) {
            setIdentityTransforms(view);
        }

        private void setCurrentMatrix(Matrix currentMatrix) {
            mTempMatrix.set(currentMatrix);
            view.setTagInternal(R.id.transitionTransform, mTempMatrix);
            transforms.restore(view);
        }
    };
    animator.addListener(listener);
    animator.addPauseListener(listener);
    return animator;
}
Also used : Path(android.graphics.Path) FloatArrayEvaluator(android.animation.FloatArrayEvaluator) Matrix(android.graphics.Matrix) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) PropertyValuesHolder(android.animation.PropertyValuesHolder) GhostView(android.view.GhostView) View(android.view.View)

Example 5 with FloatArrayEvaluator

use of android.animation.FloatArrayEvaluator in project android_frameworks_base by AOSPA.

the class ChangeTransform method createTransformAnimator.

private ObjectAnimator createTransformAnimator(TransitionValues startValues, TransitionValues endValues, final boolean handleParentChange) {
    Matrix startMatrix = (Matrix) startValues.values.get(PROPNAME_MATRIX);
    Matrix endMatrix = (Matrix) endValues.values.get(PROPNAME_MATRIX);
    if (startMatrix == null) {
        startMatrix = Matrix.IDENTITY_MATRIX;
    }
    if (endMatrix == null) {
        endMatrix = Matrix.IDENTITY_MATRIX;
    }
    if (startMatrix.equals(endMatrix)) {
        return null;
    }
    final Transforms transforms = (Transforms) endValues.values.get(PROPNAME_TRANSFORMS);
    // clear the transform properties so that we can use the animation matrix instead
    final View view = endValues.view;
    setIdentityTransforms(view);
    final float[] startMatrixValues = new float[9];
    startMatrix.getValues(startMatrixValues);
    final float[] endMatrixValues = new float[9];
    endMatrix.getValues(endMatrixValues);
    final PathAnimatorMatrix pathAnimatorMatrix = new PathAnimatorMatrix(view, startMatrixValues);
    PropertyValuesHolder valuesProperty = PropertyValuesHolder.ofObject(NON_TRANSLATIONS_PROPERTY, new FloatArrayEvaluator(new float[9]), startMatrixValues, endMatrixValues);
    Path path = getPathMotion().getPath(startMatrixValues[Matrix.MTRANS_X], startMatrixValues[Matrix.MTRANS_Y], endMatrixValues[Matrix.MTRANS_X], endMatrixValues[Matrix.MTRANS_Y]);
    PropertyValuesHolder translationProperty = PropertyValuesHolder.ofObject(TRANSLATIONS_PROPERTY, null, path);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(pathAnimatorMatrix, valuesProperty, translationProperty);
    final Matrix finalEndMatrix = endMatrix;
    AnimatorListenerAdapter listener = new AnimatorListenerAdapter() {

        private boolean mIsCanceled;

        private Matrix mTempMatrix = new Matrix();

        @Override
        public void onAnimationCancel(Animator animation) {
            mIsCanceled = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!mIsCanceled) {
                if (handleParentChange && mUseOverlay) {
                    setCurrentMatrix(finalEndMatrix);
                } else {
                    view.setTagInternal(R.id.transitionTransform, null);
                    view.setTagInternal(R.id.parentMatrix, null);
                }
            }
            view.setAnimationMatrix(null);
            transforms.restore(view);
        }

        @Override
        public void onAnimationPause(Animator animation) {
            Matrix currentMatrix = pathAnimatorMatrix.getMatrix();
            setCurrentMatrix(currentMatrix);
        }

        @Override
        public void onAnimationResume(Animator animation) {
            setIdentityTransforms(view);
        }

        private void setCurrentMatrix(Matrix currentMatrix) {
            mTempMatrix.set(currentMatrix);
            view.setTagInternal(R.id.transitionTransform, mTempMatrix);
            transforms.restore(view);
        }
    };
    animator.addListener(listener);
    animator.addPauseListener(listener);
    return animator;
}
Also used : Path(android.graphics.Path) FloatArrayEvaluator(android.animation.FloatArrayEvaluator) Matrix(android.graphics.Matrix) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) PropertyValuesHolder(android.animation.PropertyValuesHolder) GhostView(android.view.GhostView) View(android.view.View)

Aggregations

Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5 FloatArrayEvaluator (android.animation.FloatArrayEvaluator)5 ObjectAnimator (android.animation.ObjectAnimator)5 PropertyValuesHolder (android.animation.PropertyValuesHolder)5 Matrix (android.graphics.Matrix)5 Path (android.graphics.Path)5 GhostView (android.view.GhostView)5 View (android.view.View)5