@Override public void start(@Nullable IEndListener listener) { text.setScalePivot(pivot, pivot); PropertyValuesHolder sX = PropertyValuesHolder.ofFloat("scaleX", from, to); PropertyValuesHolder sY = PropertyValuesHolder.ofFloat("scaleY", from, to); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(text, sX, sY); Utils.addEndListener(this, animator, listener); animator.setDuration(duration); animator.addUpdateListener(this); animator.start(); }
@Override public void onStart() { text.addEffect(this); }
@Override public void setInitValues(@NonNull Text text) { if (show) { text.setAlpha(0); } }
@Override public void start(@Nullable final IEndListener listener) { PropertyValuesHolder valHolder = null; ObjectAnimator animator; 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); } }