Example usage for android.graphics Matrix equals

List of usage examples for android.graphics Matrix equals

Introduction

In this page you can find the example usage for android.graphics Matrix equals.

Prototype

@Override
public boolean equals(Object obj) 

Source Link

Document

Returns true iff obj is a Matrix and its values equal our values.

Usage

From source file:android.support.transition.ChangeTransform.java

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 = MatrixUtils.IDENTITY_MATRIX;
    }/* w ww  .  j a v a2s . c o m*/

    if (endMatrix == null) {
        endMatrix = MatrixUtils.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 = PropertyValuesHolderUtils.ofPointF(TRANSLATIONS_PROPERTY, 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.setTag(R.id.transition_transform, null);
                    view.setTag(R.id.parent_matrix, null);
                }
            }
            ViewUtils.setAnimationMatrix(view, 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.setTag(R.id.transition_transform, mTempMatrix);
            transforms.restore(view);
        }
    };

    animator.addListener(listener);
    AnimatorUtils.addPauseListener(animator, listener);
    return animator;
}

From source file:com.goka.flickableview.ImageViewTouchBase.java

@Override
public void setImageMatrix(Matrix matrix) {
    Matrix current = getImageMatrix();
    boolean needUpdate = false;

    if (matrix == null && !current.isIdentity() || matrix != null && !current.equals(matrix)) {
        needUpdate = true;//from   w  w w .  j a v  a 2s.  co  m
    }

    super.setImageMatrix(matrix);
    if (needUpdate) {
        onImageMatrixChanged();
    }
}