Java 类com.nineoldandroids.animation.ValueAnimator.AnimatorUpdateListener 实例源码

项目:SimplifyReader2    文件:PlayerDiscView.java   
private void startDiscAnimator(float animatedValue) {
    mDiscLayoutAnimator = ObjectAnimator.ofFloat(mDiscLayout, "rotation", animatedValue, 360 + animatedValue);
    mDiscLayoutAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator arg0) {
            mDiscLayoutAnimatorValue = (Float) arg0.getAnimatedValue();
        }
    });
    mDiscLayoutAnimator.setDuration(DISC_ANIMATOR_TIME);
    mDiscLayoutAnimator.setRepeatCount(DISC_ANIMATOR_REPEAT_COUNT);
    mDiscLayoutAnimator.setInterpolator(new LinearInterpolator());

    if (mDiscLayoutAnimator.isRunning() || mDiscLayoutAnimator.isStarted()) {
        mDiscLayoutAnimator.cancel();
    }

    mDiscLayoutAnimator.start();
}
项目:SimplifyReader2    文件:PlayerDiscView.java   
private void reverseDiscAnimator() {
    mDiscLayoutAnimator = ObjectAnimator.ofFloat(mDiscLayout, "rotation", mDiscLayoutAnimatorValue, 360);
    mDiscLayoutAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator arg0) {
            mDiscLayoutAnimatorValue = (Float) arg0.getAnimatedValue();
        }
    });
    mDiscLayoutAnimator.setDuration(DISC_REVERSE_ANIMATOR_TIME);
    mDiscLayoutAnimator.setInterpolator(new AccelerateInterpolator());

    if (mDiscLayoutAnimator.isRunning() || mDiscLayoutAnimator.isStarted()) {
        mDiscLayoutAnimator.cancel();
    }

    mDiscLayoutAnimator.start();
}
项目:SimplifyReader    文件:PlayerDiscView.java   
private void startDiscAnimator(float animatedValue) {
    mDiscLayoutAnimator = ObjectAnimator.ofFloat(mDiscLayout, "rotation", animatedValue, 360 + animatedValue);
    mDiscLayoutAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator arg0) {
            mDiscLayoutAnimatorValue = (Float) arg0.getAnimatedValue();
        }
    });
    mDiscLayoutAnimator.setDuration(DISC_ANIMATOR_TIME);
    mDiscLayoutAnimator.setRepeatCount(DISC_ANIMATOR_REPEAT_COUNT);
    mDiscLayoutAnimator.setInterpolator(new LinearInterpolator());

    if (mDiscLayoutAnimator.isRunning() || mDiscLayoutAnimator.isStarted()) {
        mDiscLayoutAnimator.cancel();
    }

    mDiscLayoutAnimator.start();
}
项目:SimplifyReader    文件:PlayerDiscView.java   
private void reverseDiscAnimator() {
    mDiscLayoutAnimator = ObjectAnimator.ofFloat(mDiscLayout, "rotation", mDiscLayoutAnimatorValue, 360);
    mDiscLayoutAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator arg0) {
            mDiscLayoutAnimatorValue = (Float) arg0.getAnimatedValue();
        }
    });
    mDiscLayoutAnimator.setDuration(DISC_REVERSE_ANIMATOR_TIME);
    mDiscLayoutAnimator.setInterpolator(new AccelerateInterpolator());

    if (mDiscLayoutAnimator.isRunning() || mDiscLayoutAnimator.isStarted()) {
        mDiscLayoutAnimator.cancel();
    }

    mDiscLayoutAnimator.start();
}
项目:android-art-res    文件:DemoActivity_1.java   
private void performAnimate(final View target, final int start, final int end) {
    ValueAnimator valueAnimator = ValueAnimator.ofInt(1, 100);
    valueAnimator.addUpdateListener(new AnimatorUpdateListener() {

        // 持有一个IntEvaluator对象,方便下面估值的时候使用
        private IntEvaluator mEvaluator = new IntEvaluator();

        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            // 获得当前动画的进度值,整型,1-100之间
            int currentValue = (Integer) animator.getAnimatedValue();
            Log.d(TAG, "current value: " + currentValue);

            // 获得当前进度占整个动画过程的比例,浮点型,0-1之间
            float fraction = animator.getAnimatedFraction();
            // 直接调用整型估值器通过比例计算出宽度,然后再设给Button
            target.getLayoutParams().width = mEvaluator.evaluate(fraction, start, end);
            target.requestLayout();
        }
    });

    valueAnimator.setDuration(5000).start();
}
项目:FancyProgress    文件:FancyProgress2.java   
public FancyProgress2 show(){
    setVisibility(View.VISIBLE);
    mAnim = ValueAnimator.ofFloat(1.0f);
    mAnim.setInterpolator(new LinearInterpolator());
    mAnim.setDuration(2000);
    mAnim.setRepeatCount(ValueAnimator.INFINITE);
    mAnim.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mPercent = animation.getAnimatedFraction();
            isFront = mPercent < 0.5f;
            invalidate();
        }
    });
    mAnim.start();
    invalidate();

    return this;
}
项目:CardView    文件:CardFaceView.java   
private void onFlagChanged(final CardFlag oldFlag, final CardFlag newFlag) {
    int flagColor = CARD_BACKGROUND_COLOR_NOFLAG;
    if (newFlag != null) {
        flagColor = newFlag.getColor();
    }

    ValueAnimator fade = ObjectAnimator.ofInt(mCardPaint,
            "color", mCardPaint.getColor(), flagColor);
    fade.setDuration(500);
    fade.setEvaluator(new ArgbEvaluator());
    fade.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator value) {
            onFlagChangedUpdate(oldFlag, newFlag, value);
            invalidate();
        }
    });

    fade.start();
}
项目:PeSanKita-android    文件:TransferControlView.java   
private Animator getWidthAnimator(final int from, final int to) {
  final ValueAnimator anim = ValueAnimator.ofInt(from, to);
  anim.addUpdateListener(new AnimatorUpdateListener() {
    @Override
    public void onAnimationUpdate(ValueAnimator animation) {
      final int val = (Integer)animation.getAnimatedValue();
      final ViewGroup.LayoutParams layoutParams = getLayoutParams();
      layoutParams.width = val;
      setLayoutParams(layoutParams);
    }
  });
  anim.setInterpolator(new FastOutSlowInInterpolator());
  anim.setDuration(TRANSITION_MS);
  return anim;
}
项目:boohee_v5.6    文件:AnimationBuilder.java   
public AnimationBuilder custom(final Update update, float... values) {
    for (final View view : this.views) {
        ValueAnimator valueAnimator = ValueAnimator.ofFloat(getValues(values));
        if (update != null) {
            valueAnimator.addUpdateListener(new AnimatorUpdateListener() {
                public void onAnimationUpdate(ValueAnimator animation) {
                    update.update(view, ((Float) animation.getAnimatedValue()).floatValue());
                }
            });
        }
        add(valueAnimator);
    }
    return this;
}
项目:Cable-Android    文件:TransferControlView.java   
private Animator getWidthAnimator(final int from, final int to) {
  final ValueAnimator anim = ValueAnimator.ofInt(from, to);
  anim.addUpdateListener(new AnimatorUpdateListener() {
    @Override
    public void onAnimationUpdate(ValueAnimator animation) {
      final int val = (Integer)animation.getAnimatedValue();
      final ViewGroup.LayoutParams layoutParams = getLayoutParams();
      layoutParams.width = val;
      setLayoutParams(layoutParams);
    }
  });
  anim.setInterpolator(new FastOutSlowInInterpolator());
  anim.setDuration(TRANSITION_MS);
  return anim;
}
项目:Silence    文件:TransferControlView.java   
private Animator getWidthAnimator(final int from, final int to) {
  final ValueAnimator anim = ValueAnimator.ofInt(from, to);
  anim.addUpdateListener(new AnimatorUpdateListener() {
    @Override
    public void onAnimationUpdate(ValueAnimator animation) {
      final int val = (Integer)animation.getAnimatedValue();
      final ViewGroup.LayoutParams layoutParams = getLayoutParams();
      layoutParams.width = val;
      setLayoutParams(layoutParams);
    }
  });
  anim.setInterpolator(new FastOutSlowInInterpolator());
  anim.setDuration(TRANSITION_MS);
  return anim;
}
项目:Conquer    文件:RoundProgressBar.java   
/**
     * 设置进度,此为线程安全控件,由于考虑多线的问题,需要同步 刷新界面调用postInvalidate()能在非UI线程刷新
     *
     * @param progress
     */

    public synchronized void setProgress(int progress) {
        if (this.progress == progress) {
            return;
        }

//        hasShowing = true;
        if (progress < 0) {
//          throw new IllegalArgumentException("progress not less than 0");
            return;
        }
        if (progress > max) {
            progress = max;
        }
        ValueAnimator va = ValueAnimator.ofInt(this.progress, progress);
        va.setDuration(1000);
        va.setInterpolator(new AccelerateInterpolator());
        va.start();
        va.addUpdateListener(new AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator arg0) {
                int value = (Integer) arg0.getAnimatedValue();
                if (value <= max) {
                    RoundProgressBar.this.progress = value;
                    invalidate();
                }
            }
        });

    }
项目:NineOldAndroids-master    文件:FlakeView.java   
/**
 * Constructor. Create objects used throughout the life of the View: the Paint and
 * the animator
 */
public FlakeView(Context context) {
    super(context);
    droid = BitmapFactory.decodeResource(getResources(), R.drawable.droid);
    textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    textPaint.setColor(Color.WHITE);
    textPaint.setTextSize(24);

    // This listener is where the action is for the flak animations. Every frame of the
    // animation, we calculate the elapsed time and update every flake's position and rotation
    // according to its speed.
    animator.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator arg0) {
            long nowTime = System.currentTimeMillis();
            float secs = (float)(nowTime - prevTime) / 1000f;
            prevTime = nowTime;
            for (int i = 0; i < numFlakes; ++i) {
                Flake flake = flakes.get(i);
                flake.y += (flake.speed * secs);
                if (flake.y > getHeight()) {
                    // If a flake falls off the bottom, send it back to the top
                    flake.y = 0 - flake.height;
                }
                flake.rotation = flake.rotation + (flake.rotationSpeed * secs);
            }
            // Force a redraw to see the flakes in their new positions and orientations
            invalidate();
        }
    });
    animator.setRepeatCount(ValueAnimator.INFINITE);
    animator.setDuration(3000);
}
项目:FancyProgress    文件:FancyProgress4.java   
public void show(){
    mAnim = ValueAnimator.ofFloat(1.0f);
    mAnim.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mPercent = animation.getAnimatedFraction();
            invalidate();
        }
    });
    mAnim.setInterpolator(new LinearInterpolator());
    mAnim.setRepeatCount(ValueAnimator.INFINITE);
    mAnim.setDuration(mOneShotDuration * 4);
    mAnim.start();
}
项目:projectTetViet    文件:FlakeView.java   
/**
     * Constructor. Create objects used throughout the life of the View: the
     * Paint and the animator
     */
    public FlakeView(Context context) {
        super(context);
        droid = BitmapFactory.decodeResource(getResources(),
                R.drawable.white_snow);
        snowImg = BitmapFactory.decodeResource(getResources(),
                R.drawable.white_snow);
        daoFlowerImg1 = BitmapFactory.decodeResource(getResources(),
                R.drawable.flower1);
        daoFlowerImg2 = BitmapFactory.decodeResource(getResources(),
                R.drawable.flower2);
//      daoFlowerImg3 = BitmapFactory.decodeResource(getResources(),
//              R.drawable.flower3);
//      heartImg = BitmapFactory.decodeResource(getResources(),
//              R.drawable.heart);

        textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        textPaint.setColor(Color.WHITE);
        textPaint.setTextSize(24);

        // This listener is where the action is for the flak animations. Every
        // frame of the
        // animation, we calculate the elapsed time and update every flake's
        // position and rotation
        // according to its speed.
        animator.addUpdateListener(new AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator arg0) {
                long nowTime = System.currentTimeMillis();
                float secs = (float) (nowTime - prevTime) / 1000f;
                prevTime = nowTime;
                for (int i = 0; i < numFlakes; ++i) {
                    Flake flake = flakes.get(i);
                    flake.y += (flake.speed * secs);
                    if (flake.y > getHeight()) {
                        // If a flake falls off the bottom, send it back to the
                        // top
                        flake.y = 0 - flake.height;
                    }
                    flake.rotation = flake.rotation
                            + (flake.rotationSpeed * secs);
                }
                // Force a redraw to see the flakes in their new positions and
                // orientations
                invalidate();
            }
        });
        animator.setRepeatCount(ValueAnimator.INFINITE);
        animator.setDuration(3000);
    }