Java 类android.animation.ValueAnimator 实例源码

项目:ReadMark    文件:RLetterS.java   
@Override
public void startAnim() {
    mAnimator = ValueAnimator.ofFloat(0, 1);
    mAnimator.setDuration(mDuration);
    mAnimator.setRepeatCount(0);
    mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float factor = (float) animation.getAnimatedValue();
            mSweepArg = (int) (90 * factor);
            mSecPoint.y = (int) (mFirPoint.y + 2 * MAX_RADIUS_CIRCLE * factor);

        }
    });
    mAnimator.start();
}
项目:Musicoco    文件:AlbumPictureController.java   
public AlbumPictureController(Context context, final ImageSwitcher view, int size) {
    this.view = view;
    this.size = size;
    this.context = context;
    this.cache = new BitmapCache(context, BitmapCache.CACHE_ALBUM_VISUALIZER_IMAGE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        defaultColor = context.getColor(R.color.default_play_bg_color);
        defaultTextColor = context.getColor(R.color.default_play_text_color);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        defaultColor = context.getResources().getColor(R.color.default_play_bg_color, null);
        defaultTextColor = context.getResources().getColor(R.color.default_play_text_color, null);
    } else {
        defaultColor = context.getResources().getColor(R.color.default_play_bg_color);
        defaultTextColor = context.getResources().getColor(R.color.default_play_text_color);
    }

    this.bitmapProducer = new BitmapProducer(context);

    colors = new int[]{
            defaultColor,
            defaultTextColor,
            defaultColor,
            defaultTextColor
    };

    rotateAnim = ObjectAnimator.ofFloat(0, 360);
    rotateAnim.setDuration(45 * 1000);
    rotateAnim.setRepeatMode(ValueAnimator.RESTART);
    rotateAnim.setRepeatCount(ValueAnimator.INFINITE);
    rotateAnim.setInterpolator(new LinearInterpolator());
    rotateAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float value = (float) animation.getAnimatedValue();
            view.getCurrentView().setRotation(value);
        }
    });
}
项目:ImitateZHRB    文件:BallGridBeatIndicator.java   
@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;
}
项目:Hello-Music-droid    文件:PlayPauseButton.java   
/**
 * アニメーションを開始する
 */
public void startAnimation() {
    mCenterEdgeAnimator = ValueAnimator.ofFloat(1.f, 0.5f);
    mCenterEdgeAnimator.setDuration(100 * SPEED);
    mCenterEdgeAnimator.addUpdateListener(mAnimatorUpdateListener);

    mLeftEdgeAnimator = ValueAnimator.ofFloat((float) (-0.2 * SQRT_3), 0.f);
    mLeftEdgeAnimator.setDuration(100 * SPEED);
    mLeftEdgeAnimator.addUpdateListener(mAnimatorUpdateListener);

    mRightEdgeAnimator = ValueAnimator.ofFloat(1.f, 0.f);
    mRightEdgeAnimator.setDuration(150 * SPEED);
    mRightEdgeAnimator.addUpdateListener(mAnimatorUpdateListener);

    if (!mPlayed) {
        mCenterEdgeAnimator.start();
        mLeftEdgeAnimator.start();
        mRightEdgeAnimator.start();
    } else {
        mCenterEdgeAnimator.reverse();
        mLeftEdgeAnimator.reverse();
        mRightEdgeAnimator.reverse();
    }
}
项目:DownloadProgressButton    文件:DownloadProgressButton.java   
public ArrayList<ValueAnimator> createBallJumpAnimators() {
    ArrayList<ValueAnimator> animators = new ArrayList<>();
    int[] delays = new int[]{70, 140, 210};
    for (int i = 0; i < 3; i++) {
        final int index = i;
        ValueAnimator scaleAnim = ValueAnimator.ofFloat(mTextBottomBorder, mTextBottomBorder - mBallRadius * 2, mTextBottomBorder);
        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();
            }
        });
        animators.add(scaleAnim);
    }
    return animators;
}
项目:GestureLockView    文件:GestureLockView.java   
/**
 * ACTION_UP/ACTION_CANCEL事件处理方法
 */
private void upEventDeal() {
    // 1.回调手势解锁监听器Complete方法
    if (mGestureLockListener != null) {
        mGestureLockListener.onComplete(getPassword());
    }
    // 2.清除触摸点到最后按下单元点的连线
    if (!mPressPoints.isEmpty()) {
        mEventX = mPressPoints.get(mPressPoints.size() - 1).x;
        mEventY = mPressPoints.get(mPressPoints.size() - 1).y;
    }
    // 3.提前结束未执行完的动画
    if (!mPointAnimators.isEmpty()) {
        for (ValueAnimator animator : mPointAnimators) {
            animator.end();
        }
        mPointAnimators.clear();
    }
    // 4.重绘
    postInvalidate();
}
项目:FakeWeather    文件:HailType.java   
@Override
public void endAnimation(DynamicWeatherView dynamicWeatherView, Animator.AnimatorListener listener) {
    super.endAnimation(dynamicWeatherView, listener);
    ValueAnimator animator = ValueAnimator.ofFloat(getWidth() - bitmap.getWidth() * 0.25f, getWidth());
    animator.setDuration(1000);
    animator.setRepeatCount(0);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            transFactor = (float) animation.getAnimatedValue();
        }
    });
    if (listener != null) {
        animator.addListener(listener);
    }
    animator.start();
}
项目:Aurora    文件:WeatherView.java   
private void startSunRotate() {
    ValueAnimator rotateAnim=animMap.get(ANIM_SUN_ROTATE);
    if (rotateAnim==null){
        rotateAnim =ValueAnimator.ofFloat(0,360f).setDuration(30*1000);
        rotateAnim.setRepeatCount(ValueAnimator.INFINITE);
        rotateAnim.setInterpolator(new LinearInterpolator());
        rotateAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                sunRotateAngle= (float) animation.getAnimatedValue();
            }
        });
        animMap.put(ANIM_SUN_ROTATE,rotateAnim);
    }
    startValueAnimator(rotateAnim);
}
项目:Multi-SwipeToRefreshLayout    文件:LineScalePulseOutRapidIndicator.java   
@Override
public List<Animator> createAnimation() {
    List<Animator> animators=new ArrayList<>();
    long[] delays=new long[]{400,200,0,200,400};
    for (int i = 0; i < 5; i++) {
        final int index=i;
        ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.4f,1);
        scaleAnim.setDuration(1000);
        scaleAnim.setRepeatCount(-1);
        scaleAnim.setStartDelay(delays[i]);
        scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                scaleYFloats[index] = (float) animation.getAnimatedValue();
                postInvalidate();
            }
        });
        scaleAnim.start();
        animators.add(scaleAnim);
    }
    return animators;
}
项目:WeiXinRecordedDemo    文件:MainActivity.java   
private void startAnim() {

        rb_start.setVisibility(View.GONE);
        ValueAnimator va = ValueAnimator.ofFloat(0, dp100).setDuration(300);
        va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {

                float value = (float) animation.getAnimatedValue();
                float dis = value-lastValue;
                iv_back.setX(iv_back.getX()-dis);
                iv_finish.setX(iv_finish.getX()+dis);
                lastValue = value;
            }
        });
        va.start();
    }
项目:Dachshund-Tab-Layout    文件:DachshundIndicator.java   
public DachshundIndicator(DachshundTabLayout dachshundTabLayout){
    this.dachshundTabLayout = dachshundTabLayout;

    valueAnimatorLeft = new ValueAnimator();
    valueAnimatorLeft.setDuration(DEFAULT_DURATION);
    valueAnimatorLeft.addUpdateListener(this);

    valueAnimatorRight = new ValueAnimator();
    valueAnimatorRight.setDuration(DEFAULT_DURATION);
    valueAnimatorRight.addUpdateListener(this);

    accelerateInterpolator = new AccelerateInterpolator();
    decelerateInterpolator = new DecelerateInterpolator();

    rectF = new RectF();
    rect = new Rect();

    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setStyle(Paint.Style.FILL);

    leftX = (int) dachshundTabLayout.getChildXCenter(dachshundTabLayout.getCurrentPosition());
    rightX = leftX;
}
项目:AgentWebX5    文件:BallPulseView.java   
private void createAnimators() {
    mAnimators = new ArrayList<>();
    int[] delays = new int[]{120, 240, 360};
    for (int i = 0; i < 3; i++) {
        final int index = i;

        ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.3f, 1);

        scaleAnim.setDuration(750);
        scaleAnim.setRepeatCount(ValueAnimator.INFINITE);
        scaleAnim.setStartDelay(delays[i]);

        mUpdateListeners.put(scaleAnim, new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                scaleFloats[index] = (float) animation.getAnimatedValue();
                postInvalidate();
            }
        });
        mAnimators.add(scaleAnim);
    }
}
项目:SafeView    文件:SafeView.java   
/**
 * 启动动画 回弹效果
 *
 */
private void startBackAnimator() {
    PropertyValuesHolder xValuesHolder = PropertyValuesHolder.ofFloat("x", canvasRotateX, 0);
    PropertyValuesHolder yValuesHolder = PropertyValuesHolder.ofFloat("y", canvasRotateY, 0);
    touchAnimator = ValueAnimator.ofPropertyValuesHolder(xValuesHolder, yValuesHolder).setDuration(700);
    touchAnimator.setInterpolator(new BounceInterpolator());
    touchAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            canvasRotateY = (Float) animation.getAnimatedValue("y");
            canvasRotateX = (Float) animation.getAnimatedValue("x");
            invalidate();
        }
    });
    touchAnimator.start();
}
项目:GitHub    文件:BallGridBeatIndicator.java   
@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;
}
项目:VirtualHook    文件:BallPulseIndicator.java   
@Override
public ArrayList<ValueAnimator> onCreateAnimators() {
    ArrayList<ValueAnimator> animators = new ArrayList<>();
    int[] delays = new int[]{120, 240, 360};
    for (int i = 0; i < 3; i++) {
        final int index = i;

        ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.3f, 1);

        scaleAnim.setDuration(750);
        scaleAnim.setRepeatCount(-1);
        scaleAnim.setStartDelay(delays[i]);

        addUpdateListener(scaleAnim, animation -> {
            scaleFloats[index] = (float) animation.getAnimatedValue();
            postInvalidate();
        });
        animators.add(scaleAnim);
    }
    return animators;
}
项目:LuaViewPlayground    文件:UDAnimatorSet.java   
public UDAnimatorSet setupValues(Animator animator) {
    animator.setupStartValues();
    if (mTarget != null && mAnimators != null) {
        for (Animator anim : mAnimators) {
            anim.setTarget(mTarget.getView());
            anim.setupStartValues();
            if (anim instanceof ValueAnimator) {
                ((ValueAnimator) anim).setRepeatCount(mRepeatCount);
                ((ValueAnimator) anim).setRepeatMode(mRepeatMode);
                //TODO
            }
        }
        if (animator instanceof AnimatorSet) {
            ((AnimatorSet) animator).playTogether(mAnimators);
        }
    }
    return this;
}
项目:GitHub    文件:ElectricFanLoadingRenderer.java   
private ValueAnimator getBezierValueAnimator(LeafHolder target, RectF leafFlyRect, float progress) {
    BezierEvaluator evaluator = new BezierEvaluator(getPoint1(leafFlyRect), getPoint2(leafFlyRect));

    int leafFlyStartY = (int) (mCurrentProgressBounds.bottom - mLeafDrawable.getIntrinsicHeight());
    int leafFlyRange = (int) (mCurrentProgressBounds.height() - mLeafDrawable.getIntrinsicHeight());

    int startPointY = leafFlyStartY - mRandom.nextInt(leafFlyRange);
    int endPointY = leafFlyStartY - mRandom.nextInt(leafFlyRange);

    ValueAnimator animator = ValueAnimator.ofObject(evaluator,
            new PointF((int) (leafFlyRect.right - mLeafDrawable.getIntrinsicWidth()), startPointY),
            new PointF(leafFlyRect.left, endPointY));
    animator.addUpdateListener(new BezierListener(target));
    animator.setTarget(target);

    animator.setDuration((long) ((mRandom.nextInt(300) + mDuration * DEFAULT_LEAF_FLY_DURATION_FACTOR) * (1.0f - progress)));

    return animator;
}
项目:diycode    文件:ExpectAnimCameraDistanceManager.java   
@Override
public List<Animator> getAnimators() {
    final List<Animator> animations = new ArrayList<>();
    calculate();
    if (mCameraDistance != null) {
        final ValueAnimator animator = ValueAnimator.ofFloat(mCurrentCameraDistance, mCameraDistance);
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                viewToMove.setCameraDistance((float) valueAnimator.getAnimatedValue());
            }
        });
        animations.add(animator);
    }
    return animations;
}
项目:GitHub    文件:ScreenUtils.java   
/**
 * 调整窗口的透明度  1.0f,0.5f 变暗
 *
 * @param from    from>=0&&from<=1.0f
 * @param to      to>=0&&to<=1.0f
 * @param context 当前的activity
 */
public static void dimBackground(final float from, final float to, Activity context) {
    final Window window = context.getWindow();
    ValueAnimator valueAnimator = ValueAnimator.ofFloat(from, to);
    valueAnimator.setDuration(500);
    valueAnimator.addUpdateListener(
            new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    WindowManager.LayoutParams params = window.getAttributes();
                    params.alpha = (Float) animation.getAnimatedValue();
                    window.setAttributes(params);
                }
            });
    valueAnimator.start();
}
项目:mkloader    文件:Pulse.java   
@Override public void setUpAnimation() {
  for (int i = 0; i < numberOfLines; i++) {
    final int index = i;
    ValueAnimator scaleAnimator = ValueAnimator.ofFloat(1f, 1.5f, 1f);
    scaleAnimator.setDuration(1000);
    scaleAnimator.setStartDelay(i * 120);
    scaleAnimator.setRepeatCount(ValueAnimator.INFINITE);
    scaleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
      @Override public void onAnimationUpdate(ValueAnimator animation) {
        scaleY[index] = (float)animation.getAnimatedValue();
        if (invalidateListener != null) {
          invalidateListener.reDraw();
        }
      }
    });

    scaleAnimator.start();
  }
}
项目:GitHub    文件:LineScaleIndicator.java   
@Override
public List<Animator> createAnimation() {
    List<Animator> animators=new ArrayList<>();
    long[] delays=new long[]{100,200,300,400,500};
    for (int i = 0; i < 5; i++) {
        final int index=i;
        ValueAnimator scaleAnim=ValueAnimator.ofFloat(1, 0.4f, 1);
        scaleAnim.setDuration(1000);
        scaleAnim.setRepeatCount(-1);
        scaleAnim.setStartDelay(delays[i]);
        scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                scaleYFloats[index] = (float) animation.getAnimatedValue();
                postInvalidate();
            }
        });
        scaleAnim.start();
        animators.add(scaleAnim);
    }
    return animators;
}
项目:MTweaks-KernelAdiutorMOD    文件:DropDownView.java   
private void expand() {
    mExpanded = true;
    if (mArrow != null) {
        mArrow.animate().rotationX(0).setDuration(500).start();
        if (mAnimator != null) {
            mAnimator.cancel();
        }
        if (mItems == null) return;
        mAnimator = ValueAnimator.ofFloat(0, mItemHeight * mItems.size());
        mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                setHeight(Math.round((float) animation.getAnimatedValue()));
            }
        });
        mAnimator.setDuration(500);
        mAnimator.start();
    }
}
项目:Multi-SwipeToRefreshLayout    文件:BallPulseIndicator.java   
@Override
public List<Animator> createAnimation() {
    List<Animator> animators=new ArrayList<>();
    int[] delays=new int[]{120,240,360};
    for (int i = 0; i < 3; i++) {
        final int index=i;

        ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.3f,1);

        scaleAnim.setDuration(750);
        scaleAnim.setRepeatCount(-1);
        scaleAnim.setStartDelay(delays[i]);

        scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                scaleFloats[index] = (float) animation.getAnimatedValue();
                postInvalidate();

            }
        });
        scaleAnim.start();
        animators.add(scaleAnim);
    }
    return animators;
}
项目:AdaptiveIconView    文件:AdaptiveIconView.java   
@Override
public boolean onTouch(View view, MotionEvent event) {
    switch (event.getAction()) {
        case MotionEvent.ACTION_UP:
            if (animator != null && animator.isStarted())
                animator.cancel();

            animator = ValueAnimator.ofFloat(fgScale, 1.2f, 1);
            animator.setDuration(500);
            animator.setInterpolator(new DecelerateInterpolator());
            animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    fgScale = (float) valueAnimator.getAnimatedValue();
                    invalidate();
                }
            });
            animator.start();

            performClick();
            return false;
    }
    return true;
}
项目:RippleValidatorEditText    文件:RippleValidatorEditText.java   
private void drawCircle(){
  rippleType = RippleType.IsPlaying;
  mCirclePaint.setColor(mValidColor);
  ValueAnimator va = ValueAnimator.ofInt(0,getWidth());
  va.setDuration(700);
  va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
    public void onAnimationUpdate(ValueAnimator animation) {
      mCircleRadius=(int)animation.getAnimatedValue();
      if(mCircleRadius==getWidth())
        drawEmptyCircle();
      invalidate();
    }
  });
  va.setStartDelay(500);
  va.start();
}
项目:SmartRefreshLayout    文件:FlyRefreshStyleActivity.java   
private void bounceAnimateView(final View view) {
    if (view == null) {
        return;
    }

    ValueAnimator swing = ValueAnimator.ofFloat(0, 60, -40, 0);
    swing.setDuration(400);
    swing.setInterpolator(new AccelerateInterpolator());
    swing.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            view.setRotationX((float)animation.getAnimatedValue());
        }
    });
    swing.start();
}
项目:GitHub    文件:RoundProgressView.java   
private void init() {
    mPath = new Paint();
    mPantR = new Paint();
    mPantR.setColor(Color.WHITE);
    mPantR.setAntiAlias(true);
    mPath.setAntiAlias(true);
    mPath.setColor(Color.rgb(114, 114, 114));

    va = ValueAnimator.ofInt(0,360);
    va.setDuration(720);
    va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            endAngle = (int) animation.getAnimatedValue();
            postInvalidate();
        }
    });
    va.setRepeatCount(ValueAnimator.INFINITE);
    va.setInterpolator(new AccelerateDecelerateInterpolator());
}
项目:SmartRefreshLayout    文件:WaveSwipeHeader.java   
@Override
public void onRefreshReleased(RefreshLayout layout, int headerHeight, int extendHeight) {
    mLastFirstBounds = 0;
    mWaveView.animationDropCircle();
    mCircleView.makeProgressTransparent();
    mCircleView.startProgress();
    ValueAnimator animator = ValueAnimator.ofFloat(0, 0);
    animator.setDuration(500);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mCircleView.setTranslationY(
                    mWaveView.getCurrentCircleCenterY() + mCircleView.getHeight() / 2.f);
        }
    });
    animator.start();
}
项目:GitHub    文件:LineScalePartyIndicator.java   
@Override
public List<Animator> createAnimation() {
    List<Animator> animators=new ArrayList<>();
    long[] durations=new long[]{1260, 430, 1010, 730};
    long[] delays=new long[]{770, 290, 280, 740};
    for (int i = 0; i < 4; i++) {
        final int index=i;
        ValueAnimator scaleAnim=ValueAnimator.ofFloat(1,0.4f,1);
        scaleAnim.setDuration(durations[i]);
        scaleAnim.setRepeatCount(-1);
        scaleAnim.setStartDelay(delays[i]);
        scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                scaleFloats[index] = (float) animation.getAnimatedValue();
                postInvalidate();
            }
        });
        scaleAnim.start();
        animators.add(scaleAnim);
    }
    return animators;
}
项目:AnimationShowcase    文件:ObjectAnimatorActivity.java   
@OnClick(R.id.translateAndFade)
public void onTranslateAndFade() {
    ValueAnimator xAnimator = ObjectAnimator.ofFloat(icon, "translationX", icon.getTranslationX(), animateForward ? icon.getWidth() * 2 : 0.0f);
    ValueAnimator yAnimator = ObjectAnimator.ofFloat(icon, "translationY", icon.getTranslationY(), animateForward ? icon.getHeight() * 4 : 0.0f);
    ValueAnimator alphaAnimator = ObjectAnimator.ofFloat(icon, "alpha", icon.getAlpha(), animateForward ? 0.0f : 1.0f);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(FULL_ANIMATION_DURATION);
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.playTogether(xAnimator, yAnimator, alphaAnimator);
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            System.out.println("translateAndFade END");
        }
    });
    animatorSet.start();

    animateForward = !animateForward;
}
项目:GitHub    文件:BallPulseView.java   
private void createAnimators() {
    mAnimators = new ArrayList<>();
    int[] delays = new int[]{120, 240, 360};
    for (int i = 0; i < 3; i++) {
        final int index = i;

        ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.3f, 1);

        scaleAnim.setDuration(750);
        scaleAnim.setRepeatCount(ValueAnimator.INFINITE);
        scaleAnim.setStartDelay(delays[i]);

        mUpdateListeners.put(scaleAnim, new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                scaleFloats[index] = (float) animation.getAnimatedValue();
                postInvalidate();
            }
        });
        mAnimators.add(scaleAnim);
    }
}
项目:Phial    文件:ExpandedView.java   
private Animator createAppearBackgroundAnimator() {
    int startColor = ResourcesCompat.getColor(getResources(),
            BACGROUND_TRANSPARENT_COLOR_RES,
            getContext().getTheme()
    );
    int finColor = ResourcesCompat.getColor(getResources(),
            BACKGROUND_COLOR_RES,
            getContext().getTheme()
    );
    ValueAnimator anim = new ValueAnimator();
    anim.setIntValues(startColor, finColor);
    anim.setEvaluator(ArgbEvaluator.getInstance());
    anim.setStartDelay(ANIMATION_DURATION / 2);
    anim.setDuration(ANIMATION_DURATION / 2);
    anim.addUpdateListener(animation -> {
        int color = (int) animation.getAnimatedValue();
        setBackgroundColor(color);
    });
    return anim;
}
项目:pipe    文件:LaunchActivity.java   
/**
 * 给背景设置一个动画
 *
 * @param endProgress 动画的结束进度
 * @param endCallback 动画结束时触发
 */
private void startAnim(float endProgress, final Runnable endCallback) {
    // 获取一个最终的颜色
    int finalColor = Resource.Color.WHITE; // UiCompat.getColor(getResources(), R.color.white);
    // 运算当前进度的颜色
    ArgbEvaluator evaluator = new ArgbEvaluator();
    int endColor = (int) evaluator.evaluate(endProgress, mBgDrawable.getColor(), finalColor);
    // 构建一个属性动画
    ValueAnimator valueAnimator = ObjectAnimator.ofObject(this, property, evaluator, endColor);
    valueAnimator.setDuration(1500); // 时间
    valueAnimator.setIntValues(mBgDrawable.getColor(), endColor); // 开始结束值
    valueAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            // 结束时触发
            endCallback.run();
        }
    });
    valueAnimator.start();
}
项目:Musicoco    文件:BottomNavigationController.java   
private void startTranslatePlayListAnim(float from, float to, int duration, final View view, @Nullable TimeInterpolator interpolator, @Nullable Animator.AnimatorListener listener) {
    final ValueAnimator anim = ObjectAnimator.ofFloat(from, to);
    anim.setDuration(duration);
    if (interpolator != null)
        anim.setInterpolator(interpolator);
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float va = (float) animation.getAnimatedValue();
            view.setY(va);
        }
    });
    if (listener != null) {
        anim.addListener(listener);
    }
    anim.start();
}
项目:RLibrary    文件:EmptyView.java   
private void initAnimator() {
    if (mObjectAnimator == null) {
        mObjectAnimator = ObjectAnimator.ofInt(3, 6);
        mObjectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                int value = (int) animation.getAnimatedValue();
                if (value != last) {
                    last = value;
                    factor = last / 10f;
                    L.e("call: onAnimationUpdate([animation])-> " + factor);
                    postInvalidate();
                }
            }
        });
        mObjectAnimator.setRepeatCount(ValueAnimator.INFINITE);
        mObjectAnimator.setRepeatMode(ValueAnimator.REVERSE);
        mObjectAnimator.setDuration(300);
        mObjectAnimator.start();
    }
}
项目:CoordinatorLayoutExample-master    文件:AnimatorUtil.java   
public static void showHeight(final View view,float  start,float end){
    final ValueAnimator animator=ValueAnimator.ofFloat(start,end);
    final ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float value = (Float) animator.getAnimatedValue();
            layoutParams.height=(int) value;
            view.setLayoutParams(layoutParams);
            Log.i(TAG, "onAnimationUpdate: value="+value);

        }
    });
    animator.setDuration(500);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.start();
}
项目:DailyStudy    文件:BallPulseLoadingView.java   
public List<Animator> createAnimation() {
    List<Animator> animators = new ArrayList<>();
    int[] delays = new int[]{120, 240, 360};
    for (int i = 0; i < 3; i++) {
        final int index = i;

        ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.3f, 1);

        scaleAnim.setDuration(750);
        scaleAnim.setRepeatCount(-1);
        scaleAnim.setStartDelay(delays[i]);

        scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                scaleFloats[index] = (float) animation.getAnimatedValue();
                postInvalidate();

            }
        });
        scaleAnim.start();
        animators.add(scaleAnim);
    }
    return animators;
}
项目:Multi-SwipeToRefreshLayout    文件:BallGridBeatIndicator.java   
@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;
}
项目:LoadingViews    文件:ChaseLoading.java   
/**
 * 开始加载成功动画
 */
private void startSuccessSymbolAnim() {
    currentPath.reset();
    pathMeasure.setPath(successSymbolPath, false);
    pathMeasure.getPosTan(0, mCurrentPosition, null);
    currentPath.moveTo(mCurrentPosition[0], mCurrentPosition[1]);

    ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, pathMeasure.getLength());
    valueAnimator.setDuration(500);
    // 减速插值器
    valueAnimator.setInterpolator(new DecelerateInterpolator());
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            if (isLoading)
                return;
            float value = (Float) animation.getAnimatedValue();
            // 获取当前点坐标封装到mCurrentPosition
            float[] tmp = mCurrentPosition;
            pathMeasure.getPosTan(value, mCurrentPosition, null);
            currentPath.quadTo(tmp[0], tmp[1], mCurrentPosition[0], mCurrentPosition[1]);
            invalidateCallback.redraw();
        }
    });
    valueAnimator.start();
}
项目:IslamicLibraryAndroid    文件:AnimationUtils.java   
public static void addBookmarkWithAnimation(final View bookmarkImage, Animator.AnimatorListener animatorListener) {
    bookmarkImage.setPivotY(0);
    ValueAnimator moveAnim = ObjectAnimator.ofFloat(bookmarkImage, View.SCALE_Y, 0, 1);
    moveAnim.setDuration(1000);
    moveAnim.setInterpolator(new OvershootInterpolator(BOOKMARK_ANIMATING_OVERSHOOT_TENSION));
    moveAnim.addListener(animatorListener);
    moveAnim.start();
}