use of su.levenetc.android.textsurface.interfaces.IEndListener 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);
}
}
use of su.levenetc.android.textsurface.interfaces.IEndListener 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();
}
use of su.levenetc.android.textsurface.interfaces.IEndListener 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();
}
Aggregations