Java Code Examples for android.graphics.Matrix#equals()

The following examples show how to use android.graphics.Matrix#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageViewTouchBase.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
@Override
public void setImageMatrix( Matrix matrix ) {

	Matrix current = getImageMatrix();
	boolean needUpdate = false;
	
	if ( matrix == null && !current.isIdentity() || matrix != null && !current.equals( matrix ) ) {
		needUpdate = true;
	}
	
	super.setImageMatrix( matrix );
	
	if ( needUpdate ) onImageMatrixChanged();
}
 
Example 2
Source File: ImageViewTouchBase.java    From FlickableView with Apache License 2.0 5 votes vote down vote up
@Override
public void setImageMatrix(Matrix matrix) {
    Matrix current = getImageMatrix();
    boolean needUpdate = false;

    if (matrix == null && !current.isIdentity() || matrix != null && !current.equals(matrix)) {
        needUpdate = true;
    }

    super.setImageMatrix(matrix);
    if (needUpdate) {
        onImageMatrixChanged();
    }
}
 
Example 3
Source File: ImageViewTouchBase.java    From Klyph with MIT License 5 votes vote down vote up
@Override
public void setImageMatrix( Matrix matrix ) {

	Matrix current = getImageMatrix();
	boolean needUpdate = false;
	
	if ( matrix == null && !current.isIdentity() || matrix != null && !current.equals( matrix ) ) {
		needUpdate = true;
	}
	
	super.setImageMatrix( matrix );
	
	if ( needUpdate ) onImageMatrixChanged();
}
 
Example 4
Source File: ChangeImageTransform.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * Creates an Animator for ImageViews moving, changing dimensions, and/or changing
 * {@link android.widget.ImageView.ScaleType}.
 *
 * @param sceneRoot   The root of the transition hierarchy.
 * @param startValues The values for a specific target in the start scene.
 * @param endValues   The values for the target in the end scene.
 * @return An Animator to move an ImageView or null if the View is not an ImageView,
 * the Drawable changed, the View is not VISIBLE, or there was no change.
 */
@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues,
        TransitionValues endValues) {
    if (startValues == null || endValues == null) {
        return null;
    }
    Rect startBounds = (Rect) startValues.values.get(PROPNAME_BOUNDS);
    Rect endBounds = (Rect) endValues.values.get(PROPNAME_BOUNDS);
    if (startBounds == null || endBounds == null) {
        return null;
    }

    Matrix startMatrix = (Matrix) startValues.values.get(PROPNAME_MATRIX);
    Matrix endMatrix = (Matrix) endValues.values.get(PROPNAME_MATRIX);

    boolean matricesEqual = (startMatrix == null && endMatrix == null) ||
            (startMatrix != null && startMatrix.equals(endMatrix));

    if (startBounds.equals(endBounds) && matricesEqual) {
        return null;
    }

    ImageView imageView = (ImageView) endValues.view;
    Drawable drawable = imageView.getDrawable();
    int drawableWidth = drawable.getIntrinsicWidth();
    int drawableHeight = drawable.getIntrinsicHeight();

    ObjectAnimator animator;
    if (drawableWidth == 0 || drawableHeight == 0) {
        animator = createNullAnimator(imageView);
    } else {
        if (startMatrix == null) {
            startMatrix = Matrix.IDENTITY_MATRIX;
        }
        if (endMatrix == null) {
            endMatrix = Matrix.IDENTITY_MATRIX;
        }
        ANIMATED_TRANSFORM_PROPERTY.set(imageView, startMatrix);
        animator = createMatrixAnimator(imageView, startMatrix, endMatrix);
    }
    return animator;
}
 
Example 5
Source File: ChangeImageTransform.java    From Transitions-Everywhere with Apache License 2.0 4 votes vote down vote up
/**
 * Creates an Animator for ImageViews moving, changing dimensions, and/or changing
 * {@link android.widget.ImageView.ScaleType}.
 *
 * @param sceneRoot   The root of the transition hierarchy.
 * @param startValues The values for a specific target in the start scene.
 * @param endValues   The values for the target in the end scene.
 * @return An Animator to move an ImageView or null if the View is not an ImageView,
 * the Drawable changed, the View is not VISIBLE, or there was no change.
 */
@Nullable
@Override
public Animator createAnimator(@NonNull ViewGroup sceneRoot, @Nullable TransitionValues startValues,
                               @Nullable TransitionValues endValues) {
    if (startValues == null || endValues == null) {
        return null;
    }
    Rect startBounds = (Rect) startValues.values.get(PROPNAME_BOUNDS);
    Rect endBounds = (Rect) endValues.values.get(PROPNAME_BOUNDS);
    if (startBounds == null || endBounds == null) {
        return null;
    }

    Matrix startMatrix = (Matrix) startValues.values.get(PROPNAME_MATRIX);
    Matrix endMatrix = (Matrix) endValues.values.get(PROPNAME_MATRIX);

    boolean matricesEqual = (startMatrix == null && endMatrix == null) ||
            (startMatrix != null && startMatrix.equals(endMatrix));

    if (startBounds.equals(endBounds) && matricesEqual) {
        return null;
    }

    ImageView imageView = (ImageView) endValues.view;
    Drawable drawable = imageView.getDrawable();
    int drawableWidth = drawable.getIntrinsicWidth();
    int drawableHeight = drawable.getIntrinsicHeight();

    ObjectAnimator animator;
    if (drawableWidth == 0 || drawableHeight == 0) {
        animator = createMatrixAnimator(imageView, new MatrixUtils.NullMatrixEvaluator(),
                MatrixUtils.IDENTITY_MATRIX, MatrixUtils.IDENTITY_MATRIX);
    } else {
        if (startMatrix == null) {
            startMatrix = MatrixUtils.IDENTITY_MATRIX;
        }
        if (endMatrix == null) {
            endMatrix = MatrixUtils.IDENTITY_MATRIX;
        }
        MatrixUtils.animateTransform(imageView, startMatrix);
        animator = createMatrixAnimator(imageView, new MatrixUtils.MatrixEvaluator(),
                startMatrix, endMatrix);
    }
    return animator;
}