Here are the examples of the java api android.animation.ObjectAnimator.setDuration() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
796 Examples
19
Source : ZoomHoverView.java
with Apache License 2.0
from zyyoona7
with Apache License 2.0
from zyyoona7
/**
* 放大动画
*
* @param view
*/
private void zoomInAnim(final View view) {
// 将view放在其他view之上
view.bringToFront();
// 按照bringToFront文档来的,暂没测试
if (Build.VERSION.SDK_INT < KITKAT) {
requestLayout();
}
if (mCurrentZoomInAnim != null) {
// 如果当前有放大动画执行,cancel调
mCurrentZoomInAnim.cancel();
}
ObjectAnimator objectAnimatorX = ObjectAnimator.ofFloat(view, "scaleX", 1.0f, mAnimZoomTo);
ObjectAnimator objectAnimatorY = ObjectAnimator.ofFloat(view, "scaleY", 1.0f, mAnimZoomTo);
objectAnimatorX.setDuration(mAnimDuration);
objectAnimatorX.setInterpolator(mZoomInInterpolator);
objectAnimatorY.setDuration(mAnimDuration);
objectAnimatorY.setInterpolator(mZoomInInterpolator);
AnimatorSet set = new AnimatorSet();
set.playTogether(objectAnimatorX, objectAnimatorY);
set.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
// 放大动画开始
if (mOnZoomAnimatorListener != null) {
mOnZoomAnimatorListener.onZoomInStart(view);
}
}
@Override
public void onAnimationEnd(Animator animator) {
// 放大动画结束
if (mOnZoomAnimatorListener != null) {
mOnZoomAnimatorListener.onZoomInEnd(view);
}
mCurrentZoomInAnim = null;
}
@Override
public void onAnimationCancel(Animator animator) {
// 放大动画退出
mCurrentZoomInAnim = null;
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
set.start();
mCurrentZoomInAnim = set;
}
19
Source : ZoomHoverView.java
with Apache License 2.0
from zyyoona7
with Apache License 2.0
from zyyoona7
/**
* 缩小动画
*
* @param view
*/
private void zoomOutAnim(final View view) {
if (mCurrentZoomOutAnim != null) {
// 如果当前有缩小动画执行,cancel调
mCurrentZoomOutAnim.cancel();
// 动画cancel后,上一个缩小view的scaleX不是1.0,就手动设置scaleX,Y到1.0
if (mPreZoomOutView != null && mPreZoomOutView.getScaleX() > 1.0) {
mPreZoomOutView.setScaleX(1.0f);
mPreZoomOutView.setScaleY(1.0f);
}
}
ObjectAnimator objectAnimatorX = ObjectAnimator.ofFloat(view, "scaleX", mAnimZoomTo, 1.0f);
ObjectAnimator objectAnimatorY = ObjectAnimator.ofFloat(view, "scaleY", mAnimZoomTo, 1.0f);
objectAnimatorX.setDuration(mAnimDuration);
objectAnimatorX.setInterpolator(mZoomOutInterpolator);
objectAnimatorY.setDuration(mAnimDuration);
objectAnimatorY.setInterpolator(mZoomOutInterpolator);
AnimatorSet set = new AnimatorSet();
set.playTogether(objectAnimatorX, objectAnimatorY);
set.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
// 缩小动画开始
if (mOnZoomAnimatorListener != null) {
mOnZoomAnimatorListener.onZoomOutStart(view);
}
}
@Override
public void onAnimationEnd(Animator animator) {
// 缩小动画结束
if (mOnZoomAnimatorListener != null) {
mOnZoomAnimatorListener.onZoomOutEnd(view);
}
mCurrentZoomOutAnim = null;
}
@Override
public void onAnimationCancel(Animator animator) {
// 缩小动画退出
mCurrentZoomOutAnim = null;
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
set.start();
mCurrentZoomOutAnim = set;
// 把当前缩放的view作为上一个缩放的view
mPreZoomOutView = view;
}
19
Source : BaseAnimator.java
with MIT License
from zj565061763
with MIT License
from zj565061763
@Override
public T setDuration(long duration) {
mObjectAnimator.setDuration(duration);
return (T) this;
}
19
Source : MusicPlayerActivity.java
with Apache License 2.0
from zion223
with Apache License 2.0
from zion223
private void initAnimator() {
// 播放动作 动画
mNeddlePlayAnimator = ObjectAnimator.ofFloat(mNeddleiew, "rotation", -25, 0);
mNeddlePlayAnimator.setDuration(200);
mNeddlePlayAnimator.setRepeatMode(ValueAnimator.REVERSE);
mNeddlePlayAnimator.setRepeatCount(0);
mNeddlePlayAnimator.setInterpolator(new LinearInterpolator());
// 暂停播放动作 动画
mNeddlePauseAnimator = ObjectAnimator.ofFloat(mNeddleiew, "rotation", 0, -25);
mNeddlePauseAnimator.setDuration(200);
mNeddlePauseAnimator.setRepeatMode(ValueAnimator.REVERSE);
mNeddlePauseAnimator.setRepeatCount(0);
mNeddlePauseAnimator.setInterpolator(new LinearInterpolator());
}
19
Source : BottomMusicView.java
with Apache License 2.0
from zion223
with Apache License 2.0
from zion223
private void initView() {
View rootView = LayoutInflater.from(mContext).inflate(R.layout.bottom_view, this);
rootView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// 跳到音乐播放Activireplacedy
MusicPlayerActivity.start((Activity) mContext);
}
});
mLeftView = rootView.findViewById(R.id.album_view);
// 属性动画 旋转动画
mRotateAnimator = ObjectAnimator.ofFloat(mLeftView, View.ROTATION.getName(), 0f, 360f);
mRotateAnimator.setDuration(10000);
mRotateAnimator.setInterpolator(new LinearInterpolator());
// 循环模式
mRotateAnimator.setRepeatMode(ObjectAnimator.RESTART);
mRotateAnimator.setRepeatCount(ObjectAnimator.INFINITE);
mreplacedleView = rootView.findViewById(R.id.audio_name_view);
mAlbumView = rootView.findViewById(R.id.audio_album_view);
mPlayView = rootView.findViewById(R.id.play_view);
mPlayView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// 处理播放暂停事件
AudioController.getInstance().playOrPause();
}
});
mRightView = rootView.findViewById(R.id.show_list_view);
mRightView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// 显示音乐列表对话框
// MusicListDialog dialog = new MusicListDialog(mContext);
// dialog.show();
}
});
}
19
Source : SwitchButton.java
with MIT License
from zion223
with MIT License
from zion223
/**
* Description:开始开关按钮切换状态和背景颜色过渡的动画
*/
private void startAnimate() {
// 计算开关指示器的半径
float radius = (getMeasuredHeight() - mPaint.getStrokeWidth() * 4) / 2;
// 计算开关指示器的 X 坐标的总偏移量
float centerXOffset = getMeasuredWidth() - mPaint.getStrokeWidth() - mPaint.getStrokeWidth() - radius - (mPaint.getStrokeWidth() + mPaint.getStrokeWidth() + radius);
AnimatorSet animatorSet = new AnimatorSet();
// 偏移量逐渐变化到 0
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(this, "buttonCenterXOffset", centerXOffset, 0);
objectAnimator.setDuration(mAnimateDuration);
objectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
invalidate();
}
});
// 背景颜色过渡系数逐渐变化到 1
ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(this, "colorGradientFactor", 0, 1);
objectAnimator2.setDuration(mAnimateDuration);
// 同时开始修改开关指示器 X 坐标偏移量的动画和修改背景颜色过渡系数的动画
animatorSet.play(objectAnimator).with(objectAnimator2);
animatorSet.start();
}
19
Source : StarRatingBar.java
with MIT License
from zelin
with MIT License
from zelin
private void createAnimation(final int position) {
AnimatorSet mainAnimator = new AnimatorSet();
ArrayList<Animator> animations = new ArrayList<>();
for (int i = 0; i <= position; i++) {
final ImageView imgView = mImages.get(i);
ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(imgView, "scaleX", 0f, 1.04f);
ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(imgView, "scaleY", 0f, 1.04f);
ObjectAnimator alphaScale = ObjectAnimator.ofFloat(imgView, "alpha", 0f, 1f);
alphaScale.setDuration(5);
scaleDownX.setDuration(mAnimDuration);
scaleDownY.setDuration(mAnimDuration);
AnimatorSet scaleDown = new AnimatorSet();
scaleDown.setStartDelay(i * 50);
scaleDown.setInterpolator(new AccelerateInterpolator());
scaleDown.play(alphaScale).with(scaleDownX).with(scaleDownY);
scaleDown.start();
scaleDown.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(imgView, "scaleX", 1.04f, 1.0f);
ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(imgView, "scaleY", 1.04f, 1.0f);
scaleDownX.setDuration(90);
scaleDownY.setDuration(90);
AnimatorSet scaleDown = new AnimatorSet();
scaleDown.play(scaleDownX).with(scaleDownY);
scaleDown.start();
}
});
animations.add(scaleDown);
}
mainAnimator.playTogether(animations);
long mDuration = position * mAnimDuration;
mDuration = mDuration / 3;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
addSelectedTextBitmap(position);
}
}, mDuration);
}
19
Source : WebProgress.java
with Apache License 2.0
from youlookwhat
with Apache License 2.0
from youlookwhat
private void startAnim(boolean isFinished) {
float v = isFinished ? 100 : 95;
if (mAnimator != null && mAnimator.isStarted()) {
mAnimator.cancel();
}
mCurrentProgress = mCurrentProgress == 0 ? 0.00000001f : mCurrentProgress;
// 可能由于透明度造成突然出现的问题
setAlpha(1);
if (!isFinished) {
ValueAnimator mAnimator = ValueAnimator.ofFloat(mCurrentProgress, v);
float residue = 1f - mCurrentProgress / 100 - 0.05f;
mAnimator.setInterpolator(new LinearInterpolator());
mAnimator.setDuration((long) (residue * CURRENT_MAX_UNIFORM_SPEED_DURATION));
mAnimator.addUpdateListener(mAnimatorUpdateListener);
mAnimator.start();
this.mAnimator = mAnimator;
} else {
ValueAnimator segment95Animator = null;
if (mCurrentProgress < 95) {
segment95Animator = ValueAnimator.ofFloat(mCurrentProgress, 95);
float residue = 1f - mCurrentProgress / 100f - 0.05f;
segment95Animator.setInterpolator(new LinearInterpolator());
segment95Animator.setDuration((long) (residue * CURRENT_MAX_DECELERATE_SPEED_DURATION));
segment95Animator.setInterpolator(new DecelerateInterpolator());
segment95Animator.addUpdateListener(mAnimatorUpdateListener);
}
ObjectAnimator mObjectAnimator = ObjectAnimator.ofFloat(this, "alpha", 1f, 0f);
mObjectAnimator.setDuration(DO_END_ALPHA_DURATION);
ValueAnimator mValueAnimatorEnd = ValueAnimator.ofFloat(95f, 100f);
mValueAnimatorEnd.setDuration(DO_END_PROGRESS_DURATION);
mValueAnimatorEnd.addUpdateListener(mAnimatorUpdateListener);
AnimatorSet mAnimatorSet = new AnimatorSet();
mAnimatorSet.playTogether(mObjectAnimator, mValueAnimatorEnd);
if (segment95Animator != null) {
AnimatorSet mAnimatorSet1 = new AnimatorSet();
mAnimatorSet1.play(mAnimatorSet).after(segment95Animator);
mAnimatorSet = mAnimatorSet1;
}
mAnimatorSet.addListener(mAnimatorListenerAdapter);
mAnimatorSet.start();
mAnimator = mAnimatorSet;
}
TAG = STARTED;
}
19
Source : ReflowText.java
with Apache License 2.0
from yongjhih
with Apache License 2.0
from yongjhih
/**
* Create Animators to transition each run of text from start to end position and size.
*/
@NonNull
private List<Animator> createRunAnimators(View view, ReflowData startData, ReflowData endData, Bitmap startText, Bitmap endText, List<Run> runs) {
List<Animator> animators = new ArrayList<>(runs.size());
int dx = startData.bounds.left - endData.bounds.left;
int dy = startData.bounds.top - endData.bounds.top;
long startDelay = 0L;
// move text closest to the destination first i.e. loop forward or backward over the runs
boolean upward = startData.bounds.centerY() > endData.bounds.centerY();
boolean first = true;
boolean lastRightward = true;
LinearInterpolator linearInterpolator = new LinearInterpolator();
for (int i = upward ? 0 : runs.size() - 1; ((upward && i < runs.size()) || (!upward && i >= 0)); i += (upward ? 1 : -1)) {
Run run = runs.get(i);
// skip text runs which aren't visible in either state
if (!run.startVisible && !run.endVisible)
continue;
// create & position the drawable which displays the run; add it to the overlay.
SwitchDrawable drawable = new SwitchDrawable(startText, run.start, startData.textSize, endText, run.end, endData.textSize);
drawable.setBounds(run.start.left + dx, run.start.top + dy, run.start.right + dx, run.start.bottom + dy);
view.getOverlay().add(drawable);
PropertyValuesHolder topLeft = PropertyValuesHolder.ofObject(SwitchDrawable.TOP_LEFT, null, getPathMotion().getPath(run.start.left + dx, run.start.top + dy, run.end.left, run.end.top));
PropertyValuesHolder width = PropertyValuesHolder.ofInt(SwitchDrawable.WIDTH, run.start.width(), run.end.width());
PropertyValuesHolder height = PropertyValuesHolder.ofInt(SwitchDrawable.HEIGHT, run.start.height(), run.end.height());
// the progress property drives the switching behaviour
PropertyValuesHolder progress = PropertyValuesHolder.ofFloat(SwitchDrawable.PROGRESS, 0f, 1f);
Animator runAnim = ObjectAnimator.ofPropertyValuesHolder(drawable, topLeft, width, height, progress);
boolean rightward = run.start.centerX() + dx < run.end.centerX();
if ((run.startVisible && run.endVisible) && !first && rightward != lastRightward) {
// increase the start delay (by a decreasing amount) for the next run
// (if it's visible throughout) to stagger the movement and try to minimize overlaps
startDelay += staggerDelay;
staggerDelay *= STAGGER_DECAY;
}
lastRightward = rightward;
first = false;
runAnim.setStartDelay(startDelay);
long animDuration = Math.max(minDuration, duration - (startDelay / 2));
runAnim.setDuration(animDuration);
animators.add(runAnim);
if (run.startVisible != run.endVisible) {
// if run is appearing/disappearing then fade it in/out
ObjectAnimator fade = ObjectAnimator.ofInt(drawable, SwitchDrawable.ALPHA, run.startVisible ? OPAQUE : TRANSPARENT, run.endVisible ? OPAQUE : TRANSPARENT);
fade.setDuration((duration + startDelay) / 2);
if (!run.startVisible) {
drawable.setAlpha(TRANSPARENT);
fade.setStartDelay((duration + startDelay) / 2);
} else {
fade.setStartDelay(startDelay);
}
animators.add(fade);
} else {
// slightly fade during transition to minimize movement
ObjectAnimator fade = ObjectAnimator.ofInt(drawable, SwitchDrawable.ALPHA, OPAQUE, OPACITY_MID_TRANSITION, OPAQUE);
fade.setStartDelay(startDelay);
fade.setDuration(duration + startDelay);
fade.setInterpolator(linearInterpolator);
animators.add(fade);
}
}
return animators;
}
19
Source : VideoProgressLayout.java
with Apache License 2.0
from yellowcath
with Apache License 2.0
from yellowcath
// private void animate(final View view) {
// Animation alphaAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.video_progress_anim);
// view.startAnimation(alphaAnimation);
// }
private void animate(final View view) {
mAnimatorSet = new AnimatorSet();
ObjectAnimator alphaEnter = ObjectAnimator.ofFloat(view, "alpha", 0.0f, 1.0f);
alphaEnter.setDuration(300);
ObjectAnimator alphaOut = ObjectAnimator.ofFloat(view, "alpha", 1.0f, 0.0f);
alphaOut.setDuration(300);
mAnimatorSet.play(alphaEnter).after(alphaOut);
mAnimatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
view.clearAnimation();
mAnimatorSet.start();
}
});
mAnimatorSet.start();
}
19
Source : WebProgress.java
with Apache License 2.0
from yangchong211
with Apache License 2.0
from yangchong211
/**
* 开始动画
*/
private void startAnim(boolean isFinished) {
float v = isFinished ? 100 : 95;
// 先清除动画资源
if (mAnimator != null && mAnimator.isStarted()) {
mAnimator.cancel();
}
mCurrentProgress = ((int) mCurrentProgress) == 0f ? 0.00000001f : mCurrentProgress;
if (!isFinished) {
// 如果还没有完成
ValueAnimator mAnimator = ValueAnimator.ofFloat(mCurrentProgress, v);
float residue = 1f - mCurrentProgress / 100 - 0.05f;
mAnimator.setInterpolator(new LinearInterpolator());
mAnimator.setDuration((long) (residue * CURRENT_MAX_UNIFORM_SPEED_DURATION));
mAnimator.addUpdateListener(mAnimatorUpdateListener);
mAnimator.start();
this.mAnimator = mAnimator;
} else {
// 如果还没有完成
ValueAnimator segment95Animator = null;
if (mCurrentProgress < 95f) {
segment95Animator = ValueAnimator.ofFloat(mCurrentProgress, 95);
float residue = 1f - mCurrentProgress / 100f - 0.05f;
segment95Animator.setInterpolator(new LinearInterpolator());
segment95Animator.setDuration((long) (residue * CURRENT_MAX_DECELERATE_SPEED_DURATION));
segment95Animator.setInterpolator(new DecelerateInterpolator());
segment95Animator.addUpdateListener(mAnimatorUpdateListener);
}
ObjectAnimator mObjectAnimator = ObjectAnimator.ofFloat(this, "alpha", 1f, 0f);
mObjectAnimator.setDuration(DO_END_ALPHA_DURATION);
ValueAnimator mValueAnimatorEnd = ValueAnimator.ofFloat(95f, 100f);
mValueAnimatorEnd.setDuration(DO_END_PROGRESS_DURATION);
mValueAnimatorEnd.addUpdateListener(mAnimatorUpdateListener);
AnimatorSet mAnimatorSet = new AnimatorSet();
mAnimatorSet.playTogether(mObjectAnimator, mValueAnimatorEnd);
if (segment95Animator != null) {
AnimatorSet mAnimatorSet1 = new AnimatorSet();
mAnimatorSet1.play(mAnimatorSet).after(segment95Animator);
mAnimatorSet = mAnimatorSet1;
}
mAnimatorSet.addListener(mAnimatorListener);
mAnimatorSet.start();
mAnimator = mAnimatorSet;
}
TAG = STARTED;
}
19
Source : CardViewLayout.java
with Apache License 2.0
from yangchong211
with Apache License 2.0
from yangchong211
private void onRelease(float eventX, int velocityX) {
animatingView = (FrameLayout) getChildAt(3);
animateValue = animatingView.getLeft();
int tag = Integer.parseInt(animatingView.getTag().toString());
// 计算目标位置
int destX = originX.get(3);
boolean isOrigin = animatingView.getLeft() > originX.get(3) + scrollDistanceMax / 2;
if (velocityX > VELOCITY_THRESHOLD || (isOrigin && velocityX > -VELOCITY_THRESHOLD)) {
destX = originX.get(4);
tag--;
}
if (tag < 0 || tag >= adapter.gereplacedemCount()) {
return;
}
if (Math.abs(animatingView.getLeft() - destX) < mTouchSlop && Math.abs(eventX - downX) < mTouchSlop) {
return;
}
adapter.displaying(tag);
animator = ObjectAnimator.ofFloat(this, "animateValue", animatingView.getLeft(), destX);
animator.setInterpolator(interpolator);
animator.setDuration(360).start();
}
19
Source : MaterialRippleLayout.java
with Apache License 2.0
from yangchong211
with Apache License 2.0
from yangchong211
private void startRipple(final Runnable animationEndRunnable) {
if (eventCancelled)
return;
float endRadius = getEndRadius();
cancelAnimations();
rippleAnimator = new AnimatorSet();
rippleAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (!ripplePersistent) {
setRadius(0);
setRippleAlpha(rippleAlpha);
}
if (animationEndRunnable != null && rippleDelayClick) {
animationEndRunnable.run();
}
childView.setPressed(false);
}
});
ObjectAnimator ripple = ObjectAnimator.ofFloat(this, radiusProperty, radius, endRadius);
ripple.setDuration(rippleDuration);
ripple.setInterpolator(new DecelerateInterpolator());
ObjectAnimator fade = ObjectAnimator.ofInt(this, circleAlphaProperty, rippleAlpha, 0);
fade.setDuration(rippleFadeDuration);
fade.setInterpolator(new AccelerateInterpolator());
fade.setStartDelay(rippleDuration - rippleFadeDuration - FADE_EXTRA_DELAY);
if (ripplePersistent) {
rippleAnimator.play(ripple);
} else if (getRadius() > endRadius) {
fade.setStartDelay(0);
rippleAnimator.play(fade);
} else {
rippleAnimator.playTogether(ripple, fade);
}
rippleAnimator.start();
}
19
Source : MaterialMenuDrawable.java
with Apache License 2.0
from xujiaji
with Apache License 2.0
from xujiaji
private void initAnimations(int transformDuration) {
transformation = ObjectAnimator.ofFloat(this, transformationProperty, 0);
transformation.setInterpolator(new DecelerateInterpolator(3));
transformation.setDuration(transformDuration);
transformation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
transformationRunning = false;
setIconState(animatingIconState);
}
});
}
19
Source : MaterialMenuDrawable.java
with Apache License 2.0
from xujiaji
with Apache License 2.0
from xujiaji
public void setTransformationDuration(int duration) {
transformation.setDuration(duration);
}
19
Source : Animators.java
with Apache License 2.0
from xuexiangjys
with Apache License 2.0
from xuexiangjys
/**
* Create a backported Animator for
* {@code @android:anim/progress_indeterminate_horizontal_rect2}.
*
* @param target The object whose properties are to be animated.
* @return An Animator object that is set up to behave the same as the its native counterpart.
*/
public static Animator createIndeterminateHorizontalRect2(Object target) {
ObjectAnimator translateXAnimator = ObjectAnimatorCompat.ofFloat(target, "translateX", null, PATH_INDETERMINATE_HORIZONTAL_RECT2_TRANSLATE_X);
translateXAnimator.setDuration(2000);
translateXAnimator.setInterpolator(Interpolators.INDETERMINATE_HORIZONTAL_RECT2_TRANSLATE_X.INSTANCE);
translateXAnimator.setRepeatCount(ValueAnimator.INFINITE);
ObjectAnimator scaleXAnimator = ObjectAnimatorCompat.ofFloat(target, null, "scaleX", PATH_INDETERMINATE_HORIZONTAL_RECT2_SCALE_X);
scaleXAnimator.setDuration(2000);
scaleXAnimator.setInterpolator(Interpolators.INDETERMINATE_HORIZONTAL_RECT2_SCALE_X.INSTANCE);
scaleXAnimator.setRepeatCount(ValueAnimator.INFINITE);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(translateXAnimator, scaleXAnimator);
return animatorSet;
}
19
Source : Animators.java
with Apache License 2.0
from xuexiangjys
with Apache License 2.0
from xuexiangjys
/**
* Create a backported Animator for
* {@code @android:anim/progress_indeterminate_horizontal_rect1}.
*
* @param target The object whose properties are to be animated.
* @return An Animator object that is set up to behave the same as the its native counterpart.
*/
public static Animator createIndeterminateHorizontalRect1(Object target) {
ObjectAnimator translateXAnimator = ObjectAnimatorCompat.ofFloat(target, "translateX", null, PATH_INDETERMINATE_HORIZONTAL_RECT1_TRANSLATE_X);
translateXAnimator.setDuration(2000);
translateXAnimator.setInterpolator(Interpolators.INDETERMINATE_HORIZONTAL_RECT1_TRANSLATE_X.INSTANCE);
translateXAnimator.setRepeatCount(ValueAnimator.INFINITE);
ObjectAnimator scaleXAnimator = ObjectAnimatorCompat.ofFloat(target, null, "scaleX", PATH_INDETERMINATE_HORIZONTAL_RECT1_SCALE_X);
scaleXAnimator.setDuration(2000);
scaleXAnimator.setInterpolator(Interpolators.INDETERMINATE_HORIZONTAL_RECT1_SCALE_X.INSTANCE);
scaleXAnimator.setRepeatCount(ValueAnimator.INFINITE);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(translateXAnimator, scaleXAnimator);
return animatorSet;
}
19
Source : ViewShakeAnimation.java
with Apache License 2.0
from xiaolutang
with Apache License 2.0
from xiaolutang
private void setVerticalShakeAnimator(View newView) {
// 动画种类:X轴平移,后面的值为移动参数,正值为右,负值为左(Y轴正值为下,负值为上)
translationAnimatorY = ObjectAnimator.ofFloat(newView, "translationY", 0f, offset, 0f, -offset, 0f);
// 用于控制动画快慢节奏,此处使用系统自带的线性Interpolator(匀速),此外还有各种变速Interpolator
translationAnimatorY.setInterpolator(new LinearInterpolator());
// 设置动画重复次数,ValueAnimator.INFINITE即-1表示用于一直重复
translationAnimatorY.setRepeatCount(ValueAnimator.RESTART);
translationAnimatorY.setRepeatCount(1);
translationAnimatorY.setDuration(DURATION);
}
19
Source : ViewShakeAnimation.java
with Apache License 2.0
from xiaolutang
with Apache License 2.0
from xiaolutang
private void setHorizontalShakeAnimator(View newView) {
// 动画种类:X轴平移,后面的值为移动参数,正值为右,负值为左(Y轴正值为下,负值为上)
translationAnimatorX = ObjectAnimator.ofFloat(newView, "translationX", 0f, offset, 0f, -offset, 0f);
// 用于控制动画快慢节奏,此处使用系统自带的线性Interpolator(匀速),此外还有各种变速Interpolator
translationAnimatorX.setInterpolator(new LinearInterpolator());
// 设置动画重复次数,ValueAnimator.INFINITE即-1表示用于一直重复
translationAnimatorX.setRepeatCount(ValueAnimator.RESTART);
translationAnimatorX.setRepeatCount(1);
translationAnimatorX.setDuration(DURATION);
}
19
Source : ProgressView.java
with Apache License 2.0
from xiaojieonly
with Apache License 2.0
from xiaojieonly
private void setupAnimators() {
ObjectAnimator trimStart = ObjectAnimator.ofFloat(this, "trimStart", 0.0f, 0.75f);
trimStart.setDuration(1333L);
trimStart.setInterpolator(TRIM_START_INTERPOLATOR);
trimStart.setRepeatCount(Animation.INFINITE);
ObjectAnimator trimEnd = ObjectAnimator.ofFloat(this, "trimEnd", 0.0f, 0.75f);
trimEnd.setDuration(1333L);
trimEnd.setInterpolator(TRIM_END_INTERPOLATOR);
trimEnd.setRepeatCount(Animation.INFINITE);
ObjectAnimator trimOffset = ObjectAnimator.ofFloat(this, "trimOffset", 0.0f, 0.25f);
trimOffset.setDuration(1333L);
trimOffset.setInterpolator(LINEAR_INTERPOLATOR);
trimOffset.setRepeatCount(Animation.INFINITE);
ObjectAnimator trimRotation = ObjectAnimator.ofFloat(this, "trimRotation", 0.0f, 720.0f);
trimRotation.setDuration(6665L);
trimRotation.setInterpolator(LINEAR_INTERPOLATOR);
trimRotation.setRepeatCount(Animation.INFINITE);
mAnimators.add(trimStart);
mAnimators.add(trimEnd);
mAnimators.add(trimOffset);
mAnimators.add(trimRotation);
}
19
Source : ViewAnimation.java
with GNU General Public License v3.0
from XecureIT
with GNU General Public License v3.0
from XecureIT
public static void fadeOutIn(View view) {
view.setAlpha(0.f);
AnimatorSet animatorSet = new AnimatorSet();
ObjectAnimator animatorAlpha = ObjectAnimator.ofFloat(view, "alpha", 0.f, 0.5f, 1.f);
ObjectAnimator.ofFloat(view, "alpha", 0.f).start();
animatorAlpha.setDuration(500);
animatorSet.play(animatorAlpha);
animatorSet.start();
}
19
Source : AbsFocusBorder.java
with Apache License 2.0
from wangxiaoxuan217
with Apache License 2.0
from wangxiaoxuan217
private ObjectAnimator getShimmerAnimator() {
if (null == mShimmerAnimator) {
mShimmerAnimator = ObjectAnimator.ofFloat(this, "shimmerTranslate", -1f, 1f);
mShimmerAnimator.setInterpolator(new LinearInterpolator());
mShimmerAnimator.setDuration(mShimmerDuration);
mShimmerAnimator.setStartDelay(400);
mShimmerAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
setShimmerAnimating(true);
}
@Override
public void onAnimationEnd(Animator animation) {
setShimmerAnimating(false);
}
});
}
return mShimmerAnimator;
}
19
Source : MySwitchButton.java
with MIT License
from wangfeng19930909
with MIT License
from wangfeng19930909
private void init(AttributeSet attrs) {
mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
mClickTimeout = ViewConfiguration.getPressedStateDuration() + ViewConfiguration.getTapTimeout();
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mRectPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mRectPaint.setStyle(Paint.Style.STROKE);
mRectPaint.setStrokeWidth(getResources().getDisplayMetrics().density);
mTextPaint = getPaint();
mThumbRectF = new RectF();
mBackRectF = new RectF();
mSafeRectF = new RectF();
mThumbSizeF = new PointF();
mThumbMargin = new RectF();
mTextOnRectF = new RectF();
mTextOffRectF = new RectF();
mProcessAnimator = ObjectAnimator.ofFloat(this, "process", 0, 0).setDuration(DEFAULT_ANIMATION_DURATION);
mProcessAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
mPresentThumbRectF = new RectF();
Resources res = getResources();
float density = res.getDisplayMetrics().density;
Drawable thumbDrawable = null;
ColorStateList thumbColor = null;
float margin = density * DEFAULT_THUMB_MARGIN_DP;
float marginLeft = 0;
float marginRight = 0;
float marginTop = 0;
float marginBottom = 0;
float thumbWidth = density * DEFAULT_THUMB_SIZE_DP;
float thumbHeight = density * DEFAULT_THUMB_SIZE_DP;
float thumbRadius = density * DEFAULT_THUMB_SIZE_DP / 2;
float backRadius = thumbRadius;
Drawable backDrawable = null;
ColorStateList backColor = null;
float backMeasureRatio = DEFAULT_BACK_MEASURE_RATIO;
int animationDuration = DEFAULT_ANIMATION_DURATION;
boolean fadeBack = true;
int tintColor = Integer.MIN_VALUE;
String textOn = null;
String textOff = null;
float textMarginH = density * DEFAULT_TEXT_MARGIN_DP;
TypedArray ta = attrs == null ? null : getContext().obtainStyledAttributes(attrs, R.styleable.SwitchButton);
if (ta != null) {
thumbDrawable = ta.getDrawable(R.styleable.SwitchButton_kswThumbDrawable);
thumbColor = ta.getColorStateList(R.styleable.SwitchButton_kswThumbColor);
margin = ta.getDimension(R.styleable.SwitchButton_kswThumbMargin, margin);
marginLeft = ta.getDimension(R.styleable.SwitchButton_kswThumbMarginLeft, margin);
marginRight = ta.getDimension(R.styleable.SwitchButton_kswThumbMarginRight, margin);
marginTop = ta.getDimension(R.styleable.SwitchButton_kswThumbMarginTop, margin);
marginBottom = ta.getDimension(R.styleable.SwitchButton_kswThumbMarginBottom, margin);
thumbWidth = ta.getDimension(R.styleable.SwitchButton_kswThumbWidth, thumbWidth);
thumbHeight = ta.getDimension(R.styleable.SwitchButton_kswThumbHeight, thumbHeight);
thumbRadius = ta.getDimension(R.styleable.SwitchButton_kswThumbRadius, Math.min(thumbWidth, thumbHeight) / 2.f);
backRadius = ta.getDimension(R.styleable.SwitchButton_kswBackRadius, thumbRadius + density * 2f);
backDrawable = ta.getDrawable(R.styleable.SwitchButton_kswBackDrawable);
backColor = ta.getColorStateList(R.styleable.SwitchButton_kswBackColor);
backMeasureRatio = ta.getFloat(R.styleable.SwitchButton_kswBackMeasureRatio, backMeasureRatio);
animationDuration = ta.getInteger(R.styleable.SwitchButton_kswAnimationDuration, animationDuration);
fadeBack = ta.getBoolean(R.styleable.SwitchButton_kswFadeBack, true);
tintColor = ta.getColor(R.styleable.SwitchButton_kswTintColor, tintColor);
textOn = ta.getString(R.styleable.SwitchButton_kswTextOn);
textOff = ta.getString(R.styleable.SwitchButton_kswTextOff);
textMarginH = ta.getDimension(R.styleable.SwitchButton_kswTextMarginH, textMarginH);
ta.recycle();
}
// text
mTextOn = textOn;
mTextOff = textOff;
mTextMarginH = textMarginH;
// thumb drawable and color
mThumbDrawable = thumbDrawable;
mThumbColor = thumbColor;
mIsThumbUseDrawable = mThumbDrawable != null;
mTintColor = tintColor;
if (mTintColor == Integer.MIN_VALUE) {
mTintColor = DEFAULT_TINT_COLOR;
}
if (!mIsThumbUseDrawable && mThumbColor == null) {
mThumbColor = ColorUtils.generateThumbColorWithTintColor(mTintColor);
mCurrThumbColor = mThumbColor.getDefaultColor();
}
if (mIsThumbUseDrawable) {
thumbWidth = Math.max(thumbWidth, mThumbDrawable.getMinimumWidth());
thumbHeight = Math.max(thumbHeight, mThumbDrawable.getMinimumHeight());
}
mThumbSizeF.set(thumbWidth, thumbHeight);
// back drawable and color
mBackDrawable = backDrawable;
mBackColor = backColor;
mIsBackUseDrawable = mBackDrawable != null;
if (!mIsBackUseDrawable && mBackColor == null) {
mBackColor = ColorUtils.generateBackColorWithTintColor(mTintColor);
mCurrBackColor = mBackColor.getDefaultColor();
mNextBackColor = mBackColor.getColorForState(CHECKED_PRESSED_STATE, mCurrBackColor);
}
// margin
mThumbMargin.set(marginLeft, marginTop, marginRight, marginBottom);
// size & measure params must larger than 1
mBackMeasureRatio = mThumbMargin.width() >= 0 ? Math.max(backMeasureRatio, 1) : backMeasureRatio;
mThumbRadius = thumbRadius;
mBackRadius = backRadius;
mAnimationDuration = animationDuration;
mFadeBack = fadeBack;
mProcessAnimator.setDuration(mAnimationDuration);
setFocusable(true);
setClickable(true);
// sync checked status
if (isChecked()) {
setProcess(1);
}
}
19
Source : MeetingApprFragment.java
with MIT License
from wangcantian
with MIT License
from wangcantian
private void initViewAnimation() {
toWaitAnimator = ObjectAnimator.ofFloat(mScrollBar, "translationX", scrollBarWidth / 2, 0);
toWaitAnimator.setDuration(300);
toWaitAnimator.setInterpolator(new DecelerateInterpolator());
toHistoryAnimator = ObjectAnimator.ofFloat(mScrollBar, "translationX", 0, scrollBarWidth / 2);
toHistoryAnimator.setDuration(300);
toHistoryAnimator.setInterpolator(new DecelerateInterpolator());
waitNormalAnimator = ObjectAnimator.ofInt(waitApproval, "textColor", Color.parseColor("#ffffff"), Color.parseColor("#7a7774"));
waitNormalAnimator.setDuration(300);
waitNormalAnimator.setInterpolator(new DecelerateInterpolator());
waitNormalAnimator.setEvaluator(new ArgbEvaluator());
waitActiveAnimator = ObjectAnimator.ofInt(waitApproval, "textColor", Color.parseColor("#7a7774"), Color.parseColor("#ffffff"));
waitActiveAnimator.setDuration(300);
waitActiveAnimator.setInterpolator(new DecelerateInterpolator());
waitActiveAnimator.setEvaluator(new ArgbEvaluator());
hisNormalAnimator = ObjectAnimator.ofInt(historyAproval, "textColor", Color.parseColor("#ffffff"), Color.parseColor("#7a7774"));
hisNormalAnimator.setDuration(300);
hisNormalAnimator.setEvaluator(new ArgbEvaluator());
hisNormalAnimator.setInterpolator(new DecelerateInterpolator());
hisActiveAnimator = ObjectAnimator.ofInt(historyAproval, "textColor", Color.parseColor("#7a7774"), Color.parseColor("#ffffff"));
hisActiveAnimator.setDuration(300);
hisActiveAnimator.setInterpolator(new DecelerateInterpolator());
hisActiveAnimator.setEvaluator(new ArgbEvaluator());
}
19
Source : DotsFragment.java
with Apache License 2.0
from vpaliy
with Apache License 2.0
from vpaliy
private AnimatorSet morphParent(int duration) {
GradientDrawable drawable = GradientDrawable.clreplaced.cast(parent.getBackground());
int endValue = isFolded ? getResources().getDimensionPixelOffset(R.dimen.morph_radius) : 0;
ObjectAnimator cornerAnimation = ObjectAnimator.ofFloat(drawable, "cornerRadius", endValue);
endValue = isFolded ? parent.getHeight() / 2 : parent.getHeight() * 2;
ValueAnimator heightAnimation = ValueAnimator.ofInt(parent.getHeight(), endValue);
heightAnimation.addUpdateListener(valueAnimator -> {
int val = (Integer) valueAnimator.getAnimatedValue();
ViewGroup.LayoutParams layoutParams = parent.getLayoutParams();
layoutParams.height = val;
parent.setLayoutParams(layoutParams);
});
cornerAnimation.setDuration(duration);
heightAnimation.setDuration(duration);
AnimatorSet set = new AnimatorSet();
set.playTogether(cornerAnimation, heightAnimation);
return set;
}
19
Source : UDAnimator.java
with GNU General Public License v3.0
from VideoOS
with GNU General Public License v3.0
from VideoOS
/**
* 时长
*
* @param duration
* @return
*/
public UDAnimator setDuration(long duration) {
ObjectAnimator animator = getAnimator();
if (animator != null && duration >= 0) {
animator.setDuration(duration);
}
return this;
}
19
Source : RecipesItemAnimator.java
with Apache License 2.0
from vicky7230
with Apache License 2.0
from vicky7230
private void animateHeartButton(final RecipesAdapter.RecipeViewHolder holder) {
AnimatorSet animatorSet = new AnimatorSet();
ObjectAnimator rotation = ObjectAnimator.ofFloat(holder.likeButton, "rotation", 0.0f, 360.0f);
rotation.setDuration(800);
rotation.setInterpolator(ANTICIPATE_OVERSHOOT_INTERPOLATOR);
ObjectAnimator scaleX = ObjectAnimator.ofFloat(holder.likeButton, "scaleX", 1.0f, 1.5f, 1.0f);
scaleX.setDuration(800);
scaleX.setInterpolator(ANTICIPATE_OVERSHOOT_INTERPOLATOR);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(holder.likeButton, "scaleY", 1.0f, 1.5f, 1.0f);
scaleY.setDuration(800);
scaleY.setInterpolator(ANTICIPATE_OVERSHOOT_INTERPOLATOR);
rotation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator valueAnimator) {
if (valueAnimator.getCurrentPlayTime() >= 500) {
holder.likeButton.setImageResource(R.drawable.ic_favorite_higlighted_24dp);
}
}
});
animatorSet.playTogether(rotation, scaleX, scaleY);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
dispatchAnimationFinished(holder);
}
});
animatorSet.start();
}
19
Source : SparkButton.java
with Apache License 2.0
from varunest
with Apache License 2.0
from varunest
/**
* Call this function to start spark animation
*/
public void playAnimation() {
if (animatorSet != null) {
animatorSet.cancel();
}
imageView.animate().cancel();
imageView.setScaleX(0);
imageView.setScaleY(0);
circleView.setInnerCircleRadiusProgress(0);
circleView.setOuterCircleRadiusProgress(0);
dotsView.setCurrentProgress(0);
animatorSet = new AnimatorSet();
ObjectAnimator outerCircleAnimator = ObjectAnimator.ofFloat(circleView, CircleView.OUTER_CIRCLE_RADIUS_PROGRESS, 0.1f, 1f);
outerCircleAnimator.setDuration((long) (250 / animationSpeed));
outerCircleAnimator.setInterpolator(DECELERATE_INTERPOLATOR);
ObjectAnimator innerCircleAnimator = ObjectAnimator.ofFloat(circleView, CircleView.INNER_CIRCLE_RADIUS_PROGRESS, 0.1f, 1f);
innerCircleAnimator.setDuration((long) (200 / animationSpeed));
innerCircleAnimator.setStartDelay((long) (200 / animationSpeed));
innerCircleAnimator.setInterpolator(DECELERATE_INTERPOLATOR);
ObjectAnimator starScaleYAnimator = ObjectAnimator.ofFloat(imageView, ImageView.SCALE_Y, 0.2f, 1f);
starScaleYAnimator.setDuration((long) (350 / animationSpeed));
starScaleYAnimator.setStartDelay((long) (250 / animationSpeed));
starScaleYAnimator.setInterpolator(OVERSHOOT_INTERPOLATOR);
ObjectAnimator starScaleXAnimator = ObjectAnimator.ofFloat(imageView, ImageView.SCALE_X, 0.2f, 1f);
starScaleXAnimator.setDuration((long) (350 / animationSpeed));
starScaleXAnimator.setStartDelay((long) (250 / animationSpeed));
starScaleXAnimator.setInterpolator(OVERSHOOT_INTERPOLATOR);
ObjectAnimator dotsAnimator = ObjectAnimator.ofFloat(dotsView, DotsView.DOTS_PROGRESS, 0, 1f);
dotsAnimator.setDuration((long) (900 / animationSpeed));
dotsAnimator.setStartDelay((long) (50 / animationSpeed));
dotsAnimator.setInterpolator(ACCELERATE_DECELERATE_INTERPOLATOR);
animatorSet.playTogether(outerCircleAnimator, innerCircleAnimator, starScaleYAnimator, starScaleXAnimator, dotsAnimator);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationCancel(Animator animation) {
circleView.setInnerCircleRadiusProgress(0);
circleView.setOuterCircleRadiusProgress(0);
dotsView.setCurrentProgress(0);
imageView.setScaleX(1);
imageView.setScaleY(1);
}
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
if (listener != null) {
listener.onEventAnimationEnd(imageView, isChecked);
}
}
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationEnd(animation);
if (listener != null) {
listener.onEventAnimationStart(imageView, isChecked);
}
}
});
animatorSet.start();
}
19
Source : LoginActivity.java
with GNU General Public License v3.0
from tysqapp
with GNU General Public License v3.0
from tysqapp
@Override
protected void initView() {
isHidePwd = true;
isNeedCode = false;
mRefreshAnim = ObjectAnimator.ofFloat(ivRefresh, "rotation", 0, 360);
mRefreshAnim.setDuration(2_000);
mRefreshAnim.setInterpolator(new LinearInterpolator());
mRefreshAnim.setRepeatCount(ValueAnimator.INFINITE);
ivBack.setOnClickListener(this);
ivRefresh.setOnClickListener(this);
ivPwdState.setOnClickListener(this);
tvLogin.setOnClickListener(this);
tvForgetPwd.setOnClickListener(this);
tvRegister.setOnClickListener(this);
changeLoginBtnClickable();
etEmail.addTextChangedListener(new TexreplacedcherAdapter() {
@Override
public void afterTextChanged(Editable s) {
changeLoginBtnClickable();
}
});
etCode.addTextChangedListener(new TexreplacedcherAdapter() {
@Override
public void afterTextChanged(Editable s) {
changeLoginBtnClickable();
}
});
etPwd.addTextChangedListener(new TexreplacedcherAdapter() {
@Override
public void afterTextChanged(Editable s) {
changeLoginBtnClickable();
}
});
etEmail.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
return;
}
String email = getEmailInfo();
boolean isMatch = checkEmail(email);
if (!isMatch) {
ToastUtils.show(getString(R.string.email_format_illegal));
}
}
});
}
19
Source : PostListActivity.java
with MIT License
from TryGhost
with MIT License
from TryGhost
@OnClick(R.id.new_post_btn)
public void onNewPostBtnClicked(View btn) {
Runnable createPost = () -> getBus().post(new CreatePostEvent());
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
// circular reveal animation
int[] revealViewLocation = new int[2], btnLocation = new int[2];
mNewPostRevealView.getLocationOnScreen(revealViewLocation);
btn.getLocationOnScreen(btnLocation);
int centerX = btnLocation[0] - revealViewLocation[0] + btn.getWidth() / 2;
int centerY = btnLocation[1] - revealViewLocation[1] + btn.getHeight() / 2;
float endRadius = (float) Math.hypot(centerX, centerY);
Animator revealAnimator = ViewAnimationUtils.createCircularReveal(mNewPostRevealView, centerX, centerY, 0, endRadius);
revealAnimator.setDuration(500);
revealAnimator.setInterpolator(new AccelerateInterpolator());
mNewPostRevealView.setVisibility(View.VISIBLE);
// background color animation
ValueAnimator colorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), mColorAccent, mColorPrimary);
colorAnimator.addUpdateListener(animator -> mNewPostRevealShrinkView.setBackgroundColor((int) animator.getAnimatedValue()));
colorAnimator.setDuration(500);
colorAnimator.setInterpolator(new AccelerateInterpolator());
// shrink animation
float startHeight = mNewPostRevealShrinkView.getHeight();
float targetScaleY = (mToolbarHeight + mTabbarHeight) / startHeight;
ObjectAnimator shrinkAnimator = ObjectAnimator.ofFloat(mNewPostRevealShrinkView, "scaleY", targetScaleY);
shrinkAnimator.setStartDelay(150);
shrinkAnimator.setDuration(300);
shrinkAnimator.setInterpolator(new DecelerateInterpolator());
// play reveal + color change together, followed by shrink
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(revealAnimator).with(colorAnimator);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
shrinkAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
createPost.run();
}
});
shrinkAnimator.start();
}
});
animatorSet.start();
} else {
createPost.run();
}
}
19
Source : CircularAnimatedDrawable.java
with Apache License 2.0
from triline3
with Apache License 2.0
from triline3
private void setupAnimations() {
mObjectAnimatorAngle = ObjectAnimator.ofFloat(this, mAngleProperty, 360f);
mObjectAnimatorAngle.setInterpolator(ANGLE_INTERPOLATOR);
mObjectAnimatorAngle.setDuration(ANGLE_ANIMATOR_DURATION);
mObjectAnimatorAngle.setRepeatMode(ValueAnimator.RESTART);
mObjectAnimatorAngle.setRepeatCount(ValueAnimator.INFINITE);
mObjectAnimatorSweep = ObjectAnimator.ofFloat(this, mSweepProperty, 360f - MIN_SWEEP_ANGLE * 2);
mObjectAnimatorSweep.setInterpolator(SWEEP_INTERPOLATOR);
mObjectAnimatorSweep.setDuration(SWEEP_ANIMATOR_DURATION);
mObjectAnimatorSweep.setRepeatMode(ValueAnimator.RESTART);
mObjectAnimatorSweep.setRepeatCount(ValueAnimator.INFINITE);
mObjectAnimatorSweep.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
toggleAppearingMode();
}
});
}
19
Source : RippleWrapper.java
with Apache License 2.0
from triline3
with Apache License 2.0
from triline3
public void build() {
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.addRule(CENTER_IN_PARENT, TRUE);
mAnimatorSet = new AnimatorSet();
ArrayList<Animator> animators = new ArrayList<>();
for (int i = 0; i < mRippleAmount; i++) {
RippleView rippleView = new RippleView(getContext(), mRippleColor);
addView(rippleView, params);
ObjectAnimator widthAnimator = ObjectAnimator.ofFloat(rippleView, SCALE_X, 1.0f, 1.318f);
widthAnimator.setRepeatCount(ObjectAnimator.INFINITE);
widthAnimator.setRepeatMode(ObjectAnimator.RESTART);
widthAnimator.setDuration(mRippleDuration);
widthAnimator.setStartDelay(i * mRippleDelay);
widthAnimator.setInterpolator(new AccelerateInterpolator());
animators.add(widthAnimator);
ObjectAnimator heightAnimator = ObjectAnimator.ofFloat(rippleView, SCALE_Y, 1.0f, 1.318f);
heightAnimator.setRepeatCount(ObjectAnimator.INFINITE);
heightAnimator.setRepeatMode(ObjectAnimator.RESTART);
heightAnimator.setDuration(mRippleDuration);
heightAnimator.setStartDelay(i * mRippleDelay);
heightAnimator.setInterpolator(new AccelerateInterpolator());
animators.add(heightAnimator);
ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(rippleView, View.ALPHA, 1.0f, 0f);
alphaAnimator.setRepeatCount(ObjectAnimator.INFINITE);
alphaAnimator.setRepeatMode(ObjectAnimator.RESTART);
alphaAnimator.setDuration(mRippleDuration);
alphaAnimator.setStartDelay(i * mRippleDelay);
alphaAnimator.setInterpolator(new AccelerateInterpolator());
animators.add(alphaAnimator);
}
mAnimatorSet.playTogether(animators);
mAnimatorSet.start();
}
19
Source : PileLayout.java
with Apache License 2.0
from triline3
with Apache License 2.0
from triline3
private void onRelease(float eventX, float velocityX) {
animatingView = (FrameLayout) getChildAt(3);
animateValue = animatingView.getLeft();
int tag = Integer.parseInt(animatingView.getTag().toString());
// 计算目标位置
int destX = originX.get(3);
if (velocityX > VELOCITY_THRESHOLD || (animatingView.getLeft() > originX.get(3) + scrollDistanceMax / 2 && velocityX > -VELOCITY_THRESHOLD)) {
destX = originX.get(4);
tag--;
}
if (tag < 0 || tag >= adapter.gereplacedemCount()) {
return;
}
if (Math.abs(animatingView.getLeft() - destX) < mTouchSlop && Math.abs(eventX - downX) < mTouchSlop) {
return;
}
adapter.displaying(tag);
animator = ObjectAnimator.ofFloat(this, "animateValue", animatingView.getLeft(), destX);
animator.setInterpolator(interpolator);
animator.setDuration(360).start();
}
19
Source : FlipMenuView.java
with Apache License 2.0
from triline3
with Apache License 2.0
from triline3
private void initView() {
mPath = new Path();
mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setStyle(Paint.Style.FILL);
mPaint.setTextSize(sp2px(14));
mCamera = new Camera();
mMatrix = new Matrix();
mAlphaAnim = ObjectAnimator.ofFloat(this, "alpha", 1.0f, 0f);
mAlphaAnim.setDuration(200);
mAlphaAnim.addListener(new MyAnimListener() {
@Override
public void onAnimationEnd(Animator animation) {
removeView();
if (onFlipClickListener != null) {
onFlipClickListener.dismiss();
}
}
});
int parentViewWidth = mParentView.getMeasuredWidth();
int parentViewHeight = mParentView.getMeasuredHeight();
int[] location = new int[2];
mParentView.getLocationInWindow(location);
int parentTop = location[1] - parentViewHeight / 2;
int parentBottom = location[1] + parentViewHeight / 2;
int parentMiddleX = location[0] + parentViewWidth / 2;
if (location[1] < mScreenHeight / 2) {
mStatus = STATUS_DOWN;
mItemTop = parentBottom + dip2px(5);
mFirsreplacedemTop = mItemTop + dip2px(6);
} else {
mStatus = STATUS_UP;
mItemTop = parentTop - dip2px(5);
mFirsreplacedemTop = mItemTop - dip2px(6);
}
if (parentMiddleX + mItemWidth / 2 > mScreenWidth) {
mItemLeft = mScreenWidth - mItemWidth - mBorderMargin - parentMiddleX;
} else if (parentMiddleX - mItemWidth / 2 < 0) {
mItemLeft = mBorderMargin;
} else {
mItemLeft = parentMiddleX - mItemWidth / 2;
}
}
19
Source : MaskLayout.java
with Apache License 2.0
from totond
with Apache License 2.0
from totond
// 设置属性动画,主要是将ScannerView从上一个地方移动到下一个目标然后放大
private void animate(final ScannerView scannerView, ScanTarget target) {
if (target.getIsRegion()) {
mScannerList.get(0).setScannerRegion(target.getRegion());
} else {
mScannerList.get(0).setScannerRegion(target.viewToRegion(-mYGuider.getContentLocationX(), -mYGuider.getContentLocationY()));
}
// 设置跳过和下一步的字符
if (target.getJumpText() == null) {
target.setJumpText(mYGuider.getJumpText());
}
if (target.getNextText() == null) {
target.setNextText(mYGuider.getNextText());
}
ObjectAnimator moveAnimator = ObjectAnimator.ofObject(scannerView, "layoutRegion", new RegionEvaluator(), scannerView.getLastRegion(), getCenterRectF(target.getRegion()));
ObjectAnimator expandAnimator = ObjectAnimator.ofObject(scannerView, "layoutRegion", new RegionEvaluator(), scannerView.getLayoutRegion(), scannerView.getsRegion());
moveAnimator.setDuration(mMoveDuration);
expandAnimator.setDuration(mExpandDuration);
mDoAnimator = new AnimatorSet();
mDoAnimator.play(expandAnimator).after(moveAnimator);
mDoAnimator.addListener(new AbstractAnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
mGuidePopupWindow.dismiss();
setClickable(false);
// 启动不断draw来刷新扫描框移动的画面
isDoingAnimation = true;
postInvalidate();
}
@Override
public void onAnimationEnd(Animator animation) {
isDoingAnimation = false;
setClickable(true);
showWindow();
scanIndex++;
}
});
mDoAnimator.start();
}
19
Source : GameSelector.java
with GNU General Public License v3.0
from TobiasBielefeld
with GNU General Public License v3.0
from TobiasBielefeld
/**
* changes the button size, according to the second parameter.
* Used to shrink/expand the menu buttons.
*
* @param view The view to apply the changes
* @param scale The scale to apply
*/
private void changeButtonSize(View view, float scale) {
ObjectAnimator animX = ObjectAnimator.ofFloat(view, "scaleX", scale);
animX.setDuration(100);
ObjectAnimator animY = ObjectAnimator.ofFloat(view, "scaleY", scale);
animY.setDuration(100);
AnimatorSet animSetXY = new AnimatorSet();
animSetXY.playTogether(animX, animY);
if (scale == 1.0) {
// expand button with a little delay
animSetXY.setStartDelay(getResources().getInteger(R.integer.expand_button_anim_delay_ms));
}
animSetXY.start();
}
19
Source : MapAnimator.java
with MIT License
from tintinscorpion
with MIT License
from tintinscorpion
public void animateRoute(GoogleMap googleMap, List<LatLng> bangaloreRoute) {
if (firstRunAnimSet == null) {
firstRunAnimSet = new AnimatorSet();
} else {
firstRunAnimSet.removeAllListeners();
firstRunAnimSet.end();
firstRunAnimSet.cancel();
firstRunAnimSet = new AnimatorSet();
}
if (secondLoopRunAnimSet == null) {
secondLoopRunAnimSet = new AnimatorSet();
} else {
secondLoopRunAnimSet.removeAllListeners();
secondLoopRunAnimSet.end();
secondLoopRunAnimSet.cancel();
secondLoopRunAnimSet = new AnimatorSet();
}
// Reset the polylines
if (foregroundPolyline != null)
foregroundPolyline.remove();
if (backgroundPolyline != null)
backgroundPolyline.remove();
PolylineOptions optionsBackground = new PolylineOptions().add(bangaloreRoute.get(0)).color(GREY).width(8);
backgroundPolyline = googleMap.addPolyline(optionsBackground);
optionsForeground = new PolylineOptions().add(bangaloreRoute.get(0)).color(BLACK).width(8);
foregroundPolyline = googleMap.addPolyline(optionsForeground);
final ValueAnimator percentageCompletion = ValueAnimator.ofInt(0, 100);
percentageCompletion.setDuration(PERCENT_COMPLETION);
percentageCompletion.setInterpolator(new DecelerateInterpolator());
percentageCompletion.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
List<LatLng> foregroundPoints = backgroundPolyline.getPoints();
int percentageValue = (int) animation.getAnimatedValue();
int pointcount = foregroundPoints.size();
int countTobeRemoved = (int) (pointcount * (percentageValue / 100.0f));
List<LatLng> subListTobeRemoved = foregroundPoints.subList(0, countTobeRemoved);
subListTobeRemoved.clear();
foregroundPolyline.setPoints(foregroundPoints);
}
});
percentageCompletion.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
foregroundPolyline.setColor(GREY);
foregroundPolyline.setPoints(backgroundPolyline.getPoints());
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), GREY, BLACK);
colorAnimation.setInterpolator(new AccelerateInterpolator());
// milliseconds
colorAnimation.setDuration(COLOR_FILL_ANIMATION);
colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
foregroundPolyline.setColor((int) animator.getAnimatedValue());
}
});
ObjectAnimator foregroundRouteAnimator = ObjectAnimator.ofObject(this, "routeIncreaseForward", new RouteEvaluator(), bangaloreRoute.toArray());
foregroundRouteAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
foregroundRouteAnimator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
backgroundPolyline.setPoints(foregroundPolyline.getPoints());
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
foregroundRouteAnimator.setDuration(FOREGROUND_TIME);
// foregroundRouteAnimator.start();
firstRunAnimSet.playSequentially(foregroundRouteAnimator, percentageCompletion);
firstRunAnimSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
secondLoopRunAnimSet.start();
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
secondLoopRunAnimSet.playSequentially(colorAnimation, percentageCompletion);
secondLoopRunAnimSet.setStartDelay(DELAY_TIME);
secondLoopRunAnimSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
secondLoopRunAnimSet.start();
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
firstRunAnimSet.start();
}
19
Source : CallSwipeView.java
with GNU General Public License v2.0
from TelePlusDev
with GNU General Public License v2.0
from TelePlusDev
private void init() {
arrowsPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
arrowsPaint.setColor(0xFFFFFFFF);
arrowsPaint.setStyle(Paint.Style.STROKE);
arrowsPaint.setStrokeWidth(AndroidUtilities.dp(2.5f));
pullBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
ArrayList<Animator> anims = new ArrayList<>();
for (int i = 0; i < arrowAlphas.length; i++) {
ArrowAnimWrapper aaw = new ArrowAnimWrapper(i);
ObjectAnimator anim = ObjectAnimator.ofInt(aaw, "arrowAlpha", 64, 255, 64);
anim.setDuration(700);
anim.setStartDelay(200 * i);
// anim.setRepeatCount(ValueAnimator.INFINITE);
anims.add(anim);
}
arrowAnim = new AnimatorSet();
arrowAnim.playTogether(anims);
arrowAnim.addListener(new AnimatorListenerAdapter() {
private long startTime;
private Runnable restarter = new Runnable() {
@Override
public void run() {
if (arrowAnim != null) {
arrowAnim.start();
}
}
};
@Override
public void onAnimationEnd(Animator animation) {
if (System.currentTimeMillis() - startTime < animation.getDuration() / 4) {
if (BuildVars.LOGS_ENABLED) {
FileLog.w("Not repeating animation because previous loop was too fast");
}
return;
}
if (!canceled && animatingArrows)
post(restarter);
}
@Override
public void onAnimationCancel(Animator animation) {
canceled = true;
}
@Override
public void onAnimationStart(Animator animation) {
startTime = System.currentTimeMillis();
}
});
}
19
Source : AnimatorUtils.java
with Apache License 2.0
from TaoPaox
with Apache License 2.0
from TaoPaox
/**
* 控件透明度的动画
* @param view view
* @param isShow 消失or出现
* @param duration 动画时长
* @param animatorListener 动画回调监听
* @return
*/
public static Animator viewAlphaAnimator(final View view, final boolean isShow, long duration, @Nullable final FreeAnimatorListener animatorListener) {
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, View.ALPHA, isShow ? 0f : 1f, isShow ? 1f : 0f);
objectAnimator.setDuration(duration);
objectAnimator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
if (isShow) {
view.setVisibility(View.VISIBLE);
}
if (animatorListener != null) {
animatorListener.onAnimationStart(animation);
}
}
@Override
public void onAnimationEnd(Animator animation) {
if (!isShow) {
view.setVisibility(View.INVISIBLE);
}
if (animatorListener != null) {
animatorListener.onAnimationEnd(animation);
}
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
// objectAnimator.start();
return objectAnimator;
}
19
Source : AnimatorUtils.java
with Apache License 2.0
from TaoPaox
with Apache License 2.0
from TaoPaox
/**
* 控件的旋转动画
* @param view view
* @param startAngle 开始的角度
* @param endAngle 结束的角度
* @param duration 持续时长
* @param animatorListener 动画回调监听
* @return
*/
public static Animator rotationAnimator(View view, int startAngle, int endAngle, int duration, @Nullable final FreeAnimatorListener animatorListener) {
ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, View.ROTATION, startAngle, endAngle);
objectAnimator.setDuration(duration);
if (animatorListener != null) {
objectAnimator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
animatorListener.onAnimationStart(animation);
}
@Override
public void onAnimationEnd(Animator animation) {
animatorListener.onAnimationEnd(animation);
}
@Override
public void onAnimationCancel(Animator animation) {
animatorListener.onAnimationCancel(animation);
}
@Override
public void onAnimationRepeat(Animator animation) {
animatorListener.onAnimationRepeat(animation);
}
});
}
return objectAnimator;
}
19
Source : MusicalNoteLayout.java
with Apache License 2.0
from TaoPaox
with Apache License 2.0
from TaoPaox
// 出场动画
private AnimatorSet getEnterAnimator(final View target) {
ObjectAnimator alpha = ObjectAnimator.ofFloat(target, View.ALPHA, 0.1f, 1f);
ObjectAnimator scaleX = ObjectAnimator.ofFloat(target, View.SCALE_X, 0.0f, 1f);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(target, View.SCALE_Y, 0.0f, 1f);
AnimatorSet enter = new AnimatorSet();
enter.setDuration(1000);
enter.setInterpolator(new AccelerateInterpolator());
enter.playTogether(alpha, scaleX, scaleY);
AnimatorSet before = new AnimatorSet();
// 同时在正负25f的角度上做随机旋转
ObjectAnimator rotate = ObjectAnimator.ofFloat(target, View.ROTATION, 0.0f, mRandom.nextInt(50) - 25.5f);
rotate.setDuration(2000);
before.playSequentially(enter, rotate);
return before;
}
19
Source : FlipProgressDialog.java
with Apache License 2.0
from Taishi-Y
with Apache License 2.0
from Taishi-Y
private void animateAnimatorSetSample(ImageView target) {
// Set AnimatorList(Will set on AnimatorSet)
List<Animator> animatorList = new ArrayList<Animator>();
// alphaプロパティを0fから1fに変化させます
PropertyValuesHolder alphaAnimator = PropertyValuesHolder.ofFloat("alpha", minAlpha, maxAlpha, minAlpha);
PropertyValuesHolder flipAnimator = PropertyValuesHolder.ofFloat(orientation, startAngle, endAngle);
ObjectAnimator translationAnimator = ObjectAnimator.ofPropertyValuesHolder(target, alphaAnimator, flipAnimator);
translationAnimator.setDuration(duration);
translationAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
// // faster
// translationAnimator.setInterpolator(new AccelerateInterpolator());
// // slower
// translationAnimator.setInterpolator(new DecelerateInterpolator());
// // fast->slow->fast
// translationAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
// repeat translationAnimator
translationAnimator.setRepeatCount(ObjectAnimator.INFINITE);
// Set all animation to animatorList
animatorList.add(translationAnimator);
final AnimatorSet animatorSet = new AnimatorSet();
// Set animatorList to animatorSet
animatorSet.playSequentially(animatorList);
// Start Animation
animatorSet.start();
}
19
Source : ExpansionHeader.java
with GNU General Public License v3.0
from TachibanaGeneralLaboratories
with GNU General Public License v3.0
from TachibanaGeneralLaboratories
private ObjectAnimator createRotateAnimator(View target, float from, float to) {
ObjectAnimator animator = ObjectAnimator.ofFloat(target, "rotation", from, to);
animator.setDuration(animationDuration);
animator.setInterpolator(new LinearInterpolator());
return animator;
}
19
Source : ItemAnimator.java
with Apache License 2.0
from SysdataSpA
with Apache License 2.0
from SysdataSpA
@Override
public boolean animateMove(final ViewHolder holder, int fromX, int fromY, int toX, int toY) {
endAnimation(holder);
final int deltaX = toX - fromX;
final int deltaY = toY - fromY;
final long moveDuration = getMoveDuration();
if (deltaX == 0 && deltaY == 0) {
dispatchMoveFinished(holder);
return false;
}
final View view = holder.itemView;
final float prevTranslationX = view.getTranslationX();
final float prevTranslationY = view.getTranslationY();
view.setTranslationX(-deltaX);
view.setTranslationY(-deltaY);
final ObjectAnimator moveAnimator;
if (deltaX != 0 && deltaY != 0) {
final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f);
final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f);
moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX, moveY);
} else if (deltaX != 0) {
final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f);
moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX);
} else {
final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f);
moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveY);
}
moveAnimator.setDuration(moveDuration);
moveAnimator.setInterpolator(new FastOutSlowInInterpolator());
moveAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
dispatchMoveStarting(holder);
}
@Override
public void onAnimationEnd(Animator animator) {
animator.removeAllListeners();
mAnimators.remove(holder);
view.setTranslationX(prevTranslationX);
view.setTranslationY(prevTranslationY);
dispatchMoveFinished(holder);
}
});
mMoveAnimatorsList.add(moveAnimator);
mAnimators.put(holder, moveAnimator);
return true;
}
19
Source : SimpleTooltip.java
with GNU General Public License v3.0
from stingle
with GNU General Public License v3.0
from stingle
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void startAnimation() {
final String property = mGravity == Gravity.TOP || mGravity == Gravity.BOTTOM ? "translationY" : "translationX";
final ObjectAnimator anim1 = ObjectAnimator.ofFloat(mContentLayout, property, -mAnimationPadding, mAnimationPadding);
anim1.setDuration(mAnimationDuration);
anim1.setInterpolator(new AccelerateDecelerateInterpolator());
final ObjectAnimator anim2 = ObjectAnimator.ofFloat(mContentLayout, property, mAnimationPadding, -mAnimationPadding);
anim2.setDuration(mAnimationDuration);
anim2.setInterpolator(new AccelerateDecelerateInterpolator());
mAnimator = new AnimatorSet();
mAnimator.playSequentially(anim1, anim2);
mAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (!dismissed && isShowing()) {
animation.start();
}
}
});
mAnimator.start();
}
19
Source : ViewAnimateUtils.java
with Apache License 2.0
from starscryer
with Apache License 2.0
from starscryer
public static void animateColorChange(View view, int fromColor, int toColor, int duration, Animator.AnimatorListener listener) {
if (view.getWindowToken() == null) {
return;
}
AnimatorSet animation = new AnimatorSet();
ObjectAnimator colorAnimator = ObjectAnimator.ofInt(view, COLOR_PROPERTY, fromColor, toColor);
colorAnimator.setEvaluator(new ArgbEvaluator());
colorAnimator.setDuration(duration);
if (listener != null)
animation.addListener(listener);
animation.play(colorAnimator);
animation.start();
}
19
Source : AndroidLikeButton.java
with Apache License 2.0
from sparrow007
with Apache License 2.0
from sparrow007
/* This view extends the framelayout and i set click listener in the init() method so when some one click on the
* view then using this method we perform the animation in appropiate manner
* */
@Override
public void onClick(View view) {
isChecked = !isChecked;
star.setImageBitmap(isChecked ? likeBitmap : unlikeBitmap);
if (animatorSet != null) {
animatorSet.cancel();
}
if (isChecked) {
star.animate().cancel();
star.setScaleX(0);
star.setScaleY(0);
androidCircleView.setInnerCircleRadiusProgress(0);
androidCircleView.setProgress(0);
androidDotView.setCurrentProgress(0);
animatorSet = new AnimatorSet();
ObjectAnimator outerCircleAnimator = ObjectAnimator.ofFloat(androidCircleView, "Progress", 0.1f, 1f);
outerCircleAnimator.setDuration(250);
outerCircleAnimator.setInterpolator(new DecelerateInterpolator());
ObjectAnimator innerCircleAnimator = ObjectAnimator.ofFloat(androidCircleView, "InnerCircleRadiusProgress", 0.1f, 1f);
innerCircleAnimator.setDuration(200);
innerCircleAnimator.setStartDelay(200);
innerCircleAnimator.setInterpolator(new DecelerateInterpolator());
ObjectAnimator starScaleYAnimator = ObjectAnimator.ofFloat(star, ImageView.SCALE_Y, 0.2f, 1f);
starScaleYAnimator.setDuration(350);
starScaleYAnimator.setStartDelay(250);
starScaleYAnimator.setInterpolator(new OvershootInterpolator());
ObjectAnimator starScaleXAnimator = ObjectAnimator.ofFloat(star, ImageView.SCALE_X, 0.2f, 1f);
starScaleXAnimator.setDuration(350);
starScaleXAnimator.setStartDelay(250);
starScaleXAnimator.setInterpolator(new OvershootInterpolator());
ObjectAnimator dotsAnimator = ObjectAnimator.ofFloat(androidDotView, "CurrentProgress", 0.1f, 1f);
dotsAnimator.setDuration(900);
dotsAnimator.setStartDelay(50);
dotsAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
animatorSet.playTogether(outerCircleAnimator, innerCircleAnimator, starScaleYAnimator, starScaleXAnimator, dotsAnimator);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationCancel(Animator animation) {
androidCircleView.setInnerCircleRadiusProgress(0);
androidCircleView.setProgress(0);
androidDotView.setCurrentProgress(0);
star.setScaleX(1);
star.setScaleY(1);
}
});
animatorSet.start();
if (onLikeEventListener != null) {
onLikeEventListener.onLikeClicked(AndroidLikeButton.this);
}
} else {
if (onLikeEventListener != null) {
onLikeEventListener.onUnlikeClicked(AndroidLikeButton.this);
}
}
}
19
Source : WhatsappCameraActivity.java
with MIT License
from spaceoamit
with MIT License
from spaceoamit
private void scaleDownAnimation() {
ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(imgCapture, "scaleX", 1f);
ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(imgCapture, "scaleY", 1f);
scaleDownX.setDuration(100);
scaleDownY.setDuration(100);
AnimatorSet scaleDown = new AnimatorSet();
scaleDown.play(scaleDownX).with(scaleDownY);
scaleDownX.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
View p = (View) imgCapture.getParent();
p.invalidate();
}
});
scaleDown.start();
}
19
Source : WhatsappCameraActivity.java
with MIT License
from spaceoamit
with MIT License
from spaceoamit
private void scaleUpAnimation() {
ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(imgCapture, "scaleX", 2f);
ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(imgCapture, "scaleY", 2f);
scaleDownX.setDuration(100);
scaleDownY.setDuration(100);
AnimatorSet scaleDown = new AnimatorSet();
scaleDown.play(scaleDownX).with(scaleDownY);
scaleDownX.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
View p = (View) imgCapture.getParent();
p.invalidate();
}
});
scaleDown.start();
}
19
Source : MenusFragment.java
with Apache License 2.0
from sougata-chatterjee
with Apache License 2.0
from sougata-chatterjee
private void createCustomAnimation() {
AnimatorSet set = new AnimatorSet();
ObjectAnimator scaleOutX = ObjectAnimator.ofFloat(menuGreen.getMenuIconView(), "scaleX", 1.0f, 0.2f);
ObjectAnimator scaleOutY = ObjectAnimator.ofFloat(menuGreen.getMenuIconView(), "scaleY", 1.0f, 0.2f);
ObjectAnimator scaleInX = ObjectAnimator.ofFloat(menuGreen.getMenuIconView(), "scaleX", 0.2f, 1.0f);
ObjectAnimator scaleInY = ObjectAnimator.ofFloat(menuGreen.getMenuIconView(), "scaleY", 0.2f, 1.0f);
scaleOutX.setDuration(50);
scaleOutY.setDuration(50);
scaleInX.setDuration(150);
scaleInY.setDuration(150);
scaleInX.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
menuGreen.getMenuIconView().setImageResource(menuGreen.isOpened() ? R.drawable.ic_close : R.drawable.ic_star);
}
});
set.play(scaleOutX).with(scaleOutY);
set.play(scaleInX).with(scaleInY).after(scaleOutX);
set.setInterpolator(new OvershootInterpolator(2));
menuGreen.setIconToggleAnimatorSet(set);
}
See More Examples