android.animation.ObjectAnimator.addUpdateListener()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(13.5k)|赞(0)|评价(0)|浏览(173)

本文整理了Java中android.animation.ObjectAnimator.addUpdateListener()方法的一些代码示例,展示了ObjectAnimator.addUpdateListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectAnimator.addUpdateListener()方法的具体详情如下:
包路径:android.animation.ObjectAnimator
类名称:ObjectAnimator
方法名:addUpdateListener

ObjectAnimator.addUpdateListener介绍

暂无

代码示例

代码示例来源:origin: PhilJay/MPAndroidChart

public AnimatedViewPortJob(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, View v, float xOrigin, float yOrigin, long duration) {
  super(viewPortHandler, xValue, yValue, trans, v);
  this.xOrigin = xOrigin;
  this.yOrigin = yOrigin;
  animator = ObjectAnimator.ofFloat(this, "phase", 0f, 1f);
  animator.setDuration(duration);
  animator.addUpdateListener(this);
  animator.addListener(this);
}

代码示例来源:origin: EverythingMe/overscroll-decor

protected ObjectAnimator createSlowdownAnimator(View view, int slowdownDuration, float slowdownEndOffset) {
  ObjectAnimator slowdownAnim = ObjectAnimator.ofFloat(view, mAnimAttributes.mProperty, slowdownEndOffset);
  slowdownAnim.setDuration(slowdownDuration);
  slowdownAnim.setInterpolator(mBounceBackInterpolator);
  slowdownAnim.addUpdateListener(this);
  return slowdownAnim;
}

代码示例来源:origin: PhilJay/MPAndroidChart

/**
   * Applys a spin animation to the Chart.
   *
   * @param durationmillis
   * @param fromangle
   * @param toangle
   */
  @SuppressLint("NewApi")
  public void spin(int durationmillis, float fromangle, float toangle, EasingFunction easing) {

    setRotationAngle(fromangle);

    ObjectAnimator spinAnimator = ObjectAnimator.ofFloat(this, "rotationAngle", fromangle,
        toangle);
    spinAnimator.setDuration(durationmillis);
    spinAnimator.setInterpolator(easing);

    spinAnimator.addUpdateListener(new AnimatorUpdateListener() {

      @Override
      public void onAnimationUpdate(ValueAnimator animation) {
        postInvalidate();
      }
    });
    spinAnimator.start();
  }
}

代码示例来源:origin: PhilJay/MPAndroidChart

/**
 * Animates values along the Y axis.
 *
 * @param durationMillis animation duration
 * @param easing EasingFunction
 */
@RequiresApi(11)
public void animateY(int durationMillis, EasingFunction easing) {
  ObjectAnimator animatorY = yAnimator(durationMillis, easing);
  animatorY.addUpdateListener(mListener);
  animatorY.start();
}

代码示例来源:origin: PhilJay/MPAndroidChart

/**
 * Animates values along the X axis.
 *
 * @param durationMillis animation duration
 * @param easing EasingFunction
 */
@RequiresApi(11)
public void animateX(int durationMillis, EasingFunction easing) {
  ObjectAnimator animatorX = xAnimator(durationMillis, easing);
  animatorX.addUpdateListener(mListener);
  animatorX.start();
}

代码示例来源:origin: PhilJay/MPAndroidChart

/**
 * Animates values along both the X and Y axes.
 *
 * @param durationMillisX animation duration along the X axis
 * @param durationMillisY animation duration along the Y axis
 * @param easing EasingFunction for both axes
 */
@RequiresApi(11)
public void animateXY(int durationMillisX, int durationMillisY, EasingFunction easing) {
  ObjectAnimator xAnimator = xAnimator(durationMillisX, easing);
  ObjectAnimator yAnimator = yAnimator(durationMillisY, easing);
  if (durationMillisX > durationMillisY) {
    xAnimator.addUpdateListener(mListener);
  } else {
    yAnimator.addUpdateListener(mListener);
  }
  xAnimator.start();
  yAnimator.start();
}

代码示例来源:origin: PhilJay/MPAndroidChart

/**
 * Animates values along both the X and Y axes.
 *
 * @param durationMillisX animation duration along the X axis
 * @param durationMillisY animation duration along the Y axis
 * @param easingX EasingFunction for the X axis
 * @param easingY EasingFunction for the Y axis
 */
@RequiresApi(11)
public void animateXY(int durationMillisX, int durationMillisY, EasingFunction easingX,
           EasingFunction easingY) {
  ObjectAnimator xAnimator = xAnimator(durationMillisX, easingX);
  ObjectAnimator yAnimator = yAnimator(durationMillisY, easingY);
  if (durationMillisX > durationMillisY) {
    xAnimator.addUpdateListener(mListener);
  } else {
    yAnimator.addUpdateListener(mListener);
  }
  xAnimator.start();
  yAnimator.start();
}

代码示例来源:origin: EverythingMe/overscroll-decor

protected ObjectAnimator createBounceBackAnimator(float startOffset) {
    final View view = mViewAdapter.getView();
    // Duration is proportional to the view's size.
    float bounceBackDuration = (Math.abs(startOffset) / mAnimAttributes.mMaxOffset) * MAX_BOUNCE_BACK_DURATION_MS;
    ObjectAnimator bounceBackAnim = ObjectAnimator.ofFloat(view, mAnimAttributes.mProperty, mStartAttr.mAbsOffset);
    bounceBackAnim.setDuration(Math.max((int) bounceBackDuration, MIN_BOUNCE_BACK_DURATION_MS));
    bounceBackAnim.setInterpolator(mBounceBackInterpolator);
    bounceBackAnim.addUpdateListener(this);
    return bounceBackAnim;
  }
}

代码示例来源:origin: PhilJay/MPAndroidChart

protected void resetAnimator(){
  animator.removeAllListeners();
  animator.removeAllUpdateListeners();
  animator.reverse();
  animator.addUpdateListener(this);
  animator.addListener(this);
}

代码示例来源:origin: seven332/EhViewer

private void hideSlider(View sliderPanel) {
  if (null != mSeekBarPanelAnimator) {
    mSeekBarPanelAnimator.cancel();
    mSeekBarPanelAnimator = null;
  }
  mSeekBarPanelAnimator = ObjectAnimator.ofFloat(sliderPanel, "translationY", sliderPanel.getHeight());
  mSeekBarPanelAnimator.setDuration(SLIDER_ANIMATION_DURING);
  mSeekBarPanelAnimator.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR);
  mSeekBarPanelAnimator.addUpdateListener(mUpdateSliderListener);
  mSeekBarPanelAnimator.addListener(mHideSliderListener);
  mSeekBarPanelAnimator.start();
  if (null != mSystemUiHelper) {
    mSystemUiHelper.hide();
    mShowSystemUi = false;
  }
}

代码示例来源:origin: seven332/EhViewer

private void showSlider(View sliderPanel) {
  if (null != mSeekBarPanelAnimator) {
    mSeekBarPanelAnimator.cancel();
    mSeekBarPanelAnimator = null;
  }
  sliderPanel.setTranslationY(sliderPanel.getHeight());
  sliderPanel.setVisibility(View.VISIBLE);
  mSeekBarPanelAnimator = ObjectAnimator.ofFloat(sliderPanel, "translationY", 0.0f);
  mSeekBarPanelAnimator.setDuration(SLIDER_ANIMATION_DURING);
  mSeekBarPanelAnimator.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR);
  mSeekBarPanelAnimator.addUpdateListener(mUpdateSliderListener);
  mSeekBarPanelAnimator.addListener(mShowSliderListener);
  mSeekBarPanelAnimator.start();
  if (null != mSystemUiHelper) {
    mSystemUiHelper.show();
    mShowSystemUi = true;
  }
}

代码示例来源:origin: aurelhubert/ahbottomnavigation

/**
 * Manage animation for Android < KITKAT
 *
 * @param child
 */
private void ensureOrCancelObjectAnimation(final V child, final int offset, boolean withAnimation) {
  if (translationObjectAnimator != null) {
    translationObjectAnimator.cancel();
  }
  translationObjectAnimator = ObjectAnimator.ofFloat(child, View.TRANSLATION_Y, offset);
  translationObjectAnimator.setDuration(withAnimation ? ANIM_DURATION : 0);
  translationObjectAnimator.setInterpolator(INTERPOLATOR);
  translationObjectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
    @Override
    public void onAnimationUpdate(ValueAnimator animation) {
      if (snackbarLayout != null && snackbarLayout.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
        targetOffset = child.getMeasuredHeight() - child.getTranslationY();
        ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) snackbarLayout.getLayoutParams();
        p.setMargins(p.leftMargin, p.topMargin, p.rightMargin, (int) targetOffset);
        snackbarLayout.requestLayout();
      }
      // Pass navigation height to listener
      if (navigationPositionListener != null) {
        navigationPositionListener.onPositionChange((int) (child.getMeasuredHeight() - child.getTranslationY() + snackBarY));
      }
    }
  });
}

代码示例来源:origin: 500px/500px-android-blur

for (ImageView imageView : mImageViews) {
  ObjectAnimator tx = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_X, (mRandom.nextFloat() - 0.5f) * 500);
  tx.addUpdateListener(listener);
  ObjectAnimator ty = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_Y, (mRandom.nextFloat() - 0.5f) * 500);
  ty.addUpdateListener(listener);
  AnimatorSet set = new AnimatorSet();
  set.playTogether(tx, ty);
for (ImageView imageView : mImageViews) {
  ObjectAnimator tx = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_X, 0);
  tx.addUpdateListener(listener);
  ObjectAnimator ty = ObjectAnimator.ofFloat(imageView, View.TRANSLATION_Y, 0);
  ty.addUpdateListener(listener);
  AnimatorSet set = new AnimatorSet();
  set.playTogether(tx, ty);

代码示例来源:origin: xinghongfei/LookLook

@Override
  public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
    if (!meizi.hasFadedIn) {
      holder.imageView.setHasTransientState(true);
      final ObservableColorMatrix cm = new ObservableColorMatrix();
      final ObjectAnimator animator = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f);
      animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
          holder.imageView.setColorFilter(new ColorMatrixColorFilter(cm));
        }
      });
      animator.setDuration(2000L);
      animator.setInterpolator(new AccelerateInterpolator());
      animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
          super.onAnimationEnd(animation);
          holder.imageView.clearColorFilter();
          holder.imageView.setHasTransientState(false);
          animator.start();
          meizi.hasFadedIn = true;
        }
      });
    }
    return false;
  }
}).diskCacheStrategy(DiskCacheStrategy.SOURCE)

代码示例来源:origin: xinghongfei/LookLook

@Override
  public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
    if (!zhihuDailyItem.hasFadedIn) {
      holder.imageView.setHasTransientState(true);
      final ObservableColorMatrix cm = new ObservableColorMatrix();
      final ObjectAnimator animator = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f);
      animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
          holder.imageView.setColorFilter(new ColorMatrixColorFilter(cm));
        }
      });
      animator.setDuration(2000L);
      animator.setInterpolator(new AccelerateInterpolator());
      animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
          super.onAnimationEnd(animation);
          holder.imageView.clearColorFilter();
          holder.imageView.setHasTransientState(false);
          animator.start();
          zhihuDailyItem.hasFadedIn = true;
        }
      });
    }
    return false;
  }
}).diskCacheStrategy(DiskCacheStrategy.SOURCE)

代码示例来源:origin: xinghongfei/LookLook

@Override
  public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
    if (!newsBeanItem.hasFadedIn) {
      holder.imageView.setHasTransientState(true);
      final ObservableColorMatrix cm = new ObservableColorMatrix();
      final ObjectAnimator animator = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f);
      animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
          holder.imageView.setColorFilter(new ColorMatrixColorFilter(cm));
        }
      });
      animator.setDuration(2000L);
      animator.setInterpolator(new AccelerateInterpolator());
      animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
          super.onAnimationEnd(animation);
          holder.imageView.clearColorFilter();
          holder.imageView.setHasTransientState(false);
          animator.start();
          newsBeanItem.hasFadedIn = true;
        }
      });
    }
    return false;
  }
}).diskCacheStrategy(DiskCacheStrategy.SOURCE)

代码示例来源:origin: wdullaer/MaterialDateTimePicker

public ObjectAnimator getDisappearAnimator() {
  if (!mIsInitialized || !mDrawValuesReady) {
    Log.e(TAG, "RadialSelectorView was not ready for animation.");
    return null;
  }
  Keyframe kf0, kf1, kf2;
  float midwayPoint = 0.2f;
  int duration = 500;
  kf0 = Keyframe.ofFloat(0f, 1);
  kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
  kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier);
  PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe(
      "animationRadiusMultiplier", kf0, kf1, kf2);
  kf0 = Keyframe.ofFloat(0f, 1f);
  kf1 = Keyframe.ofFloat(1f, 0f);
  PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);
  ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
      this, radiusDisappear, fadeOut).setDuration(duration);
  disappearAnimator.addUpdateListener(mInvalidateUpdateListener);
  return disappearAnimator;
}

代码示例来源:origin: iSoron/uhabits

public ObjectAnimator getDisappearAnimator() {
  if (!mIsInitialized || !mDrawValuesReady) {
    Log.e(TAG, "RadialSelectorView was not ready for animation.");
    return null;
  }
  Keyframe kf0, kf1, kf2;
  float midwayPoint = 0.2f;
  int duration = 500;
  kf0 = Keyframe.ofFloat(0f, 1);
  kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
  kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier);
  PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe(
      "animationRadiusMultiplier", kf0, kf1, kf2);
  kf0 = Keyframe.ofFloat(0f, 1f);
  kf1 = Keyframe.ofFloat(1f, 0f);
  PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);
  ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
      this, radiusDisappear, fadeOut).setDuration(duration);
  disappearAnimator.addUpdateListener(mInvalidateUpdateListener);
  return disappearAnimator;
}

代码示例来源:origin: wangdan/AisenWeiBo

public ObjectAnimator getDisappearAnimator() {
  if (!mIsInitialized || !mDrawValuesReady) {
    Log.e(TAG, "RadialSelectorView was not ready for animation.");
    return null;
  }
  Keyframe kf0, kf1, kf2;
  float midwayPoint = 0.2f;
  int duration = 500;
  kf0 = Keyframe.ofFloat(0f, 1);
  kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
  kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier);
  PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe(
      "animationRadiusMultiplier", kf0, kf1, kf2);
  kf0 = Keyframe.ofFloat(0f, 1f);
  kf1 = Keyframe.ofFloat(1f, 0f);
  PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);
  ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(
      this, radiusDisappear, fadeOut).setDuration(duration);
  disappearAnimator.addUpdateListener(mInvalidateUpdateListener);
  return disappearAnimator;
}

代码示例来源:origin: wdullaer/MaterialDateTimePicker

reappearAnimator.addUpdateListener(mInvalidateUpdateListener);
return reappearAnimator;

相关文章