Example #1
0
  @Override
  public void onAnimationUpdate(ValueAnimator animation) {
    int va = (int) animation.getAnimatedValue();
    if (playing) {
      s = va;
      if (s <= 100) {
        temp1 = (y1 + y2) / 2 + (y1 - y2) / 2 * s / 100;
        temp2 = (y1 + y2) / 2 - (y1 - y2) / 2 * s / 100;
      } else if (s > 900) {
        temp1 = y1 + (y2 - y1) / 2 * (s - 900) / 100;
        temp2 = y2 + (y1 - y2) / 2 * (s - 900) / 100;
      }
      if (va == 1000) {
        playing = false;
        v.cancel();
        if (h != null) h.sendEmptyMessage(0);
      }

    } else {
      s = 0;
      temp1 = y1 + (y2 - y1) / 2 * (va) / 100;
      temp2 = y2 + (y1 - y2) / 2 * (va) / 100;
    }
    invalidate();
  }
  private void transformMaterial(
      int origWidth,
      int targetWidth,
      int origHeight,
      int targetHeight,
      int origRadius,
      int targetRadius,
      ValueAnimator animation) {

    float fraction = (float) animation.getAnimatedValue();
    // update the cardView rounded corners
    mCardView.setRadius(interpolate(origRadius, targetRadius, fraction));

    // update cardview size
    if (origWidth != targetWidth) {
      mCardView.getLayoutParams().width =
          (int) ((targetWidth - origWidth) * (1 - fraction) + origWidth);
    }
    if (origHeight != targetHeight) {
      mCardView.getLayoutParams().height =
          (int) ((targetHeight - origHeight) * (1 - fraction) + origWidth);
    }

    // request the cardview to redraw
    mCardView.requestLayout();
  }
 @Override
 public void onAnimationUpdate(@NonNull ValueAnimator animation) {
   float value = (Float) animation.getAnimatedValue();
   int oldLeft = mTargetView.getLeft();
   int newLeft = MathUtils.lerp(mStartLeft, mEndLeft, value);
   if (mTargetView == mLeftDrawer) slideLeftDrawer(newLeft - oldLeft);
   else slideRightDrawer(newLeft - oldLeft);
 }
Example #4
0
 @Override
 public void onAnimationUpdate(ValueAnimator animation) {
   float value = (Float) animation.getAnimatedValue();
   float[] result = new float[9];
   for (int i = 0; i < 9; i++) {
     result[i] = mStart[i] + (mEnd[i] - mStart[i]) * value;
   }
   mOuterMatrix.setValues(result);
   onOuterMatrixChanged();
   invalidate();
 }
 /** 更新涟漪半径 */
 @Override
 public void onAnimationUpdate(ValueAnimator animation) {
   mChangeRadius01 = (int) animation.getAnimatedValue();
   if (mChangeRadius01 > COMMON_RADIUS + RIPPLE_SPACE_VALUE) {
     mChangeRadius02 = mChangeRadius01 - RIPPLE_SPACE_VALUE;
   }
   if (mChangeRadius01 > COMMON_RADIUS + RIPPLE_SPACE_VALUE * 2) {
     mChangeRadius03 = mChangeRadius01 - RIPPLE_SPACE_VALUE * 2;
   }
   float percent = COMMON_RADIUS / mChangeRadius01;
   setOutCircleAlpha(percent);
   postInvalidate();
 }
  @Override
  public void onDraw(Canvas canvas) {
    ValueAnimator animator = translateAnimator.isRunning() ? translateAnimator : suspendAnimator;
    int xPos = (int) (positionSecondText * (Float) animator.getAnimatedValue()) + getPaddingLeft();
    int yPos = (int) ((canvas.getHeight() / 2) - (adjustTextBaseline / 2));

    canvas.save();
    canvas.clipRect(clipping);
    if (null != splitText && 0 < splitText.length) {
      Integer[] offsets = createVerticalOffsetsFromBaseline(splitText.length);
      for (int i = 0; i < splitText.length; ++i) {
        canvas.drawText(splitText[i], xPos, yPos + offsets[i], paint);
        canvas.drawText(splitText[i], xPos + positionSecondText, yPos + offsets[i], paint);
      }
    }
    canvas.restore();
  }
  private void animate(int direction) {
    final long currentPlayTime = mAnimator.getCurrentPlayTime();
    final float toValue = (direction == IN) ? mOriginalToValue : mOriginalFromValue;
    final float startValue =
        mFirstRun ? mOriginalFromValue : ((Float) mAnimator.getAnimatedValue()).floatValue();

    // Make sure it's stopped before we modify any values
    cancel();

    mDirection = direction;

    // Ensure we don't calculate a non-sensical duration
    long duration = mOriginalDuration - currentPlayTime;
    mAnimator.setDuration(Math.max(0, Math.min(duration, mOriginalDuration)));

    mAnimator.setFloatValues(startValue, toValue);
    mAnimator.start();
    mFirstRun = false;
  }
  private void animate(int direction) {
    final long currentPlayTime = mAnimator.getCurrentPlayTime();
    final float toValue = (direction == IN) ? mOriginalToValue : mOriginalFromValue;
    final float startValue =
        mFirstRun ? mOriginalFromValue : ((Float) mAnimator.getAnimatedValue()).floatValue();

    // Make sure it's stopped before we modify any values
    cancel();

    // TODO: We don't really need to do the animation if startValue == toValue, but
    // somehow that doesn't seem to work, possibly a quirk of the animation framework
    mDirection = direction;

    // Ensure we don't calculate a non-sensical duration
    long duration = mOriginalDuration - currentPlayTime;
    mAnimator.setDuration(Math.max(0, Math.min(duration, mOriginalDuration)));

    mAnimator.setFloatValues(startValue, toValue);
    mAnimator.start();
    mFirstRun = false;
  }
Example #9
0
 @Override
 public void onAnimationUpdate(ValueAnimator animation) {
   // No need for synchronization as this always run on main thread anyway
   TextView v = textView.get();
   if (v != null) {
     if (isAttachedToHierarchy(v)) {
       shift = (Integer) animation.getAnimatedValue();
       v.invalidate();
     } else {
       animation.setCurrentPlayTime(0);
       animation.start();
     }
   } else {
     // The textview has been destroyed and teardown() hasn't been called
     teardown();
     if (BuildConfig.DEBUG) {
       Log.e(
           "JumpingBeans", "!!! Remember to call JumpingBeans.stopJumping() when appropriate !!!");
     }
   }
 }
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (location == null
        || foregroundBounds == null
        || backgroundBounds == null
        || accuracyAnimator == null) {
      // Not ready yet
      return;
    }

    // Draw circle
    float metersPerPixel = (float) projection.getMetersPerPixelAtLatitude(location.getLatitude());
    float accuracyPixels = (Float) accuracyAnimator.getAnimatedValue() / metersPerPixel;
    float maxRadius = getWidth() / 2;
    canvas.drawCircle(
        foregroundBounds.centerX(),
        foregroundBounds.centerY(),
        accuracyPixels <= maxRadius ? accuracyPixels : maxRadius,
        accuracyPaint);

    // Draw shadow
    if (backgroundDrawable != null) {
      backgroundDrawable.draw(canvas);
    }

    // Draw foreground
    if (myBearingTrackingMode == MyBearingTracking.NONE) {
      if (foregroundDrawable != null) {
        foregroundDrawable.draw(canvas);
      }
    } else if (foregroundBearingDrawable != null && foregroundBounds != null) {
      getRotateDrawable(
              foregroundBearingDrawable,
              myBearingTrackingMode == MyBearingTracking.COMPASS ? compassDirection : gpsDirection)
          .draw(canvas);
    }
  }
 protected Float getCurrentCountValue(ValueAnimator animation) {
   return (Float) animation.getAnimatedValue(PROPERTY_VALUE_COUNT);
 }
 @Override
 public void onAnimationUpdate(ValueAnimator animation) {
   super.onAnimationUpdate(animation);
   mView.setTextColor((Integer) animation.getAnimatedValue(ViewConstants.PROPERTY_TEXT_COLOR));
 }
Example #13
0
 public void onAnimationUpdate(ValueAnimator valueAnimator) {
   float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
   this.a.l.setX(((1.0f - floatValue) * this.a.c) + (this.a.e * floatValue));
   this.a.m.setX((floatValue * this.a.e) + ((1.0f - floatValue) * this.a.d));
 }
 /**
  * Notifies the occurrence of another frame of the animation.
  *
  * @param animation The animation which was repeated.
  */
 @Override
 public void onAnimationUpdate(ValueAnimator animation) {
   expand.setRotation((Float) animation.getAnimatedValue());
 }
Example #15
0
 @Override
 public void onAnimationUpdate(ValueAnimator animation) {
   mViewAlpha = (float) animation.getAnimatedValue();
   invalidate();
 }
 @Override
 public void onAnimationUpdate(ValueAnimator animation) {
   setTaskProgress((Float) animation.getAnimatedValue());
 }
 private void updateAnimationFor(@NonNull ValueAnimator animation, @NonNull TextView v) {
   if (isAttachedToHierarchy(v)) {
     shift = (int) animation.getAnimatedValue();
     v.invalidate();
   }
 }