use of com.nineoldandroids.animation.Animator in project cw-omnibus by commonsguy.
the class ViewPropertyAnimatorHC method cancel.
@Override
public void cancel() {
if (mAnimatorMap.size() > 0) {
HashMap<Animator, PropertyBundle> mAnimatorMapCopy = (HashMap<Animator, PropertyBundle>) mAnimatorMap.clone();
Set<Animator> animatorSet = mAnimatorMapCopy.keySet();
for (Animator runningAnim : animatorSet) {
runningAnim.cancel();
}
}
mPendingAnimations.clear();
View v = mView.get();
if (v != null) {
v.removeCallbacks(mAnimationStarter);
}
}
use of com.nineoldandroids.animation.Animator in project cw-omnibus by commonsguy.
the class ViewPropertyAnimatorPreHC method animatePropertyBy.
/**
* Utility function, called by animateProperty() and animatePropertyBy(), which handles the
* details of adding a pending animation and posting the request to start the animation.
*
* @param constantName The specifier for the property being animated
* @param startValue The starting value of the property
* @param byValue The amount by which the property will change
*/
private void animatePropertyBy(int constantName, float startValue, float byValue) {
// First, cancel any existing animations on this property
if (mAnimatorMap.size() > 0) {
Animator animatorToCancel = null;
Set<Animator> animatorSet = mAnimatorMap.keySet();
for (Animator runningAnim : animatorSet) {
PropertyBundle bundle = mAnimatorMap.get(runningAnim);
if (bundle.cancel(constantName)) {
// there can only ever be one such animation running.
if (bundle.mPropertyMask == NONE) {
// the animation is no longer changing anything - cancel it
animatorToCancel = runningAnim;
break;
}
}
}
if (animatorToCancel != null) {
animatorToCancel.cancel();
}
}
NameValuesHolder nameValuePair = new NameValuesHolder(constantName, startValue, byValue);
mPendingAnimations.add(nameValuePair);
View v = mView.get();
if (v != null) {
v.removeCallbacks(mAnimationStarter);
v.post(mAnimationStarter);
}
}
use of com.nineoldandroids.animation.Animator in project cw-omnibus by commonsguy.
the class ViewPropertyAnimatorPreHC method cancel.
@Override
public void cancel() {
if (mAnimatorMap.size() > 0) {
HashMap<Animator, PropertyBundle> mAnimatorMapCopy = (HashMap<Animator, PropertyBundle>) mAnimatorMap.clone();
Set<Animator> animatorSet = mAnimatorMapCopy.keySet();
for (Animator runningAnim : animatorSet) {
runningAnim.cancel();
}
}
mPendingAnimations.clear();
View v = mView.get();
if (v != null) {
v.removeCallbacks(mAnimationStarter);
}
}
use of com.nineoldandroids.animation.Animator in project PhotoPicker by donglua.
the class ImagePagerFragment method runExitAnimation.
/**
* The exit animation is basically a reverse of the enter animation, except that if
* the orientation has changed we simply scale the picture back into the center of
* the screen.
*
* @param endAction This action gets run after the animation completes (this is
* when we actually switch activities)
*/
public void runExitAnimation(final Runnable endAction) {
if (!getArguments().getBoolean(ARG_HAS_ANIM, false) || !hasAnim) {
endAction.run();
return;
}
final long duration = ANIM_DURATION;
// Animate image back to thumbnail size/location
ViewPropertyAnimator.animate(mViewPager).setDuration(duration).setInterpolator(new AccelerateInterpolator()).scaleX((float) thumbnailWidth / mViewPager.getWidth()).scaleY((float) thumbnailHeight / mViewPager.getHeight()).translationX(thumbnailLeft).translationY(thumbnailTop).setListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
endAction.run();
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
// Fade out background
ObjectAnimator bgAnim = ObjectAnimator.ofInt(mViewPager.getBackground(), "alpha", 0);
bgAnim.setDuration(duration);
bgAnim.start();
// Animate a color filter to take the image back to grayscale,
// in parallel with the image scaling and moving into place.
ObjectAnimator colorizer = ObjectAnimator.ofFloat(ImagePagerFragment.this, "saturation", 1, 0);
colorizer.setDuration(duration);
colorizer.start();
}
use of com.nineoldandroids.animation.Animator in project Meizhi by drakeet.
the class FloatView method translationX.
public void translationX(float fromX, float toX, float formAlpha, final float toAlpha) {
ObjectAnimator a1 = ObjectAnimator.ofFloat(rootView, "alpha", formAlpha, toAlpha);
ObjectAnimator a2 = ObjectAnimator.ofFloat(rootView, "translationX", fromX, toX);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(a1, a2);
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
if (toAlpha == 0) {
HeadsUpManager.getInstant(getContext()).dismiss();
cutDown = -1;
if (velocityTracker != null) {
velocityTracker.clear();
try {
velocityTracker.recycle();
} catch (IllegalStateException e) {
}
}
}
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
animatorSet.start();
}
Aggregations