@Override public void end() { Animator a = mAnimator.get(); if (a != null) { a.end(); } }
@Override public void cancel() { Animator a = mAnimator.get(); if (a != null) { a.cancel(); } }
@Override public void setInterpolator(Interpolator value) { Animator a = mAnimator.get(); if (a != null) { a.setInterpolator(value); } }
@Override public void addListener(final AnimatorListener listener) { Animator a = mAnimator.get(); if (a == null) { return; } if (listener == null) { a.addListener(null); return; } a.addListener( new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { listener.onAnimationStart(); } @Override public void onAnimationEnd(Animator animation) { listener.onAnimationEnd(); } @Override public void onAnimationCancel(Animator animation) { listener.onAnimationCancel(); } @Override public void onAnimationRepeat(Animator animation) { listener.onAnimationRepeat(); } }); }
@Override public void setDuration(int duration) { Animator a = mAnimator.get(); if (a != null) { a.setDuration(duration); } }
@Override public void start() { Animator a = mAnimator.get(); if (a != null) { a.start(); } }
@Override public void setupEndValues() { Animator a = mAnimator.get(); if (a != null) { a.setupEndValues(); } }
@Override public void onMovedToScrapHeap(View view) { Animator animator = mActiveAnimators.get(view); if (animator != null) { animator.cancel(); } }
/** * Animates all the cards displayed out of the screen. The total skipped classes text view and the * add subject button will also be animated to a 0 alpha. * * @return the estimated duration of the whole animation */ private long animateClearAll() { final long betweenCardsDelay = 80; int size = mSubjectCards.size(); for (int i = 0; i < size; i++) mSubjectCards.get(i).swipeRight(0, betweenCardsDelay * i); long halfDuration = (betweenCardsDelay * size) / 2 + 120; Animator anmtr = AnimatorCreationUtil.ofFloat(mAddButton, "alpha", halfDuration, null, 0); anmtr.setStartDelay(halfDuration); anmtr.start(); anmtr = AnimatorCreationUtil.ofFloat(mTotalAbsencesTextView, "alpha", halfDuration, null, 0); anmtr.setStartDelay(halfDuration); anmtr.start(); return 2 * halfDuration; }
public void setVisibility(final int visibility) { if (visibility == View.VISIBLE && (getVisibility() != View.VISIBLE || animator != null)) { if (animator != null) animator.cancel(); if (inAnim != AnimUtils.Style.None) { animator = AnimUtils.animateIn( this, inAnim, new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator a) { animator = null; clearAnimation(); } }); } super.setVisibility(visibility); } else if (visibility != View.VISIBLE && (getVisibility() == View.VISIBLE || animator != null)) { if (animator != null) animator.cancel(); if (outAnim == AnimUtils.Style.None) { super.setVisibility(visibility); return; } animator = AnimUtils.animateOut( this, outAnim, new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator a) { if (((ValueAnimator) a).getAnimatedFraction() == 1) RangeSeekBar.super.setVisibility(visibility); animator = null; clearAnimation(); } }); } }
@Override public void setupStartValues() { super.setupStartValues(); Animator a = mAnimator.get(); if (a != null) a.setupStartValues(); }
@Override public void addListener(AnimatorListener listener) { Animator a = mAnimator.get(); if (a != null) a.addListener(listener); }
@Override public void cancel() { super.cancel(); Animator a = mAnimator.get(); if (a != null) a.cancel(); }
@Override public void start() { super.start(); Animator a = mAnimator.get(); if (a != null) a.start(); }
@Override public ArcAnimator setDuration(long duration) { Animator a = mAnimator.get(); if (a != null) a.setDuration(duration); return this; }
@Override public boolean isRunning() { Animator a = mAnimator.get(); return a != null && a.isRunning(); }
@Override public void setStartDelay(long startDelay) { Animator a = mAnimator.get(); if (a != null) a.setStartDelay(startDelay); }
private void zoomImageFromThumb(View thumbView, int position) { // If there's an animation in progress, cancel it immediately and // proceed with this one. if (mCurrentAnimator != null) { mCurrentAnimator.cancel(); } viewPager = (HackyViewPager) ((Activity) mContext).findViewById(R.id.expanded_image); viewPager.setAdapter(new SamplePagerAdapter(mThumbIds, mContext)); viewPager.setCurrentItem(position); // Calculate the starting and ending bounds for the zoomed-in image. // This step // involves lots of math. Yay, math. startBounds = new Rect(); final Rect finalBounds = new Rect(); final Point globalOffset = new Point(); // The start bounds are the global visible rectangle of the thumbnail, // and the // final bounds are the global visible rectangle of the container view. // Also // set the container view's offset as the origin for the bounds, since // that's // the origin for the positioning animation properties (X, Y). thumbView.getGlobalVisibleRect(startBounds); ((Activity) mContext) .findViewById(R.id.container) .getGlobalVisibleRect(finalBounds, globalOffset); startBounds.offset(-globalOffset.x, -globalOffset.y); finalBounds.offset(-globalOffset.x, -globalOffset.y); // Adjust the start bounds to be the same aspect ratio as the final // bounds using the // "center crop" technique. This prevents undesirable stretching during // the animation. // Also calculate the start scaling factor (the end scaling factor is // always 1.0). if ((float) finalBounds.width() / finalBounds.height() > (float) startBounds.width() / startBounds.height()) { // Extend start bounds horizontally startScale = (float) startBounds.height() / finalBounds.height(); float startWidth = startScale * finalBounds.width(); float deltaWidth = (startWidth - startBounds.width()) / 2; startBounds.left -= deltaWidth; startBounds.right += deltaWidth; } else { // Extend start bounds vertically startScale = (float) startBounds.width() / finalBounds.width(); float startHeight = startScale * finalBounds.height(); float deltaHeight = (startHeight - startBounds.height()) / 2; startBounds.top -= deltaHeight; startBounds.bottom += deltaHeight; } // show the zoomed-in view. When the animation // begins, // it will position the zoomed-in view in the place of the thumbnail. viewPager.setVisibility(View.VISIBLE); // Set the pivot point for SCALE_X and SCALE_Y transformations to the // top-left corner of // the zoomed-in view (the default is the center of the view). AnimatorSet animSet = new AnimatorSet(); animSet.setDuration(1); animSet .play(ObjectAnimator.ofFloat(viewPager, "pivotX", 0f)) .with(ObjectAnimator.ofFloat(viewPager, "pivotY", 0f)) .with(ObjectAnimator.ofFloat(viewPager, "alpha", 1.0f)); animSet.start(); // Construct and run the parallel animation of the four translation and // scale properties // (X, Y, SCALE_X, and SCALE_Y). AnimatorSet set = new AnimatorSet(); ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(((MainActivity) mContext).gridView, "alpha", 1.0f, 0.f); ObjectAnimator animatorX = ObjectAnimator.ofFloat(viewPager, "x", startBounds.left, finalBounds.left); ObjectAnimator animatorY = ObjectAnimator.ofFloat(viewPager, "y", startBounds.top, finalBounds.top); ObjectAnimator animatorScaleX = ObjectAnimator.ofFloat(viewPager, "scaleX", startScale, 1f); ObjectAnimator animatorScaleY = ObjectAnimator.ofFloat(viewPager, "scaleY", startScale, 1f); set.play(alphaAnimator) .with(animatorX) .with(animatorY) .with(animatorScaleX) .with(animatorScaleY); set.setDuration(mShortAnimationDuration); set.setInterpolator(new DecelerateInterpolator()); set.addListener( new AnimatorListenerAdapter() { public void onAnimationEnd(Animator animation) { mCurrentAnimator = null; } public void onAnimationCancel(Animator animation) { mCurrentAnimator = null; } }); set.start(); mCurrentAnimator = set; // Upon clicking the zoomed-in image, it should zoom back down to the // original bounds // and show the thumbnail instead of the expanded image. startScaleFinal = startScale; }
@Override public long getDuration() { Animator a = mAnimator.get(); return a == null ? 0 : a.getDuration(); }
@Override public void onResume() { super.onResume(); // load animations mAnimVcardOut = AnimatorInflater.loadAnimator(this, R.animator.fade_out); mAnimVerticalLeftIn = AnimatorInflater.loadAnimator(this, R.animator.fade_in); mAnimVerticalRightIn = AnimatorInflater.loadAnimator(this, R.animator.fade_in); mAnimVcardOut.addListener(new HideAfterAnimatorListener(mContainerVcard)); mAnimVerticalLeftIn.addListener(new DisplayBeforeAnimatorListener(mVerticalLeft)); mAnimVerticalRightIn.addListener(new DisplayBeforeAnimatorListener(mVerticalRight)); if (!mPrefs.getBoolean(Constants.PREF_SIDE_USED, false)) { final Animator animatorHintLeft = AnimatorInflater.loadAnimator(this, R.animator.side_hint); final Animator animatorHintRight = AnimatorInflater.loadAnimator(this, R.animator.side_hint); animatorHintLeft.addListener(new BothEndsAnimatorListener(mHintLeft)); animatorHintRight.addListener(new BothEndsAnimatorListener(mHintRight)); animatorHintLeft.setTarget(mHintLeft); animatorHintRight.setTarget(mHintRight); animatorHintLeft.start(); animatorHintRight.start(); } }
@Override public void end() { super.end(); Animator a = mAnimator.get(); if (a != null) a.end(); }
public void startAnimation() { createAnimation(); animation.start(); }