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();
  }
Exemple #2
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();
  }
Exemple #3
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 AnimatorSet startAniMoveRightToCenter(View rightDot) {
    int dotDiameter = (int) getResources().getDimension(R.dimen.loading_dot_size);
    int dotPadding = (int) getResources().getDimension(R.dimen.loading_dot_padding);
    AnimatorSet moveRightToCentral = new AnimatorSet();
    ObjectAnimator rightDotToCentral =
        ObjectAnimator.ofFloat(rightDot, "translationX", 0, -dotPadding - dotDiameter);

    rightDotColorChange =
        ValueAnimator.ofObject(
            new ArgbEvaluator(),
            getResources().getColor(R.color.dot_normal),
            getResources().getColor(R.color.dot_active));
    final GradientDrawable rightDotBg = (GradientDrawable) rightDot.getBackground();
    rightDotColorChange.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(final ValueAnimator animator) {
            rightDotBg.setColor((Integer) animator.getAnimatedValue());
          }
        });
    rightDotColorChange.setDuration(aniDuration);
    rightDotColorChange.addListener(this);
    moveRightToCentral.play(rightDotColorChange).with(rightDotToCentral);
    return moveRightToCentral;
  }
  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();
  }
Exemple #6
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();
  }
Exemple #7
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();
  }
  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();
      }
    }
  }
Exemple #9
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();
 }
 public void perform() {
   ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1);
   valueAnimator.setInterpolator(ANIMATION_INTERP);
   valueAnimator.addUpdateListener(this);
   valueAnimator.addListener(this);
   valueAnimator.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();
  }
  /**
   * 抛物线
   *
   * @param view
   */
  public void paowuxian(View view) {

    final ValueAnimator valueAnimator = new ValueAnimator();
    valueAnimator.setDuration(3000);
    valueAnimator.setTarget(mBlueBall);
    valueAnimator.setObjectValues(new PointF(0, 0));
    valueAnimator.setInterpolator(new LinearInterpolator()); // 匀速

    /**
     * evaluator全部继承至TypeEvaluator接口,它只有一个evaluate()方法。它用来返回你要进行动画的那个属性在当前时间点所需要的属性值
     * 根据属性的开始、结束值与TimeInterpolation计算出的因子计算出当前时间的属性值
     */
    valueAnimator.setEvaluator(
        new TypeEvaluator<PointF>() {
          @Override
          public PointF evaluate(float fraction, PointF startValue, PointF endValue) {
            /**
             * fraction 表示时间分值 画面绘制一帧所需要的时间 平抛运动可正交分解为两个运动:水平方向上的速度为V的匀速直线运动和竖直方向上的自由落体运动. 水平方向上位移是x
             * = Vt; 竖直方向上的速度V = gt,位移y = gt²/2 这里设x的速度为200px/s g为260px/s 时间为3秒
             */
            Log.e("sssssssss", fraction + "");
            PointF point = new PointF();
            point.x = 200 * 3 * fraction;
            point.y = 260 * (fraction * 3) * (fraction * 3) / 2;
            return point;
          }
        });
    valueAnimator.start();
    valueAnimator.addUpdateListener(
        new AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            PointF point = (PointF) animation.getAnimatedValue();
            mBlueBall.setX(point.x);
            mBlueBall.setY(point.y);
          }
        });
    /**
     * 动画监听事件 AnimatorListenerAdapter继承了AnimatorListener接口,可以空实现所有的方法 你可以根据你的需要重写你需要的方法 主要的方法有
     * onAnimationStart 开始 onAnimationRepeat 重复 onAnimationCancel 停止 onAnimationEnd 结束
     */
    valueAnimator.addListener(
        new AnimatorListenerAdapter() {

          @Override
          public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            ViewGroup parent = (ViewGroup) mBlueBall.getParent();
            if (mBlueBall != null) {
              parent.removeView(mBlueBall);
            }
          }

          @Override
          public void onAnimationCancel(Animator animation) {
            super.onAnimationCancel(animation);
          }
        });
  }
Exemple #13
0
 public void animateViewAlpha(float alpha, long durationOut, Interpolator interpolator) {
   Log.d(TAG, "animateViewAlpha: ");
   if (mAlphaAnimator != null) {
     mAlphaAnimator.cancel();
   }
   mAlphaAnimator = ValueAnimator.ofFloat(mViewAlpha, alpha);
   mAlphaAnimator.addUpdateListener(mAlphaUpdateListener);
   mAlphaAnimator.addListener(mClearAnimatorListener);
   mAlphaAnimator.setInterpolator(interpolator);
   mAlphaAnimator.setDuration(durationOut);
   mAlphaAnimator.start();
 }
  public MultiLineMarqueeTextView(Context context, AttributeSet attrs) {
    super(context, attrs);

    // get display size and density.
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    Point point = new Point();
    display.getSize(point);
    displayWidth = point.x;
    displayHeight = point.y;
    final float density = getResources().getDisplayMetrics().density;

    // load XML settings
    parseXmlSettings(context, attrs, density);

    paint.setAntiAlias(true);

    adjustTextBaseline = paint.descent() + paint.ascent();
    textHeight = Math.abs(paint.getFontMetrics().top) + paint.getFontMetrics().bottom;
    intervalSecondText = (int) (INTERVAL_SECOND_TEXT_DIPS * density);

    LinearInterpolator linearInterpolator = new LinearInterpolator();
    translateAnimator = ValueAnimator.ofFloat(0.0f, -1.0f);
    translateAnimator.setInterpolator(linearInterpolator);
    translateAnimator.removeAllUpdateListeners();
    translateAnimator.addUpdateListener(animatorUpdateListener);
    translateAnimator.removeAllListeners();
    translateAnimator.addListener(animatorListener);
    translateAnimator.setDuration(DURATION_TRANSLATE);

    suspendAnimator = ValueAnimator.ofFloat(0.0f, 0.0f);
    suspendAnimator.setInterpolator(linearInterpolator);
    suspendAnimator.removeAllUpdateListeners();
    suspendAnimator.addUpdateListener(animatorUpdateListener);
    suspendAnimator.removeAllListeners();
    suspendAnimator.addListener(animatorListener);
    suspendAnimator.setDuration(DURATION_SUSPEND);

    changeTapReset();
  }
 private void setupAnimation(ValueAnimator anim, final View v) {
   anim.setInterpolator(sAccelerateInterpolator);
   anim.setDuration(TRANSITION_DURATION);
   anim.addListener(
       new AnimatorListenerAdapter() {
         @Override
         public void onAnimationEnd(Animator animation) {
           if (v != null) {
             v.setLayerType(View.LAYER_TYPE_NONE, null);
           }
         }
       });
 }
  public InterruptibleInOutAnimator(View view, long duration, float fromValue, float toValue) {
    mAnimator = LauncherAnimUtils.ofFloat(view, fromValue, toValue).setDuration(duration);
    mOriginalDuration = duration;
    mOriginalFromValue = fromValue;
    mOriginalToValue = toValue;

    mAnimator.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            mDirection = STOPPED;
          }
        });
  }
Exemple #17
0
  private void PlayAnimator() {
    if (i < text.length()) {
      mPath.moveTo(0, 0); // 起点
      mPath.quadTo(
          (mTextSize * i) / 2, 0, mTextSize * i, mTextSize + DensityUtil.px2dip(mContext, 300));
      mPathMeasure = new PathMeasure(mPath, false);
      animator = ValueAnimator.ofFloat(0, mPathMeasure.getLength());
      animator.addUpdateListener(
          new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
              float value = (Float) animation.getAnimatedValue();
              mPathMeasure.getPosTan(value, mCurrentPosition, null);
              postInvalidate();
            }
          });
      mPath.close();
      animator.setDuration(1500);
      animator.setRepeatMode(ValueAnimator.RESTART);
      animator.setInterpolator(new LinearInterpolator());
      animator.start();
      animator.addListener(
          new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animator) {}

            @Override
            public void onAnimationEnd(Animator animator) {
              // 每一个动画执行完成后记录最后一个坐标点
              Point point = new Point();
              point.x = (int) mCurrentPosition[0];
              point.y = (int) mCurrentPosition[1];
              endloc.put(i, point);
              i++;
              if (i >= text.length()) { // 当i大于7的时候置为零方便下次循环
                i = 0;
                endloc.clear(); // 清空集合,从新来过
              }
              mPath.reset();
              PlayAnimator();
            }

            @Override
            public void onAnimationCancel(Animator animator) {}

            @Override
            public void onAnimationRepeat(Animator animator) {}
          });
    }
  }
  private void init() {
    animator = ValueAnimator.ofFloat(0, 0);
    animator.setDuration(DEFAULT_ANIM_DURATION);
    animator.setInterpolator(new DecelerateInterpolator());
    animator.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            float value = (Float) animation.getAnimatedValue();
            if (scaleDirection == VERTICAL) {
              bottom = (int) (value * (parentHeight - drawableOriginHeight) + drawableOriginHeight);
              right = bottom * drawableOriginWidth / drawableOriginHeight;
            } else {
              right = drawableOriginWidth + (int) ((parentWidth - drawableOriginWidth) * value);
              bottom = right * drawableOriginHeight / drawableOriginWidth;
            }
            top = beginTop + (int) (value * (finalTop - beginTop));
            left = beginLeft + (int) (value * (finalLeft - beginLeft));
            parentView.setBackgroundColor((int) (200 * value) << 24);
            ScaleImageView.super.setFrame(left, top, right + left, bottom + top);
          }
        });
    animator.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animation) {}

          @Override
          public void onAnimationEnd(Animator animation) {
            if (mIsOpen) {

            } else {
              parentView.setVisibility(INVISIBLE);
            }
          }

          @Override
          public void onAnimationCancel(Animator animation) {}

          @Override
          public void onAnimationRepeat(Animator animation) {}
        });
    setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            close();
          }
        });
  }
  private void startLineAnim() {
    mStatus = LINE_MOVE;
    int duration = 1;
    // (cxRight - cxLeft) != mRecWidth. 极小的数字也会画出一个点
    linePosXAnim = ValueAnimator.ofFloat(0, cxRight - cxLeft);
    linePosXAnim.setDuration(duration * mRippleDuration);
    linePosXAnim.setInterpolator(new LinearInterpolator());
    linePosXAnim.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            mLinePosX = (float) animation.getAnimatedValue();
            postInvalidate();
          }
        });

    sweepAngAnim = ValueAnimator.ofFloat(180f, mSweepAngMin);
    sweepAngAnim.setDuration(duration * mRippleDuration);
    sweepAngAnim.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            mSweepAng = (float) animation.getAnimatedValue();
            postInvalidate();
          }
        });
    sweepAngAnim.setInterpolator(new LinearInterpolator());
    sweepAngAnim.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animation) {}

          @Override
          public void onAnimationEnd(Animator animation) {
            mLinePosX = 0;
            mSweepAng = 180f;
            startTickAnim();
          }

          @Override
          public void onAnimationCancel(Animator animation) {}

          @Override
          public void onAnimationRepeat(Animator animation) {}
        });

    AnimatorSet animSet = new AnimatorSet();
    animSet.playSequentially(linePosXAnim, sweepAngAnim);
    animSet.start();
  }
Exemple #20
0
  public void animateView(
      final DragView view,
      AnimatorUpdateListener updateCb,
      int duration,
      TimeInterpolator interpolator,
      final Runnable onCompleteRunnable,
      final int animationEndStyle,
      View anchorView) {
    // Clean up the previous animations
    if (mDropAnim != null) mDropAnim.cancel();
    if (mFadeOutAnim != null) mFadeOutAnim.cancel();

    // Show the drop view if it was previously hidden
    mDropView = view;
    mDropView.cancelAnimation();
    mDropView.resetLayoutParams();

    // Set the anchor view if the page is scrolling
    if (anchorView != null) {
      mAnchorViewInitialScrollX = anchorView.getScrollX();
    }
    mAnchorView = anchorView;

    // Create and start the animation
    mDropAnim = new ValueAnimator();
    mDropAnim.setInterpolator(interpolator);
    mDropAnim.setDuration(duration);
    mDropAnim.setFloatValues(0f, 1f);
    mDropAnim.addUpdateListener(updateCb);
    mDropAnim.addListener(
        new AnimatorListenerAdapter() {
          public void onAnimationEnd(Animator animation) {
            if (onCompleteRunnable != null) {
              onCompleteRunnable.run();
            }
            switch (animationEndStyle) {
              case ANIMATION_END_DISAPPEAR:
                clearAnimatedView();
                break;
              case ANIMATION_END_FADE_OUT:
                fadeOutDragView();
                break;
              case ANIMATION_END_REMAIN_VISIBLE:
                break;
            }
          }
        });
    mDropAnim.start();
  }
  /** Hide the SuperCardToast and animate the Layout. Post Honeycomb only. * */
  @SuppressLint("NewApi")
  private void dismissWithLayoutAnimation() {

    if (mToastView != null) {

      mToastView.setVisibility(View.INVISIBLE);

      final ViewGroup.LayoutParams layoutParams = mToastView.getLayoutParams();
      final int originalHeight = mToastView.getHeight();

      ValueAnimator animator =
          ValueAnimator.ofInt(originalHeight, 1)
              .setDuration(
                  mContext.getResources().getInteger(android.R.integer.config_shortAnimTime));

      animator.addListener(
          new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {

              Handler mHandler = new Handler();
              mHandler.post(mHideImmediateRunnable);
            }
          });

      animator.addUpdateListener(
          new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {

              if (mToastView != null) {

                layoutParams.height = (Integer) valueAnimator.getAnimatedValue();
                mToastView.setLayoutParams(layoutParams);
              }
            }
          });

      animator.start();

    } else {

      dismissImmediately();
    }
  }
 private void _mth02CB(TextView textview, EditText edittext)
 {
     if (textview.getVisibility() != 0)
     {
         return;
     } else
     {
         ValueAnimator valueanimator = ValueAnimator.ofInt(new int[] {
             brt, 0
         });
         valueanimator.addUpdateListener(new ali(this, textview));
         valueanimator.addListener(new ala(this, textview, edittext));
         valueanimator.setDuration(180L);
         valueanimator.start();
         return;
     }
 }
  private void startRippleAnim() {
    mStatus = RIPPLE;
    rippleAnimator = ValueAnimator.ofFloat(mRippleWidth, mMaxRippleWidth);
    rippleAlphaAnimator = ValueAnimator.ofInt(255, 0);
    rippleAnimator.setDuration(mRippleDuration);
    rippleAlphaAnimator.setDuration(mRippleDuration);
    rippleAnimator.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            mRippleWidth = (Float) animation.getAnimatedValue();
          }
        });
    rippleAlphaAnimator.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            mRippleAlpha = (int) animation.getAnimatedValue();
            postInvalidate();
          }
        });
    rippleAnimator.addListener(
        new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animation) {}

          @Override
          public void onAnimationEnd(Animator animation) {
            mRippleWidth = mInitRippleWidth;
            mRippleAlpha = 255;
            startLineAnim();
          }

          @Override
          public void onAnimationCancel(Animator animation) {
            mRippleWidth = mInitRippleWidth;
            mRippleAlpha = 255;
          }

          @Override
          public void onAnimationRepeat(Animator animation) {}
        });
    AnimatorSet animSet = new AnimatorSet();
    animSet.playTogether(rippleAnimator, rippleAlphaAnimator);
    animSet.start();
  }
  private void expend() {
    int height = 0;
    int targeHeight = getMeasureHeight();
    if (!isOpen) {
      isOpen = true;
      valueAnimator = ValueAnimator.ofInt(height, targeHeight);
    } else {
      isOpen = false;
      // 缩回
      valueAnimator = ValueAnimator.ofInt(targeHeight, height);
    }
    // 监听弹出操作
    valueAnimator.addUpdateListener(
        new AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator arg0) {
            // 可以获取当前的控件所在的高度值
            layoutParams.height = (Integer) arg0.getAnimatedValue();
            ll_footer.setLayoutParams(layoutParams);
          }
        });
    // 监听动画完成后的操作
    valueAnimator.addListener(
        new AnimatorListener() {
          @Override
          public void onAnimationStart(Animator arg0) {}

          @Override
          public void onAnimationRepeat(Animator arg0) {}

          @Override
          public void onAnimationEnd(Animator arg0) {
            if (isOpen) {
              arrow.setBackgroundResource(R.drawable.arrow_up);
            } else {
              arrow.setBackgroundResource(R.drawable.arrow_down);
            }
          }

          @Override
          public void onAnimationCancel(Animator arg0) {}
        });

    valueAnimator.start();
    valueAnimator.setDuration(100);
  }
  private void init() {
    mLeftOpened = false;
    mRightOpened = false;
    mLeftState = STATE_CLOSED;
    mRightState = STATE_CLOSED;
    mLeftPercent = 0.0f;
    mRightPercent = 0.0f;
    mMinDrawerMargin = sDefaultMinDrawerMargin;
    mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback());
    mAnimator = ValueAnimator.ofFloat(0.0f, 1.0f);
    mAnimator.addUpdateListener(this);
    mAnimator.addListener(this);
    mAnimator.setInterpolator(AnimationUtils2.FAST_SLOW_INTERPOLATOR);
    mCancelAnimation = false;

    setWillNotDraw(false);
  }
Exemple #26
0
 /**
  * Starts the underlying Animator for a set of properties. We use a single animator that simply
  * runs from 0 to 1, and then use that fractional value to set each property value accordingly.
  */
 private void startAnimation() {
   if (mRTBackend != null && mRTBackend.startAnimation(this)) {
     return;
   }
   mView.setHasTransientState(true);
   ValueAnimator animator = ValueAnimator.ofFloat(1.0f);
   ArrayList<NameValuesHolder> nameValueList =
       (ArrayList<NameValuesHolder>) mPendingAnimations.clone();
   mPendingAnimations.clear();
   int propertyMask = 0;
   int propertyCount = nameValueList.size();
   for (int i = 0; i < propertyCount; ++i) {
     NameValuesHolder nameValuesHolder = nameValueList.get(i);
     propertyMask |= nameValuesHolder.mNameConstant;
   }
   mAnimatorMap.put(animator, new PropertyBundle(propertyMask, nameValueList));
   if (mPendingSetupAction != null) {
     mAnimatorSetupMap.put(animator, mPendingSetupAction);
     mPendingSetupAction = null;
   }
   if (mPendingCleanupAction != null) {
     mAnimatorCleanupMap.put(animator, mPendingCleanupAction);
     mPendingCleanupAction = null;
   }
   if (mPendingOnStartAction != null) {
     mAnimatorOnStartMap.put(animator, mPendingOnStartAction);
     mPendingOnStartAction = null;
   }
   if (mPendingOnEndAction != null) {
     mAnimatorOnEndMap.put(animator, mPendingOnEndAction);
     mPendingOnEndAction = null;
   }
   animator.addUpdateListener(mAnimatorEventListener);
   animator.addListener(mAnimatorEventListener);
   if (mStartDelaySet) {
     animator.setStartDelay(mStartDelay);
   }
   if (mDurationSet) {
     animator.setDuration(mDuration);
   }
   if (mInterpolatorSet) {
     animator.setInterpolator(mInterpolator);
   }
   animator.start();
 }
  /** 开始进入动画 */
  private void startEnterAnim() {

    // 求所有小球长度一半的偏移量
    float offset =
        mCircleCount % 2 == 0
            ? (mCircleCount / 2) * (mDivideWidth + 2 * mCircleRadius) - mDivideWidth / 2
            : (mCircleCount / 2) * (mDivideWidth + 2 * mCircleRadius) + mCircleRadius;

    /* 进入动画 */
    for (int i = 0; i < mCircleCount; i++) {
      final Circle circle = mCircles.get(i);
      ValueAnimator valueAnimator =
          ValueAnimator.ofFloat(circle.oldX, circle.oldX + mWidth / 2 + offset);
      valueAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
      valueAnimator.setDuration(800 + 200 * i);
      valueAnimator.start();
      valueAnimator.addUpdateListener(
          new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
              float x = (float) animation.getAnimatedValue();
              circle.x = x;
              invalidate();
            }
          });

      if (i == mCircleCount - 1) {
        valueAnimator.addListener(
            new AnimatorListenerAdapter() {
              @Override
              public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                new Handler()
                    .postDelayed(
                        new Runnable() {
                          public void run() {
                            startLeaveAnim();
                          }
                        },
                        400);
              }
            });
      }
    }
  }
 private void _mth02CA(TextView textview, EditText edittext)
 {
     if (textview.getVisibility() == 0)
     {
         return;
     } else
     {
         textview.setVisibility(0);
         ValueAnimator valueanimator = ValueAnimator.ofInt(new int[] {
             0, brt
         });
         valueanimator.addUpdateListener(new alg(this, textview));
         valueanimator.addListener(new alh(this, edittext));
         valueanimator.setDuration(180L);
         valueanimator.start();
         return;
     }
 }
  private void processPendingDismisses(final PendingDismissData pendingDismissData) {
    mPendingDismiss = null;
    final ViewGroup.LayoutParams lp = pendingDismissData.rowContainer.container.getLayoutParams();
    final int originalHeight = pendingDismissData.rowContainer.container.getHeight();

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

    animator.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            if (mCallbacks.canDismiss(pendingDismissData.position))
              mCallbacks.onDismiss(mRecyclerView, pendingDismissData.position);
            pendingDismissData.rowContainer.dataContainer.post(
                new Runnable() {
                  @Override
                  public void run() {
                    pendingDismissData.rowContainer.dataContainer.setTranslationX(0);
                    pendingDismissData.rowContainer.dataContainer.setAlpha(1);
                    pendingDismissData.rowContainer.undoContainer.setVisibility(View.GONE);
                    pendingDismissData.rowContainer.undoContainer.setTranslationX(0);
                    pendingDismissData.rowContainer.undoContainer.setAlpha(1);

                    lp.height = originalHeight;
                    pendingDismissData.rowContainer.container.setLayoutParams(lp);
                  }
                });
          }
        });

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

    animator.start();
  }
  public IconicLabelView setTexts(String text1, String text2) {
    if (text1 == null || text2 == null) {
      return this;
    }
    mText1 = text1;
    Rect text1Bounds = new Rect();
    mTextPaint.getTextBounds(mText1, 0, mText1.length(), text1Bounds);

    mText2 = text2;
    Rect text2Bounds = new Rect();
    mTextPaint.getTextBounds(mText2, 0, mText2.length(), text2Bounds);

    mText = text1;
    mTextBounds = new Rect(text1Bounds);

    mAnimText1ToText2 = true;
    mAnim = ValueAnimator.ofObject(new RectEvaluator(mTextBounds), text1Bounds, text2Bounds);
    mAnim.addUpdateListener(this);
    mAnim.addListener(this);
    return this;
  }