use of android.view.animation.Transformation in project Taurus by Yalantis.
the class RefreshView method setupAnimations.
private void setupAnimations() {
mAnimation = new Animation() {
@Override
public void applyTransformation(float interpolatedTime, @NonNull Transformation t) {
setLoadingAnimationTime(interpolatedTime);
}
};
mAnimation.setRepeatCount(Animation.INFINITE);
mAnimation.setRepeatMode(Animation.REVERSE);
mAnimation.setInterpolator(ACCELERATE_DECELERATE_INTERPOLATOR);
mAnimation.setDuration(ANIMATION_DURATION);
}
use of android.view.animation.Transformation in project remusic by aa112901.
the class SwipeRefreshLayout method startScaleUpAnimation.
private void startScaleUpAnimation(AnimationListener listener) {
mHeadViewContainer.setVisibility(View.VISIBLE);
mScaleAnimation = new Animation() {
@Override
public void applyTransformation(float interpolatedTime, Transformation t) {
setAnimationProgress(interpolatedTime);
}
};
mScaleAnimation.setDuration(mMediumAnimationDuration);
if (listener != null) {
mHeadViewContainer.setAnimationListener(listener);
}
mHeadViewContainer.clearAnimation();
mHeadViewContainer.startAnimation(mScaleAnimation);
}
use of android.view.animation.Transformation in project LuaViewSDK by alibaba.
the class SuperSwipeRefreshLayout method startScaleUpAnimation.
private void startScaleUpAnimation(AnimationListener listener) {
mScaleAnimation = new Animation() {
@Override
public void applyTransformation(float interpolatedTime, Transformation t) {
setAnimationProgress(interpolatedTime);
}
};
mScaleAnimation.setDuration(mMediumAnimationDuration);
if (listener != null) {
mHeadViewContainer.setAnimationListener(listener);
}
mHeadViewContainer.clearAnimation();
mHeadViewContainer.startAnimation(mScaleAnimation);
}
use of android.view.animation.Transformation in project okhttp-OkGo by jeasonlzy.
the class SimpleViewBehavior method updateViewWithPercent.
/** 更新View */
public void updateViewWithPercent(View child, float percent) {
if (mAnimation == null) {
//如果没有自定义动画,那么使用属性动画
float newX = targetX == UNSPECIFIED_INT ? 0 : (targetX - mStartX) * percent;
float newY = targetY == UNSPECIFIED_INT ? 0 : (targetY - mStartY) * percent;
//缩放动画
if (targetWidth != UNSPECIFIED_INT || targetHeight != UNSPECIFIED_INT) {
child.setScaleX(scaleEvaluator(mStartWidth, targetWidth, percent));
child.setScaleY(scaleEvaluator(mStartHeight, targetHeight, percent));
float newWidth = floatEvaluator(mStartWidth, targetWidth, percent);
float newHeight = floatEvaluator(mStartWidth, targetWidth, percent);
newX -= (mStartWidth - newWidth) / 2;
newY -= (mStartHeight - newHeight) / 2;
}
//平移动画
child.setTranslationX(newX);
child.setTranslationY(newY);
//透明度变化
if (targetAlpha != UNSPECIFIED_FLOAT)
child.setAlpha(floatEvaluator(mStartAlpha, targetAlpha, percent));
//背景渐变
if (targetBackgroundColor != UNSPECIFIED_INT && mStartBackgroundColor != 0) {
child.setBackgroundColor(argbEvaluator(mStartBackgroundColor, targetBackgroundColor, percent));
}
//旋转动画
if (targetRotateX != UNSPECIFIED_FLOAT)
child.setRotationX(floatEvaluator(mStartRotateX, targetRotateX, percent));
if (targetRotateY != UNSPECIFIED_FLOAT)
child.setRotationY(floatEvaluator(mStartRotateY, targetRotateY, percent));
} else {
mAnimation.setStartTime(0);
mAnimation.restrictDuration(100);
Transformation transformation = new Transformation();
mAnimation.getTransformation((long) (percent * 100), transformation);
BehaviorAnimation animation = new BehaviorAnimation(transformation);
child.startAnimation(animation);
}
child.requestLayout();
}
use of android.view.animation.Transformation in project WaveSwipeRefreshLayout by recruit-lifestyle.
the class MaterialProgressDrawable method setupAnimators.
private void setupAnimators() {
final Ring ring = mRing;
final Animation animation = new Animation() {
@Override
public void applyTransformation(float interpolatedTime, Transformation t) {
if (mFinishing) {
applyFinishTranslation(interpolatedTime, ring);
} else {
// The minProgressArc is calculated from 0 to create an
// angle that
// matches the stroke width.
final float minProgressArc = (float) Math.toRadians(ring.getStrokeWidth() / (2 * Math.PI * ring.getCenterRadius()));
final float startingEndTrim = ring.getStartingEndTrim();
final float startingTrim = ring.getStartingStartTrim();
final float startingRotation = ring.getStartingRotation();
// Offset the minProgressArc to where the endTrim is
// located.
final float minArc = MAX_PROGRESS_ARC - minProgressArc;
final float endTrim = startingEndTrim + (minArc * START_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime));
ring.setEndTrim(endTrim);
final float startTrim = startingTrim + (MAX_PROGRESS_ARC * END_CURVE_INTERPOLATOR.getInterpolation(interpolatedTime));
ring.setStartTrim(startTrim);
final float rotation = startingRotation + (0.25f * interpolatedTime);
ring.setRotation(rotation);
float groupRotation = ((720.0f / NUM_POINTS) * interpolatedTime) + (720.0f * (mRotationCount / NUM_POINTS));
setRotation(groupRotation);
}
}
};
animation.setRepeatCount(Animation.INFINITE);
animation.setRepeatMode(Animation.RESTART);
animation.setInterpolator(LINEAR_INTERPOLATOR);
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
mRotationCount = 0;
}
@Override
public void onAnimationEnd(Animation animation) {
// do nothing
}
@Override
public void onAnimationRepeat(Animation animation) {
ring.storeOriginals();
ring.goToNextColor();
ring.setStartTrim(ring.getEndTrim());
if (mFinishing) {
// finished closing the last ring from the swipe gesture; go
// into progress mode
mFinishing = false;
animation.setDuration(ANIMATION_DURATION);
ring.setShowArrow(false);
} else {
mRotationCount = (mRotationCount + 1) % (NUM_POINTS);
}
}
});
mAnimation = animation;
}
Aggregations