コード例 #1
0
 @Override
 public void end() {
   Animator a = mAnimator.get();
   if (a != null) {
     a.end();
   }
 }
コード例 #2
0
 @Override
 public void cancel() {
   Animator a = mAnimator.get();
   if (a != null) {
     a.cancel();
   }
 }
コード例 #3
0
 @Override
 public void setInterpolator(Interpolator value) {
   Animator a = mAnimator.get();
   if (a != null) {
     a.setInterpolator(value);
   }
 }
コード例 #4
0
  @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();
          }
        });
  }
コード例 #5
0
 @Override
 public void setDuration(int duration) {
   Animator a = mAnimator.get();
   if (a != null) {
     a.setDuration(duration);
   }
 }
コード例 #6
0
 @Override
 public void start() {
   Animator a = mAnimator.get();
   if (a != null) {
     a.start();
   }
 }
コード例 #7
0
 @Override
 public void setupEndValues() {
   Animator a = mAnimator.get();
   if (a != null) {
     a.setupEndValues();
   }
 }
コード例 #8
0
 @Override
 public void onMovedToScrapHeap(View view) {
   Animator animator = mActiveAnimators.get(view);
   if (animator != null) {
     animator.cancel();
   }
 }
コード例 #9
0
  /**
   * 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;
  }
コード例 #10
0
ファイル: RangeSeekBar.java プロジェクト: Sai-Teja/Carbon
 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();
               }
             });
   }
 }
コード例 #11
0
ファイル: ArcAnimator.java プロジェクト: chonamdoo/Animation
 @Override
 public void setupStartValues() {
   super.setupStartValues();
   Animator a = mAnimator.get();
   if (a != null) a.setupStartValues();
 }
コード例 #12
0
ファイル: ArcAnimator.java プロジェクト: chonamdoo/Animation
 @Override
 public void addListener(AnimatorListener listener) {
   Animator a = mAnimator.get();
   if (a != null) a.addListener(listener);
 }
コード例 #13
0
ファイル: ArcAnimator.java プロジェクト: chonamdoo/Animation
 @Override
 public void cancel() {
   super.cancel();
   Animator a = mAnimator.get();
   if (a != null) a.cancel();
 }
コード例 #14
0
ファイル: ArcAnimator.java プロジェクト: chonamdoo/Animation
 @Override
 public void start() {
   super.start();
   Animator a = mAnimator.get();
   if (a != null) a.start();
 }
コード例 #15
0
ファイル: ArcAnimator.java プロジェクト: chonamdoo/Animation
 @Override
 public ArcAnimator setDuration(long duration) {
   Animator a = mAnimator.get();
   if (a != null) a.setDuration(duration);
   return this;
 }
コード例 #16
0
ファイル: ArcAnimator.java プロジェクト: chonamdoo/Animation
 @Override
 public boolean isRunning() {
   Animator a = mAnimator.get();
   return a != null && a.isRunning();
 }
コード例 #17
0
ファイル: ArcAnimator.java プロジェクト: chonamdoo/Animation
 @Override
 public void setStartDelay(long startDelay) {
   Animator a = mAnimator.get();
   if (a != null) a.setStartDelay(startDelay);
 }
コード例 #18
0
  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;
  }
コード例 #19
0
ファイル: ArcAnimator.java プロジェクト: chonamdoo/Animation
 @Override
 public long getDuration() {
   Animator a = mAnimator.get();
   return a == null ? 0 : a.getDuration();
 }
コード例 #20
0
  @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();
    }
  }
コード例 #21
0
ファイル: ArcAnimator.java プロジェクト: chonamdoo/Animation
 @Override
 public void end() {
   super.end();
   Animator a = mAnimator.get();
   if (a != null) a.end();
 }
コード例 #22
0
 public void startAnimation() {
   createAnimation();
   animation.start();
 }