Search in sources :

Example 1 with ISurfaceAnimation

use of su.levenetc.android.textsurface.interfaces.ISurfaceAnimation in project TextSurface by elevenetc.

the class TextSurface method configAnimations.

private void configAnimations(ISurfaceAnimation animation) {
    if (animation instanceof ICameraAnimation) {
        ((ICameraAnimation) animation).setCamera(camera);
    } else if (animation instanceof ISet) {
        LinkedList<ISurfaceAnimation> animations = ((ISet) animation).getAnimations();
        for (ISurfaceAnimation a : animations) configAnimations(a);
    } else if (animation instanceof ITextSurfaceAnimation) {
        ITextSurfaceAnimation textAnimation = (ITextSurfaceAnimation) animation;
        Text text = textAnimation.getText();
        if (text != null && textsTree.add(text))
            textAnimation.setInitValues(text);
    }
}
Also used : ICameraAnimation(su.levenetc.android.textsurface.interfaces.ICameraAnimation) ISurfaceAnimation(su.levenetc.android.textsurface.interfaces.ISurfaceAnimation) ITextSurfaceAnimation(su.levenetc.android.textsurface.interfaces.ITextSurfaceAnimation) ISet(su.levenetc.android.textsurface.interfaces.ISet) LinkedList(java.util.LinkedList)

Example 2 with ISurfaceAnimation

use of su.levenetc.android.textsurface.interfaces.ISurfaceAnimation in project TextSurface by elevenetc.

the class Rotate3D method start.

@Override
public void start(@Nullable final IEndListener listener) {
    PropertyValuesHolder valHolder = null;
    int fromDegree;
    int toDegree;
    text.setAlpha(255);
    if (show) {
        fromDegree = 90;
        toDegree = 0;
    } else {
        fromDegree = 0;
        toDegree = -90;
    }
    if ((pivot & Pivot.BOTTOM) == Pivot.BOTTOM) {
        valHolder = PropertyValuesHolder.ofFloat("rotationX", fromDegree, toDegree);
        cameraTransXPre = -text.getWidth() / 2;
        cameraTransXPost = text.getWidth() / 2;
        cameraTransYPre = -text.getFontDescent();
        cameraTransYPost = 0;
    } else if ((pivot & Pivot.TOP) == Pivot.TOP) {
        valHolder = PropertyValuesHolder.ofFloat("rotationX", -fromDegree, toDegree);
        cameraTransXPre = -text.getWidth() / 2;
        cameraTransXPost = text.getWidth() / 2;
        cameraTransYPre = text.getHeight() - text.getFontDescent();
        cameraTransYPost = -text.getHeight();
    }
    if ((pivot & Pivot.LEFT) == Pivot.LEFT) {
        valHolder = PropertyValuesHolder.ofFloat("rotationY", fromDegree, toDegree);
        cameraTransXPre = 0;
        cameraTransXPost = 0;
        cameraTransYPre = text.getHeight() / 2 - text.getFontDescent();
        cameraTransYPost = text.getHeight() / 2 - text.getHeight();
    } else if ((pivot & Pivot.RIGHT) == Pivot.RIGHT) {
        valHolder = PropertyValuesHolder.ofFloat("rotationY", -fromDegree, toDegree);
        cameraTransXPre = -text.getWidth();
        cameraTransXPost = text.getWidth();
        cameraTransYPre = text.getHeight() / 2 - text.getFontDescent();
        cameraTransYPost = text.getHeight() / 2 - text.getHeight();
    }
    if ((pivot & Pivot.CENTER) == Pivot.CENTER) {
        valHolder = PropertyValuesHolder.ofFloat(axis == Axis.Y ? "rotationY" : "rotationX", fromDegree, toDegree);
        cameraTransXPre = -text.getWidth() / 2;
        cameraTransXPost = text.getWidth() / 2;
        cameraTransYPre = text.getHeight() / 2 - text.getFontDescent();
        cameraTransYPost = text.getHeight() / 2 - text.getHeight();
    }
    if (valHolder != null) {
        animator = ObjectAnimator.ofPropertyValuesHolder(this, valHolder);
        animator.setInterpolator(new FastOutSlowInInterpolator());
        Utils.addEndListener(this, animator, new IEndListener() {

            @Override
            public void onAnimationEnd(ISurfaceAnimation animation) {
                text.removeEffect(Rotate3D.this);
                if (!show)
                    text.setAlpha(0);
                if (listener != null)
                    listener.onAnimationEnd(Rotate3D.this);
            }
        });
        animator.setDuration(duration);
        animator.addUpdateListener(this);
        animator.start();
    } else {
        throw new RuntimeException(getClass().getSuperclass() + " was not configured properly. Pivot:" + pivot);
    }
}
Also used : ISurfaceAnimation(su.levenetc.android.textsurface.interfaces.ISurfaceAnimation) FastOutSlowInInterpolator(android.support.v4.view.animation.FastOutSlowInInterpolator) PropertyValuesHolder(android.animation.PropertyValuesHolder) IEndListener(su.levenetc.android.textsurface.interfaces.IEndListener) Paint(android.graphics.Paint)

Example 3 with ISurfaceAnimation

use of su.levenetc.android.textsurface.interfaces.ISurfaceAnimation in project TextSurface by elevenetc.

the class ShapeReveal method start.

@Override
public void start(@Nullable final IEndListener listener) {
    text.setAlpha(255);
    animator = revealShape.getAnimator();
    animator.setInterpolator(new FastOutSlowInInterpolator());
    Utils.addEndListener(this, animator, new IEndListener() {

        @Override
        public void onAnimationEnd(ISurfaceAnimation animation) {
            text.removeEffect(ShapeReveal.this);
            if (hideOnEnd)
                text.setAlpha(0);
            if (listener != null)
                listener.onAnimationEnd(ShapeReveal.this);
        }
    });
    animator.setDuration(duration);
    animator.start();
}
Also used : ISurfaceAnimation(su.levenetc.android.textsurface.interfaces.ISurfaceAnimation) FastOutSlowInInterpolator(android.support.v4.view.animation.FastOutSlowInInterpolator) IEndListener(su.levenetc.android.textsurface.interfaces.IEndListener)

Example 4 with ISurfaceAnimation

use of su.levenetc.android.textsurface.interfaces.ISurfaceAnimation in project TextSurface by elevenetc.

the class Slide method start.

@Override
public void start(@Nullable final IEndListener listener) {
    text.setAlpha(255);
    PropertyValuesHolder hHolder = null;
    PropertyValuesHolder vHolder = null;
    float fromX = 0;
    float toX = 0;
    float fromY = 0;
    float toY = 0;
    if ((side & Side.LEFT) == side) {
        if (toShow) {
            fromX = -text.getWidth();
        } else {
            toX = -text.getWidth();
        }
        hHolder = PropertyValuesHolder.ofFloat("xOffset", fromX, toX);
    } else if ((side & Side.RIGHT) == side) {
        if (toShow) {
            fromX = text.getWidth();
        } else {
            toX = text.getWidth();
        }
        hHolder = PropertyValuesHolder.ofFloat("xOffset", fromX, toX);
    }
    if ((side & Side.TOP) == side) {
        if (toShow) {
            fromY = -text.getHeight();
        } else {
            toY = -text.getHeight();
        }
        vHolder = PropertyValuesHolder.ofFloat("yOffset", fromY, toY);
    } else if ((side & Side.BOTTOM) == side) {
        if (toShow) {
            fromY = text.getHeight();
        } else {
            toY = text.getHeight();
        }
        vHolder = PropertyValuesHolder.ofFloat("yOffset", fromY, toY);
    }
    if (hHolder != null && vHolder != null) {
        animator = ObjectAnimator.ofPropertyValuesHolder(this, hHolder, vHolder);
    } else if (hHolder != null) {
        animator = ObjectAnimator.ofPropertyValuesHolder(this, hHolder);
    } else {
        animator = ObjectAnimator.ofPropertyValuesHolder(this, vHolder);
    }
    animator.setInterpolator(new FastOutSlowInInterpolator());
    Utils.addEndListener(this, animator, new IEndListener() {

        @Override
        public void onAnimationEnd(ISurfaceAnimation animation) {
            text.removeEffect(Slide.this);
            if (!toShow)
                text.setAlpha(0);
            if (listener != null)
                listener.onAnimationEnd(Slide.this);
        }
    });
    animator.setDuration(duration);
    animator.addUpdateListener(this);
    animator.start();
}
Also used : ISurfaceAnimation(su.levenetc.android.textsurface.interfaces.ISurfaceAnimation) FastOutSlowInInterpolator(android.support.v4.view.animation.FastOutSlowInInterpolator) PropertyValuesHolder(android.animation.PropertyValuesHolder) IEndListener(su.levenetc.android.textsurface.interfaces.IEndListener)

Aggregations

ISurfaceAnimation (su.levenetc.android.textsurface.interfaces.ISurfaceAnimation)4 FastOutSlowInInterpolator (android.support.v4.view.animation.FastOutSlowInInterpolator)3 IEndListener (su.levenetc.android.textsurface.interfaces.IEndListener)3 PropertyValuesHolder (android.animation.PropertyValuesHolder)2 Paint (android.graphics.Paint)1 LinkedList (java.util.LinkedList)1 ICameraAnimation (su.levenetc.android.textsurface.interfaces.ICameraAnimation)1 ISet (su.levenetc.android.textsurface.interfaces.ISet)1 ITextSurfaceAnimation (su.levenetc.android.textsurface.interfaces.ITextSurfaceAnimation)1