Java Code Examples for android.view.animation.Transformation#setAlpha()

The following examples show how to use android.view.animation.Transformation#setAlpha() . 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: PathAnimator.java    From MousePaint with MIT License 5 votes vote down vote up
@Override
protected void applyTransformation(float factor, Transformation transformation) {
    Matrix matrix = transformation.getMatrix();
    mPm.getMatrix(mDistance * factor, matrix, PathMeasure.POSITION_MATRIX_FLAG);
    mView.setRotation(mRotation * factor);
    float scale = 1F;
    if (3000.0F * factor < 200.0F) {
        scale = scale(factor, 0.0D, 0.06666667014360428D, 0.20000000298023224D, 1.100000023841858D);
    } else if (3000.0F * factor < 300.0F) {
        scale = scale(factor, 0.06666667014360428D, 0.10000000149011612D, 1.100000023841858D, 1.0D);
    }
    mView.setScaleX(scale);
    mView.setScaleY(scale);
    transformation.setAlpha(1.0F - factor);
}
 
Example 2
Source File: UEAnimatorProxy.java    From Auie with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    View view = mView.get();
    if (view != null) {
        t.setAlpha(mAlpha);
        transformMatrix(t.getMatrix(), view);
    }
}
 
Example 3
Source File: AnimatorProxy.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    View view = mView.get();
    if (view != null) {
        t.setAlpha(mAlpha);
        transformMatrix(t.getMatrix(), view);
    }
}
 
Example 4
Source File: AnimatorProxy.java    From android-apps with MIT License 5 votes vote down vote up
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    View view = mView.get();
    if (view != null) {
        t.setAlpha(mAlpha);
        transformMatrix(t.getMatrix(), view);
    }
}
 
Example 5
Source File: AnimatorProxy.java    From KJFrameForAndroid with Apache License 2.0 5 votes vote down vote up
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    View view = mView.get();
    if (view != null) {
        t.setAlpha(mAlpha);
        transformMatrix(t.getMatrix(), view);
    }
}
 
Example 6
Source File: AnimatorProxy.java    From Mover with Apache License 2.0 5 votes vote down vote up
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    View view = mView.get();
    if (view != null) {
        t.setAlpha(mAlpha);
        transformMatrix(t.getMatrix(), view);
    }
}
 
Example 7
Source File: AnimatorProxy.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
protected void applyTransformation(float f1, Transformation transformation)
{
    View view = (View)b.get();
    if (view != null)
    {
        transformation.setAlpha(e);
        a(transformation.getMatrix(), view);
    }
}
 
Example 8
Source File: Gallery.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean getChildStaticTransformation(View child, Transformation t) {
    
    t.clear();
    t.setAlpha(child == mSelectedChild ? 1.0f : mUnselectedAlpha);
    
    return true;
}
 
Example 9
Source File: PathAnimator.java    From KSYMediaPlayer_Android with Apache License 2.0 5 votes vote down vote up
@Override
protected void applyTransformation(float factor, Transformation transformation) {
    Matrix matrix = transformation.getMatrix();
    mPm.getMatrix(mDistance * factor, matrix, PathMeasure.POSITION_MATRIX_FLAG);
    mView.setRotation(mRotation * factor);
    float scale = 1F;
    if (3000.0F * factor < 200.0F) {
        scale = scale(factor, 0.0D, 0.06666667014360428D, 0.20000000298023224D, 1.100000023841858D);
    } else if (3000.0F * factor < 300.0F) {
        scale = scale(factor, 0.06666667014360428D, 0.10000000149011612D, 1.100000023841858D, 1.0D);
    }
    mView.setScaleX(scale);
    mView.setScaleY(scale);
    transformation.setAlpha(1.0F - factor);
}
 
Example 10
Source File: AnimatorProxy.java    From android-project-wo2b with Apache License 2.0 5 votes vote down vote up
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    View view = mView.get();
    if (view != null) {
        t.setAlpha(mAlpha);
        transformMatrix(t.getMatrix(), view);
    }
}
 
Example 11
Source File: AnimatorProxy.java    From CSipSimple with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    View view = mView.get();
    if (view != null) {
        t.setAlpha(mAlpha);
        transformMatrix(t.getMatrix(), view);
    }
}
 
Example 12
Source File: RxPathAnimator.java    From RxTools-master with Apache License 2.0 5 votes vote down vote up
@Override
protected void applyTransformation(float factor, Transformation transformation) {
    Matrix matrix = transformation.getMatrix();
    mPm.getMatrix(mDistance * factor, matrix, PathMeasure.POSITION_MATRIX_FLAG);
    mView.setRotation(mRotation * factor);
    float scale = 1F;
    if (3000.0F * factor < 200.0F) {
        scale = scale(factor, 0.0D, 0.06666667014360428D, 0.20000000298023224D, 1.100000023841858D);
    } else if (3000.0F * factor < 300.0F) {
        scale = scale(factor, 0.06666667014360428D, 0.10000000149011612D, 1.100000023841858D, 1.0D);
    }
    mView.setScaleX(scale);
    mView.setScaleY(scale);
    transformation.setAlpha(1.0F - factor);
}
 
Example 13
Source File: AnimatorProxy.java    From AndroidLinkup with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    View view = mView.get();
    if (view != null) {
        t.setAlpha(mAlpha);
        transformMatrix(t.getMatrix(), view);
    }
}
 
Example 14
Source File: AnimatorProxy.java    From zen4android with MIT License 5 votes vote down vote up
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    View view = mView.get();
    if (view != null) {
        t.setAlpha(mAlpha);
        transformMatrix(t.getMatrix(), view);
    }
}
 
Example 15
Source File: SlideLayout.java    From SlideLayout with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    t.setAlpha(alpha);
}
 
Example 16
Source File: ViewPropertyAnimation.java    From FragmentAnimations with Apache License 2.0 4 votes vote down vote up
protected void applyTransformation(Transformation t) {
    final Matrix m = t.getMatrix();
    final float w = mWidth;
    final float h = mHeight;
    final float pX = mPivotX;
    final float pY = mPivotY;

    final float rX = mRotationX;
    final float rY = mRotationY;
    final float rZ = mRotationZ;
    if ((rX != 0) || (rY != 0) || (rZ != 0)) {
        final Camera camera = mCamera;
        camera.save();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
            camera.setLocation(mCameraX, mCameraY, mCameraZ);
        }
        if (mTranslationZ != 0) {
            camera.translate(0, 0, mTranslationZ);
        }
        camera.rotateX(rX);
        camera.rotateY(rY);
        camera.rotateZ(-rZ);
        camera.getMatrix(m);
        camera.restore();
        m.preTranslate(-pX, -pY);
        m.postTranslate(pX, pY);
    }

    final float sX = mScaleX;
    final float sY = mScaleY;
    if ((sX != 1.0f) || (sY != 1.0f)) {
        m.postScale(sX, sY);
        final float sPX = -(pX / w) * ((sX * w) - w);
        final float sPY = -(pY / h) * ((sY * h) - h);
        m.postTranslate(sPX, sPY);
    }

    m.postTranslate(mTranslationX, mTranslationY);

    t.setAlpha(mAlpha);
}
 
Example 17
Source File: CardPromptAnim.java    From AndroidLinkup with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    t.setAlpha((float) Math.abs(Math.sin(interpolatedTime * 4 * Math.PI)));
    super.applyTransformation(interpolatedTime, t);
}
 
Example 18
Source File: HorizontalCarouselLayout.java    From CustomViewSets with Apache License 2.0 4 votes vote down vote up
protected boolean getChildStaticTransformation(View child, Transformation t) {
    Camera camera = new Camera();
    int leftCenterView = this.mWidthCenter - this.mChildrenWidthMiddle;
    float offset = (-child.getLeft() + leftCenterView) /
            this.mSpaceBetweenViews;
    if (offset != 0.0F) {
        float absOffset = Math.abs(offset);
        float scale = (float) Math.pow(0.8999999761581421D, absOffset);
        t.clear();
        t.setTransformationType(Transformation.TYPE_MATRIX);
        t.setAlpha(this.mSetInactiveViewTransparency);
        Matrix m = t.getMatrix();
        m.setScale(scale, scale);
        if (this.mTranslatateEnbabled) {
            m.setTranslate(0.0F, this.mTranslate * absOffset);
        }
        if (offset > 0.0F) {
            camera.save();
            camera.translate(0.0F, 0.0F, this.mViewZoomOutFactor * offset);
            camera.rotateY(this.mCoverflowRotation);
            camera.getMatrix(m);
            camera.restore();
            m.preTranslate(-this.mChildrenWidthMiddle, -this.mChildrenHeight);
            m.postTranslate(this.mChildrenWidthMiddle, this.mChildrenHeight);
        } else {
            camera.save();
            camera.translate(0.0F, 0.0F, -(this.mViewZoomOutFactor * offset));
            camera.rotateY(-this.mCoverflowRotation);
            camera.getMatrix(m);
            camera.restore();
            m.preTranslate(-this.mChildrenWidthMiddle, -this.mChildrenHeight);
            m.postTranslate(this.mChildrenWidthMiddle, this.mChildrenHeight);
        }
        this.mMatrix.reset();
        if (this.mRotationEnabled) {
            this.mMatrix.setRotate(this.mRotation * offset);
        }
        this.mMatrix.preTranslate(-this.mChildrenWidthMiddle, -this.mChildrenHeightMiddle);
        this.mMatrix.postTranslate(this.mChildrenWidthMiddle, this.mChildrenHeightMiddle);
        m.setConcat(m, this.mMatrix);
    }
    return true;
}
 
Example 19
Source File: FancyCoverFlow.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean getChildStaticTransformation(View child, Transformation t) {
    // We can cast here because FancyCoverFlowAdapter only creates wrappers.
    FancyCoverFlowItemWrapper item = (FancyCoverFlowItemWrapper) child;

    // Since Jelly Bean childs won't get invalidated automatically, needs to be added for the smooth coverflow animation
    if (android.os.Build.VERSION.SDK_INT >= 16) {
        item.invalidate();
    }

    final int coverFlowWidth = this.getWidth();
    final int coverFlowCenter = coverFlowWidth / 2;
    final int childWidth = item.getWidth();
    final int childHeight = item.getHeight();
    final int childCenter = item.getLeft() + childWidth / 2;

    // Use coverflow width when its defined as automatic.
    final int actionDistance = (this.actionDistance == ACTION_DISTANCE_AUTO) ? (int) ((coverFlowWidth + childWidth) / 2.0f) : this.actionDistance;

    // Calculate the abstract amount for all effects.
    final float effectsAmount = Math.min(1.0f, Math.max(-1.0f, (1.0f / actionDistance) * (childCenter - coverFlowCenter)));

    // Clear previous transformations and set transformation type (matrix + alpha).
    t.clear();
    t.setTransformationType(Transformation.TYPE_BOTH);

    // Alpha
    if (this.unselectedAlpha != 1) {
        final float alphaAmount = (this.unselectedAlpha - 1) * Math.abs(effectsAmount) + 1;
        t.setAlpha(alphaAmount);
    }

    // Saturation
    if (this.unselectedSaturation != 1) {
        // Pass over saturation to the wrapper.
        final float saturationAmount = (this.unselectedSaturation - 1) * Math.abs(effectsAmount) + 1;
        item.setSaturation(saturationAmount);
    }

    final Matrix imageMatrix = t.getMatrix();

    // Apply rotation.
    if (this.maxRotation != 0) {
        final int rotationAngle = (int) (-effectsAmount * this.maxRotation);
        this.transformationCamera.save();
        this.transformationCamera.rotateY(rotationAngle);
        this.transformationCamera.getMatrix(imageMatrix);
        this.transformationCamera.restore();
    }

    // Zoom.
    if (this.unselectedScale != 1) {
        final float zoomAmount = (this.unselectedScale - 1) * Math.abs(effectsAmount) + 1;
        // Calculate the scale anchor (y anchor can be altered)
        final float translateX = childWidth / 2.0f;
        final float translateY = childHeight * this.scaleDownGravity;
        imageMatrix.preTranslate(-translateX, -translateY);
        imageMatrix.postScale(zoomAmount, zoomAmount);
        imageMatrix.postTranslate(translateX, translateY);
    }

    return true;
}
 
Example 20
Source File: FancyCoverFlow.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean getChildStaticTransformation(View child, Transformation t) {
    // We can cast here because FancyCoverFlowAdapter only creates wrappers.
    FancyCoverFlowItemWrapper item = (FancyCoverFlowItemWrapper) child;

    // Since Jelly Bean childs won't get invalidated automatically, needs to be added for the smooth coverflow animation
    if (android.os.Build.VERSION.SDK_INT >= 16) {
        item.invalidate();
    }

    final int coverFlowWidth = this.getWidth();
    final int coverFlowCenter = coverFlowWidth / 2;
    final int childWidth = item.getWidth();
    final int childHeight = item.getHeight();
    final int childCenter = item.getLeft() + childWidth / 2;

    // Use coverflow width when its defined as automatic.
    final int actionDistance = (this.actionDistance == ACTION_DISTANCE_AUTO) ? (int) ((coverFlowWidth + childWidth) / 2.0f) : this.actionDistance;

    // Calculate the abstract amount for all effects.
    final float effectsAmount = Math.min(1.0f, Math.max(-1.0f, (1.0f / actionDistance) * (childCenter - coverFlowCenter)));

    // Clear previous transformations and set transformation type (matrix + alpha).
    t.clear();
    t.setTransformationType(Transformation.TYPE_BOTH);

    // Alpha
    if (this.unselectedAlpha != 1) {
        final float alphaAmount = (this.unselectedAlpha - 1) * Math.abs(effectsAmount) + 1;
        t.setAlpha(alphaAmount);
    }

    // Saturation
    if (this.unselectedSaturation != 1) {
        // Pass over saturation to the wrapper.
        final float saturationAmount = (this.unselectedSaturation - 1) * Math.abs(effectsAmount) + 1;
        item.setSaturation(saturationAmount);
    }

    final Matrix imageMatrix = t.getMatrix();

    // Apply rotation.
    if (this.maxRotation != 0) {
        final int rotationAngle = (int) (-effectsAmount * this.maxRotation);
        this.transformationCamera.save();
        this.transformationCamera.rotateY(rotationAngle);
        this.transformationCamera.getMatrix(imageMatrix);
        this.transformationCamera.restore();
    }

    // Zoom.
    if (this.unselectedScale != 1) {
        final float zoomAmount = (this.unselectedScale - 1) * Math.abs(effectsAmount) + 1;
        // Calculate the scale anchor (y anchor can be altered)
        final float translateX = childWidth / 2.0f;
        final float translateY = childHeight * this.scaleDownGravity;
        imageMatrix.preTranslate(-translateX, -translateY);
        imageMatrix.postScale(zoomAmount, zoomAmount);
        imageMatrix.postTranslate(translateX, translateY);
    }

    return true;
}