private void doBackAnim(final View view) {
   ValueAnimator tmpAnimator =
       ObjectAnimator.ofFloat(view, "translationX", view.getTranslationX(), 0);
   tmpAnimator.setDuration(mBackAnimTime);
   tmpAnimator.setRepeatCount(0);
   tmpAnimator.start();
 }
  /** Pop alphabet */
  protected void popAlphabet() {
    if (mAlphabetList.size() < POP_LIMIT_NUM) {
      return;
    }
    backAlphabet(false); // first, back alphabet, and pop alphabet

    isPoped = true;
    changeTextColor(mCurrentSelection, false);
    isShowSelected = false;
    invalidate();

    int position;
    int halfMoveCount = (mMoveCount + 1) / 2;
    for (int i = 0; i < mMoveCount; i++) {
      position = mCurrentSelection - halfMoveCount + 1 + i;
      if (position >= 0 && position < getChildCount()) {
        View view = getChildAt(position);
        ValueAnimator tmpAnimator =
            ObjectAnimator.ofFloat(
                view,
                "translationX",
                view.getTranslationX(),
                -mMaxOffset * (float) Math.sin((i + 1) * Math.PI / (mMoveCount + 1)));
        // Math.sin((i + 1) * Math.PI / (mMoveCount + 2))区间是[0,1],如移动的字母数(mMoveCount=3),
        // 那么取sin曲线上5个点,1和5点无动画,只创建中间3点动画,值是0.7071、1.0、0.7071。
        tmpAnimator.setDuration(mPopAnimTime);
        tmpAnimator.setRepeatCount(0);
        tmpAnimator.setInterpolator(mInterpolator);
        tmpAnimator.start();
        mAnimMap.put(position, tmpAnimator);
      }
    }
  }
  private void startAnimation(final boolean isLeft, final boolean isOpen, boolean staticDuration) {
    mToOpen = isOpen;
    int total;
    if (isLeft) {
      mTargetView = mLeftDrawer;
      mStartLeft = mLeftDrawer.getLeft();
      total = mLeftDrawer.getWidth();
      mEndLeft = mToOpen ? 0 : -total;
    } else {
      mTargetView = mRightDrawer;
      mStartLeft = mRightDrawer.getLeft();
      total = mRightDrawer.getWidth();
      mEndLeft = mToOpen ? getWidth() - total : getWidth();
    }

    if (mStartLeft == mEndLeft) {
      // No need to animate
      updateDrawerSlide(mTargetView, mToOpen ? 1.0f : 0.0f);
      updateDrawerState(mTargetView, mToOpen ? STATE_OPEN : STATE_CLOSED);
      if (mToOpen) dispatchOnDrawerOpened(mTargetView);
      else dispatchOnDrawerClosed(mTargetView);
      return;
    }

    mAnimator.setDuration(
        staticDuration ? ANIMATE_TIME : ANIMATE_TIME * Math.abs(mStartLeft - mEndLeft) / total);

    mAnimator.start();
  }
  private void startUnCheckedAnimation() {
    ValueAnimator animator = ValueAnimator.ofFloat(0f, 1.0f);
    animator.setDuration(mAnimDuration);
    animator.setInterpolator(new LinearInterpolator());
    animator.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            mScaleVal = (float) animation.getAnimatedValue();
            mFloorColor = getGradientColor(mCheckedColor, COLOR_FLOOR_UNCHECKED, mScaleVal);
            postInvalidate();
          }
        });
    animator.start();

    ValueAnimator floorAnimator = ValueAnimator.ofFloat(1.0f, 0.8f, 1.0f);
    floorAnimator.setDuration(mAnimDuration);
    floorAnimator.setInterpolator(new LinearInterpolator());
    floorAnimator.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            mFloorScale = (float) animation.getAnimatedValue();
            postInvalidate();
          }
        });
    floorAnimator.start();
  }
Beispiel #5
0
  private void animateOut() {
    ValueAnimator animWidth = ValueAnimator.ofInt(zoomableImageView.getMeasuredWidth(), rect.right);
    animWidth.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int val = (Integer) valueAnimator.getAnimatedValue();
            ViewGroup.LayoutParams layoutParams = zoomableImageView.getLayoutParams();
            layoutParams.width = val;
            zoomableImageView.setLayoutParams(layoutParams);
          }
        });
    animWidth.setDuration(500);
    animWidth.start();

    ValueAnimator animHeight =
        ValueAnimator.ofInt(zoomableImageView.getMeasuredHeight(), rect.bottom);
    animHeight.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int val = (Integer) valueAnimator.getAnimatedValue();
            ViewGroup.LayoutParams layoutParams = zoomableImageView.getLayoutParams();
            layoutParams.height = val;
            zoomableImageView.setLayoutParams(layoutParams);
          }
        });
    animHeight.setDuration(500);
    animHeight.start();
    if (statusBarHeightCorrection > 0) {
      zoomableImageView.animate().y(-statusBarHeightCorrection).setDuration(300).start();
    }
    zoomableImageView.animate().alpha(0.0f).setDuration(500).start();
  }
 private void setCurrentPlayTimeByStateAndPlay(long[] tab, State mState) {
   switch (mState) {
     case ANIMATING_LINE_TO_DOT:
       mArrowToLineAnimatorSet.start();
       for (int i = 0; i < mArrowToLineAnimatorSet.getChildAnimations().size(); i++) {
         ((ValueAnimator) mArrowToLineAnimatorSet.getChildAnimations().get(i))
             .setCurrentPlayTime(tab[i]);
       }
       break;
     case ANIMATING_PROGRESS:
       mProgressAnimationSet.start();
       for (int i = 0; i < mProgressAnimationSet.getChildAnimations().size(); i++) {
         ((ValueAnimator) mProgressAnimationSet.getChildAnimations().get(i))
             .setCurrentPlayTime(tab[i]);
       }
       break;
     case ANIMATING_ERROR:
       mErrorAnimation.start();
       mErrorAnimation.setCurrentPlayTime(tab[0]);
       break;
     case ANIMATING_SUCCESS:
       mSuccessAnimation.start();
       mSuccessAnimation.setCurrentPlayTime(tab[0]);
       break;
   }
 }
  @Override
  public List<Animator> createAnimation() {
    List<Animator> animators = new ArrayList<>();
    float startX = getWidth() / 5;
    float startY = getWidth() / 5;
    for (int i = 0; i < 3; i++) {
      final int index = i;
      ValueAnimator translateXAnim =
          ValueAnimator.ofFloat(getWidth() / 2, getWidth() - startX, startX, getWidth() / 2);
      if (i == 1) {
        translateXAnim =
            ValueAnimator.ofFloat(getWidth() - startX, startX, getWidth() / 2, getWidth() - startX);
      } else if (i == 2) {
        translateXAnim = ValueAnimator.ofFloat(startX, getWidth() / 2, getWidth() - startX, startX);
      }
      ValueAnimator translateYAnim =
          ValueAnimator.ofFloat(startY, getHeight() - startY, getHeight() - startY, startY);
      if (i == 1) {
        translateYAnim =
            ValueAnimator.ofFloat(
                getHeight() - startY, getHeight() - startY, startY, getHeight() - startY);
      } else if (i == 2) {
        translateYAnim =
            ValueAnimator.ofFloat(
                getHeight() - startY, startY, getHeight() - startY, getHeight() - startY);
      }

      translateXAnim.setDuration(2000);
      translateXAnim.setInterpolator(new LinearInterpolator());
      translateXAnim.setRepeatCount(-1);
      translateXAnim.addUpdateListener(
          new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
              translateX[index] = (float) animation.getAnimatedValue();
              postInvalidate();
            }
          });
      translateXAnim.start();

      translateYAnim.setDuration(2000);
      translateYAnim.setInterpolator(new LinearInterpolator());
      translateYAnim.setRepeatCount(-1);
      translateYAnim.addUpdateListener(
          new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
              translateY[index] = (float) animation.getAnimatedValue();
              postInvalidate();
            }
          });
      translateYAnim.start();

      animators.add(translateXAnim);
      animators.add(translateYAnim);
    }
    return animators;
  }
  private void animateBothText() {
    ValueAnimator rotateAnimX = ObjectAnimator.ofFloat(bothText, "scaleX", 0f, 0.9f);
    rotateAnimX.setDuration(700);
    rotateAnimX.start();

    ValueAnimator rotateAnimY = ObjectAnimator.ofFloat(bothText, "scaleY", 0f, 0.9f);
    rotateAnimY.setDuration(700);
    rotateAnimY.start();
  }
 @Override
 public void onAnimationEnd(Animator animation) {
   if (stoppedMarquee || !isEnabled()) return;
   // run alternately.
   if (animation.equals(translateAnimator)) {
     // start suspend when finished translation.
     suspendAnimator.start();
   }
   if (animation.equals(suspendAnimator)) {
     // start translate animation when finished suspension.
     translateAnimator.start();
   }
 }
Beispiel #10
0
  private void smoothTo(int fromY, int toY) {
    ValueAnimator valueAnimator =
        ValueAnimator.ofObject(
            new TypeEvaluator<Integer>() {
              @Override
              public Integer evaluate(float fraction, Integer startValue, Integer endValue) {
                return startValue + (int) (fraction * (endValue - startValue));
              }
            },
            fromY,
            toY);

    valueAnimator.setInterpolator(null);
    valueAnimator.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
    valueAnimator.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            offsetTop = (int) animation.getAnimatedValue();
            requestLayout();
          }
        });

    valueAnimator.start();
  }
  /** 圆周运动 */
  public void circleRun(View view) {
    ValueAnimator animator = new ValueAnimator();
    animator.setDuration(10000);
    animator.setTarget(mCircleBall);
    animator.setObjectValues(new PointF(mCircleBall.getX(), mCircleBall.getY()));
    animator.setInterpolator(new LinearInterpolator());

    animator.setEvaluator(
        new TypeEvaluator<PointF>() {
          @Override
          public PointF evaluate(float fraction, PointF startValue, PointF endValue) {
            /** 设置圆的半径r为200px 圆点坐标为(x1,y1) 圆周上的点坐标的公式为 x = x1 + r * cos(wt) y = y1 + r * sin(wt) */
            PointF point = new PointF();
            point.x =
                (float) (mScreenWidth / 2 + 200 * Math.cos(Math.toRadians(360 * fraction - 90)));
            point.y = (float) (200 + 200 * Math.sin(Math.toRadians(360 * fraction - 90)));
            return point;
          }
        });
    //        //设置重复模式,RESTART为结束后重新开始,REVERSE为按原来的轨迹逆向返回
    // animator.setRepeatMode(Animation.RESTART);
    // 设置重复次数,INFINITE为无限
    animator.setRepeatCount(0);
    animator.start();
    animator.addUpdateListener(
        new AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            PointF point = (PointF) animation.getAnimatedValue();
            mCircleBall.setX(point.x);
            mCircleBall.setY(point.y);
          }
        });
  }
  @TargetApi(11)
  public ValueAnimator setSpeed(double progress, long duration, long startDelay) {
    if (progress <= 0)
      throw new IllegalArgumentException("Non-positive value specified as a speed.");

    if (progress > maxSpeed) progress = maxSpeed;

    ValueAnimator va =
        ValueAnimator.ofObject(
            new TypeEvaluator<Double>() {
              @Override
              public Double evaluate(float fraction, Double startValue, Double endValue) {
                return startValue + fraction * (endValue - startValue);
              }
            },
            Double.valueOf(getSpeed()),
            Double.valueOf(progress));

    va.setDuration(duration);
    va.setStartDelay(startDelay);
    va.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            Double value = (Double) animation.getAnimatedValue();
            if (value != null) setSpeed(value);
          }
        });
    va.start();
    return va;
  }
Beispiel #13
0
 public void animateToNaturalState() {
   if (mAcceptAnimator != null) {
     mAcceptAnimator.cancel();
   }
   mNeutralAnimator = ValueAnimator.ofFloat(0f, 1f);
   mNeutralAnimator.setDuration(CONSUMPTION_ANIMATION_DURATION);
   mNeutralAnimator.addUpdateListener(
       new AnimatorUpdateListener() {
         public void onAnimationUpdate(ValueAnimator animation) {
           final float percent = (Float) animation.getAnimatedValue();
           mOuterRingSize = (1 + (1 - percent) * OUTER_RING_GROWTH_FACTOR) * sPreviewSize;
           mInnerRingSize = (1 + (1 - percent) * INNER_RING_GROWTH_FACTOR) * sPreviewSize;
           if (mCellLayout != null) {
             mCellLayout.invalidate();
           }
         }
       });
   mNeutralAnimator.addListener(
       new AnimatorListenerAdapter() {
         @Override
         public void onAnimationEnd(Animator animation) {
           if (mCellLayout != null) {
             mCellLayout.hideFolderAccept(FolderRingAnimator.this);
           }
           if (mFolderIcon != null) {
             mFolderIcon.mPreviewBackground.setVisibility(VISIBLE);
           }
         }
       });
   mNeutralAnimator.start();
 }
Beispiel #14
0
  /**
   * call when you want to animate the highlight in or out - this is NOT dependant on {@link
   * #setChecked(boolean)} above because on scroll, among other layout calls, would trigger
   * setChecked many, many times
   *
   * @param checked
   */
  public void animateHighlight(boolean checked) {
    if (mHighlightAnimator != null && mHighlightAnimator.isRunning()) {
      mHighlightAnimator.cancel();
      mHighlightAnimator.removeAllUpdateListeners();
      mHighlightAnimator.removeAllListeners();
    }

    if (checked) {
      mHighlightAnimator = ValueAnimator.ofFloat(0, mMaxWidth);
    } else {
      mHighlightAnimator = ValueAnimator.ofFloat(mMaxWidth, 0);
    }

    mHighlightAnimator.setDuration(250);
    mHighlightAnimator.addListener(mHighlightAnimatorListener);
    mHighlightAnimator.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            mPinkPaint.setStrokeWidth((float) animation.getAnimatedValue());
            postInvalidate();
          }
        });
    mHighlightAnimator.start();
  }
Beispiel #15
0
 private void showCheck() {
   if (isAnim) {
     return;
   }
   isAnim = true;
   ValueAnimator va = ValueAnimator.ofFloat(0, 1).setDuration(animDurtion);
   va.setInterpolator(new LinearInterpolator());
   va.start();
   va.addUpdateListener(
       new ValueAnimator.AnimatorUpdateListener() {
         @Override
         public void onAnimationUpdate(ValueAnimator animation) {
           float value = (float) animation.getAnimatedValue(); // 0f ~ 1f
           radius = (int) (value * height * 0.37f + height * 0.125f);
           if (value >= 1) {
             isChecked = true;
             isAnim = false;
             if (listener != null) {
               listener.onCheckedChanged(AnimatedCheckBox.this, true);
             }
             showCorrect();
           }
           invalidate();
         }
       });
 }
 public void perform() {
   ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1);
   valueAnimator.setInterpolator(ANIMATION_INTERP);
   valueAnimator.addUpdateListener(this);
   valueAnimator.addListener(this);
   valueAnimator.start();
 }
  private void scrollToTarget(int target, final Runnable after) {
    int scrollX = getScrollX();
    if (scrollX == target) {
      if (after != null) after.run();
    } else {
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
        ValueAnimator realSmoothScrollAnimation =
            ValueAnimator.ofInt(scrollX, target).setDuration(500);
        realSmoothScrollAnimation.setInterpolator(new DecelerateInterpolator());
        realSmoothScrollAnimation.addUpdateListener(
            new ValueAnimator.AnimatorUpdateListener() {
              @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
              @Override
              public void onAnimationUpdate(ValueAnimator animation) {
                scrollTo((Integer) animation.getAnimatedValue(), 0);
              }
            });

        realSmoothScrollAnimation.addListener(
            new AnimatorListenerAdapter() {
              @Override
              public void onAnimationEnd(Animator animation) {
                if (after != null) after.run();
              }
            });
        realSmoothScrollAnimation.start();
      } else {
        smoothScrollTo(target, 0);
        if (after != null) after.run();
      }
    }
  }
Beispiel #18
0
 public void start(int a) {
   v = ValueAnimator.ofInt(0, 1000);
   v.setDuration(a);
   v.addUpdateListener(this);
   playing = true;
   v.start();
 }
Beispiel #19
0
  private void peak(boolean next, boolean once) {
    final float baseFlipDistance = mCurrentPageIndex * FLIP_DISTANCE_PER_PAGE;
    if (next) {
      mPeakAnim =
          ValueAnimator.ofFloat(baseFlipDistance, baseFlipDistance + FLIP_DISTANCE_PER_PAGE / 4);
    } else {
      mPeakAnim =
          ValueAnimator.ofFloat(baseFlipDistance, baseFlipDistance - FLIP_DISTANCE_PER_PAGE / 4);
    }
    mPeakAnim.setInterpolator(mPeakInterpolator);
    mPeakAnim.addUpdateListener(
        new AnimatorUpdateListener() {

          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            setFlipDistance((Float) animation.getAnimatedValue());
          }
        });
    mPeakAnim.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            endPeak();
          }
        });
    mPeakAnim.setDuration(PEAK_ANIM_DURATION);
    mPeakAnim.setRepeatMode(ValueAnimator.REVERSE);
    mPeakAnim.setRepeatCount(once ? 1 : ValueAnimator.INFINITE);
    mPeakAnim.start();
  }
 @Override
 public List<Animator> createAnimation() {
   List<Animator> animators = new ArrayList<>();
   float circleSpacing = 4;
   float radius = (getWidth() - circleSpacing * 2) / 6;
   int[] delays = new int[] {70, 140, 210};
   for (int i = 0; i < 3; i++) {
     final int index = i;
     ValueAnimator scaleAnim =
         ValueAnimator.ofFloat(getHeight() / 2, getHeight() / 2 - radius * 2, getHeight() / 2);
     scaleAnim.setDuration(600);
     scaleAnim.setRepeatCount(-1);
     scaleAnim.setStartDelay(delays[i]);
     scaleAnim.addUpdateListener(
         new ValueAnimator.AnimatorUpdateListener() {
           @Override
           public void onAnimationUpdate(ValueAnimator animation) {
             translateYFloats[index] = (float) animation.getAnimatedValue();
             postInvalidate();
           }
         });
     scaleAnim.start();
     animators.add(scaleAnim);
   }
   return animators;
 }
Beispiel #21
0
  private void fadeOutDragView() {
    mFadeOutAnim = new ValueAnimator();
    mFadeOutAnim.setDuration(150);
    mFadeOutAnim.setFloatValues(0f, 1f);
    mFadeOutAnim.removeAllUpdateListeners();
    mFadeOutAnim.addUpdateListener(
        new AnimatorUpdateListener() {
          public void onAnimationUpdate(ValueAnimator animation) {
            final float percent = (Float) animation.getAnimatedValue();

            float alpha = 1 - percent;
            mDropView.setAlpha(alpha);
          }
        });
    mFadeOutAnim.addListener(
        new AnimatorListenerAdapter() {
          public void onAnimationEnd(Animator animation) {
            if (mDropView != null) {
              mDragController.onDeferredEndDrag(mDropView);
            }
            mDropView = null;
            invalidate();
          }
        });
    mFadeOutAnim.start();
  }
Beispiel #22
0
 private void startAnimation(int temp_moveX, int temp_moveY) {
   Point startPoint = new Point(temp_moveX, temp_moveY);
   Point endPoint = new Point((int) centerX, (int) centerY);
   ValueAnimator anim = ValueAnimator.ofObject(new PointEvaluator(), startPoint, endPoint);
   anim.addUpdateListener(
       new ValueAnimator.AnimatorUpdateListener() {
         @Override
         public void onAnimationUpdate(ValueAnimator animation) {
           Point point = (Point) animation.getAnimatedValue();
           moveX = point.getX();
           moveY = point.getY();
           Log.i("CJT", moveX + "   ====   " + moveY);
           invalidate();
         }
       });
   anim.addListener(
       new AnimatorListenerAdapter() {
         @Override
         public void onAnimationEnd(Animator animation) {
           isAnim = false;
           VIEW_STATUS = VIEW_ACTION_STATUS;
           invalidate();
         }
       });
   anim.setInterpolator(new SpringInterpolator());
   anim.setDuration(1000);
   anim.start();
 }
  private void performDismiss() {
    // Animate the dismissed view to zero-height and then fire the dismiss callback.
    // This triggers layout on each animation frame; in the future we may want to do something
    // smarter and more performant.

    final ViewGroup.LayoutParams lp = mView.getLayoutParams();
    final int originalHeight = mView.getHeight();

    ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);

    animator.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            mCallbacks.onDismiss(mView, mToken);
            // Reset view presentation
            mView.setAlpha(1f);
            mView.setTranslationX(0);
            lp.height = originalHeight;
            mView.setLayoutParams(lp);
          }
        });

    animator.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator valueAnimator) {
            lp.height = (Integer) valueAnimator.getAnimatedValue();
            mView.setLayoutParams(lp);
          }
        });

    animator.start();
  }
  /**
   * Set the thumb to be in the normal/un-pressed state and calls invalidate() to redraw the canvas
   * to reflect the updated state.
   *
   * @param thumb the thumb to release
   */
  private void releasePin(final PinView thumb) {

    final float nearestTickX = mBar.getNearestTickCoordinate(thumb);
    thumb.setX(nearestTickX);
    int tickIndex = mBar.getNearestTickIndex(thumb);
    thumb.setXValue(getPinValue(tickIndex));

    if (mArePinsTemporary) {
      ValueAnimator animator = ValueAnimator.ofFloat(mExpandedPinRadius, 0);
      animator.addUpdateListener(
          new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
              mThumbRadiusDP = (Float) (animation.getAnimatedValue());
              thumb.setSize(
                  mThumbRadiusDP, mPinPadding - (mPinPadding * animation.getAnimatedFraction()));
              invalidate();
            }
          });
      animator.start();
    } else {
      invalidate();
    }

    thumb.release();
  }
 private void startAnim() {
   ValueAnimator valueAnimator =
       ValueAnimator.ofFloat(mActiveCircle.angle, mActiveCircle.angle + 360);
   valueAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
   valueAnimator.setDuration(2500);
   valueAnimator.setRepeatCount(Animation.INFINITE);
   valueAnimator.start();
   valueAnimator.addUpdateListener(
       new ValueAnimator.AnimatorUpdateListener() {
         @Override
         public void onAnimationUpdate(ValueAnimator animation) {
           float angle = (Float) animation.getAnimatedValue();
           mActiveCircle.x =
               (float)
                   (mCenterCircle.x
                       + (mCenterCircleRadius + mWallCircleRadius)
                           * Math.cos(Math.toRadians(angle)));
           mActiveCircle.y =
               (float)
                   (mCenterCircle.y
                       + (mCenterCircleRadius + mWallCircleRadius)
                           * Math.sin(Math.toRadians(angle)));
           invalidate();
         }
       });
 }
  private void performDismiss(
      final View dismissView, final int dismissPosition, final int direction) {
    // Animate the dismissed list item to zero-height and fire the dismiss callback when
    // all dismissed list item animations have completed. This triggers layout on each animation
    // frame; in the future we may want to do something smarter and more performant.

    final ViewGroup.LayoutParams lp = dismissView.getLayoutParams();
    final int originalHeight = dismissView.getHeight();

    ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);

    animator.addListener(createAnimatorListener(originalHeight));

    animator.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator valueAnimator) {
            lp.height = (Integer) valueAnimator.getAnimatedValue();
            dismissView.setLayoutParams(lp);
          }
        });

    mPendingDismisses.add(new PendingDismissData(dismissPosition, direction, dismissView));
    animator.start();
  }
  public void collapse(final View v) {

    int finalHeight = v.getHeight();

    ValueAnimator mAnimator = slideAnimator(finalHeight, 0, v);

    mAnimator.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animator) {}

          @Override
          public void onAnimationEnd(Animator animator) {
            // Height=0, but it set visibility to GONE
            v.setVisibility(View.GONE);
          }

          @Override
          public void onAnimationCancel(Animator animator) {}

          @Override
          public void onAnimationRepeat(Animator animator) {}
        });
    mAnimator.start();
  }
  @Override
  public List<Animator> createAnimation() {
    List<Animator> animators = new ArrayList<>();

    int[] durations = {960, 930, 1190, 1130, 1340, 940, 1200, 820, 1190};
    int[] delays = {360, 400, 680, 410, 710, -150, -120, 10, 320};

    for (int i = 0; i < 9; i++) {
      final int index = i;
      ValueAnimator alphaAnim = ValueAnimator.ofInt(255, 168, 255);
      alphaAnim.setDuration(durations[i]);
      alphaAnim.setRepeatCount(-1);
      alphaAnim.setStartDelay(delays[i]);
      alphaAnim.addUpdateListener(
          new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
              alphas[index] = (int) animation.getAnimatedValue();
              postInvalidate();
            }
          });
      alphaAnim.start();
      animators.add(alphaAnim);
    }
    return animators;
  }
 public void setShown(boolean shown, boolean animate) {
   synchronized (mWindowManagerService.mWindowMap) {
     if (mShown == shown) {
       return;
     }
     mShown = shown;
     if (animate) {
       if (mShowHideFrameAnimator.isRunning()) {
         mShowHideFrameAnimator.reverse();
       } else {
         if (shown) {
           mShowHideFrameAnimator.start();
         } else {
           mShowHideFrameAnimator.reverse();
         }
       }
     } else {
       mShowHideFrameAnimator.cancel();
       if (shown) {
         setAlpha(MAX_ALPHA);
       } else {
         setAlpha(MIN_ALPHA);
       }
     }
     if (DEBUG_VIEWPORT_WINDOW) {
       Slog.i(LOG_TAG, "ViewportWindow shown: " + mShown);
     }
   }
 }
 /** 抛物线 */
 public void parabolaRun(View view) {
   ValueAnimator ani = new ValueAnimator();
   ani.setDuration(1000);
   ani.setObjectValues(new PointF(0, 0));
   ani.setInterpolator(new LinearInterpolator());
   ani.setEvaluator(
       new TypeEvaluator<PointF>() {
         @Override
         public PointF evaluate(float fraction, PointF startValue, PointF endValue) {
           Log.e("TAG", fraction + "");
           // x方向的速度v=200px/s;y方向的加速度为0.5f,速度也是v
           PointF point = new PointF();
           point.x = mX * fraction;
           point.y = mY * fraction * fraction;
           return point;
         }
       });
   ani.addUpdateListener(
       new AnimatorUpdateListener() {
         @Override
         public void onAnimationUpdate(ValueAnimator animation) {
           PointF point = (PointF) animation.getAnimatedValue();
           ivBall.setX(point.x);
           ivBall.setY(point.y);
         }
       });
   ani.start();
 }