use of android.animation.Animator.AnimatorListener in project RecyclerViewAnimator by dkmeteor.
the class StandUpIn method startAnimation.
@Override
public void startAnimation(final ViewHolder holder, long duration, final BaseItemAnimator animator) {
System.out.println("startAnimation");
float x = (holder.itemView.getWidth() - holder.itemView.getPaddingLeft() - holder.itemView.getPaddingRight()) / 2 + holder.itemView.getPaddingLeft();
float y = holder.itemView.getHeight() - holder.itemView.getPaddingBottom();
AnimatorSet set = new AnimatorSet();
set.playTogether(ObjectAnimator.ofFloat(holder.itemView, "pivotX", x, x, x, x, x), ObjectAnimator.ofFloat(holder.itemView, "pivotY", y, y, y, y, y), ObjectAnimator.ofFloat(holder.itemView, "rotationX", 90, 55, -30, 15, -15, 0));
set.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animator animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animator animation) {
animator.dispatchAddFinished(holder);
animator.mAddAnimations.remove(holder);
animator.dispatchFinishedWhenDone();
}
@Override
public void onAnimationCancel(Animator animation) {
// TODO Auto-generated method stub
}
});
set.setStartDelay(mDelay * mDelayCount);
set.setDuration(animator.getAddDuration());
set.start();
animator.mAddAnimations.add(holder);
}
use of android.animation.Animator.AnimatorListener in project RecyclerViewAnimator by dkmeteor.
the class DropOut method startAnimation.
@Override
public void startAnimation(final ViewHolder holder, long duration, final BaseItemAnimator animator) {
ViewCompat.animate(holder.itemView).cancel();
AnimatorSet set = new AnimatorSet();
int abs = Math.random() > 0.5 ? -1 : 1;
ObjectAnimator objectAnimatorAnimatorR = ObjectAnimator.ofFloat(holder.itemView, "rotation", abs * 30, abs * 90);
ObjectAnimator objectAnimatorAnimatorT = ObjectAnimator.ofFloat(holder.itemView, "translationY", 0, ViewUtils.getScreenHeight());
set.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
animator.dispatchAddFinished(holder);
animator.mAddAnimations.remove(holder);
animator.dispatchFinishedWhenDone();
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
set.playTogether(objectAnimatorAnimatorR, objectAnimatorAnimatorT);
set.setStartDelay(mDelay * mDelayCount);
set.setDuration(animator.getAddDuration());
set.start();
animator.mAddAnimations.add(holder);
}
use of android.animation.Animator.AnimatorListener in project RecyclerViewAnimator by dkmeteor.
the class FlipHorizonIn method startAnimation.
@Override
public void startAnimation(final ViewHolder holder, long duration, final BaseItemAnimator animator) {
ViewCompat.animate(holder.itemView).cancel();
AnimatorSet set = new AnimatorSet();
set.playTogether(ObjectAnimator.ofFloat(holder.itemView, "rotationY", 90, -15, 15, 0), ObjectAnimator.ofFloat(holder.itemView, "alpha", 0.25f, 0.5f, 0.75f, 1));
set.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animator animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animator animation) {
animator.dispatchAddFinished(holder);
animator.mAddAnimations.remove(holder);
animator.dispatchFinishedWhenDone();
}
@Override
public void onAnimationCancel(Animator animation) {
// TODO Auto-generated method stub
}
});
set.setStartDelay(mDelay * mDelayCount);
set.setDuration(animator.getAddDuration());
set.start();
animator.mAddAnimations.add(holder);
}
use of android.animation.Animator.AnimatorListener in project KJFrameForAndroid by kymjs.
the class AnimationExecutor method animateView.
public void animateView(int duration, int fromY, int toY) {
if (mCurtainViewController.getSlidingItem().getMaxDuration() > CurtainViewController.DEFAULT_INT) {
duration = Math.min(duration, mCurtainViewController.getSlidingItem().getMaxDuration());
}
// 移动方式
final MovingType movingType = toY == 0 ? MovingType.BOTTOM_TO_TOP : MovingType.TOP_TO_BOTTOM;
String propertyName = "";
if (mCurtainViewController.getSlidingItem().getSlidingType() == SlidingType.SIZE) {
propertyName = "viewHeight";
} else if (mCurtainViewController.getSlidingItem().getSlidingType() == SlidingType.MOVE) {
propertyName = "viewTop";
}
ValueAnimator sizeAnim = ObjectAnimator.ofInt(mCurtainViewController, propertyName, fromY, toY);
sizeAnim.setDuration(duration);
sizeAnim.addListener(new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
if (movingType == AnimationExecutor.MovingType.BOTTOM_TO_TOP) {
if (mCurtainViewController.getSlidingItem().getOnSwitchListener() != null) {
mCurtainViewController.getSlidingItem().getOnSwitchListener().onCollapsed();
}
} else if (movingType == AnimationExecutor.MovingType.TOP_TO_BOTTOM) {
if (mCurtainViewController.getSlidingItem().getOnSwitchListener() != null) {
mCurtainViewController.getSlidingItem().getOnSwitchListener().onExpanded();
}
}
}
@Override
public void onAnimationCancel(Animator animation) {
}
});
sizeAnim.start();
}
use of android.animation.Animator.AnimatorListener in project android_frameworks_base by ParanoidAndroid.
the class Tweener method to.
public static Tweener to(Object object, long duration, Object... vars) {
long delay = 0;
AnimatorUpdateListener updateListener = null;
AnimatorListener listener = null;
TimeInterpolator interpolator = null;
// Iterate through arguments and discover properties to animate
ArrayList<PropertyValuesHolder> props = new ArrayList<PropertyValuesHolder>(vars.length / 2);
for (int i = 0; i < vars.length; i += 2) {
if (!(vars[i] instanceof String)) {
throw new IllegalArgumentException("Key must be a string: " + vars[i]);
}
String key = (String) vars[i];
Object value = vars[i + 1];
if ("simultaneousTween".equals(key)) {
// TODO
} else if ("ease".equals(key)) {
// TODO: multiple interpolators?
interpolator = (TimeInterpolator) value;
} else if ("onUpdate".equals(key) || "onUpdateListener".equals(key)) {
updateListener = (AnimatorUpdateListener) value;
} else if ("onComplete".equals(key) || "onCompleteListener".equals(key)) {
listener = (AnimatorListener) value;
} else if ("delay".equals(key)) {
delay = ((Number) value).longValue();
} else if ("syncWith".equals(key)) {
// TODO
} else if (value instanceof float[]) {
props.add(PropertyValuesHolder.ofFloat(key, ((float[]) value)[0], ((float[]) value)[1]));
} else if (value instanceof int[]) {
props.add(PropertyValuesHolder.ofInt(key, ((int[]) value)[0], ((int[]) value)[1]));
} else if (value instanceof Number) {
float floatValue = ((Number) value).floatValue();
props.add(PropertyValuesHolder.ofFloat(key, floatValue));
} else {
throw new IllegalArgumentException("Bad argument for key \"" + key + "\" with value " + value.getClass());
}
}
// Re-use existing tween, if present
Tweener tween = sTweens.get(object);
ObjectAnimator anim = null;
if (tween == null) {
anim = ObjectAnimator.ofPropertyValuesHolder(object, props.toArray(new PropertyValuesHolder[props.size()]));
tween = new Tweener(anim);
sTweens.put(object, tween);
if (DEBUG)
Log.v(TAG, "Added new Tweener " + tween);
} else {
anim = sTweens.get(object).animator;
// Cancel all animators for given object
replace(props, object);
}
if (interpolator != null) {
anim.setInterpolator(interpolator);
}
// Update animation with properties discovered in loop above
anim.setStartDelay(delay);
anim.setDuration(duration);
if (updateListener != null) {
// There should be only one
anim.removeAllUpdateListeners();
anim.addUpdateListener(updateListener);
}
if (listener != null) {
// There should be only one.
anim.removeAllListeners();
anim.addListener(listener);
}
anim.addListener(mCleanupListener);
return tween;
}
Aggregations