예제 #1
0
  private void startUnCheckedAnimation() {
    ValueAnimator animator = ValueAnimator.ofFloat(0f, 1.0f);
    animator.setDuration(mAnimDuration);
    animator.setInterpolator(new LinearInterpolator());
    animator.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            mScaleVal = (float) animation.getAnimatedValue();
            mFloorColor = getGradientColor(mCheckedColor, COLOR_FLOOR_UNCHECKED, mScaleVal);
            postInvalidate();
          }
        });
    animator.start();

    ValueAnimator floorAnimator = ValueAnimator.ofFloat(1.0f, 0.8f, 1.0f);
    floorAnimator.setDuration(mAnimDuration);
    floorAnimator.setInterpolator(new LinearInterpolator());
    floorAnimator.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            mFloorScale = (float) animation.getAnimatedValue();
            postInvalidate();
          }
        });
    floorAnimator.start();
  }
예제 #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();
  }
예제 #3
0
파일: FlipView.java 프로젝트: Y-bao/Android
  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();
  }
  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();
  }
  @Override
  public List<Animator> createAnimation() {
    List<Animator> animators = new ArrayList<>();
    float startX = getWidth() / 6;
    float startY = getWidth() / 6;
    for (int i = 0; i < 2; i++) {
      final int index = i;
      ValueAnimator translateXAnim =
          ValueAnimator.ofFloat(startX, getWidth() - startX, getWidth() / 2, startX);
      if (i == 1) {
        translateXAnim =
            ValueAnimator.ofFloat(getWidth() - startX, startX, getWidth() / 2, getWidth() - startX);
      }
      ValueAnimator translateYAnim = ValueAnimator.ofFloat(startY, startY, getHeight() / 2, startY);
      if (i == 1) {
        translateYAnim =
            ValueAnimator.ofFloat(
                getHeight() - startY, getHeight() - startY, getHeight() / 2, getHeight() - startY);
      }

      translateXAnim.setDuration(1000);
      translateXAnim.setInterpolator(new LinearInterpolator());
      translateXAnim.setRepeatCount(-1);
      translateXAnim.addUpdateListener(
          new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
              translateX[index] = (float) animation.getAnimatedValue();
              postInvalidate();
            }
          });
      translateXAnim.start();

      translateYAnim.setDuration(1000);
      translateYAnim.setInterpolator(new LinearInterpolator());
      translateYAnim.setRepeatCount(-1);
      translateYAnim.addUpdateListener(
          new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
              translateY[index] = (float) animation.getAnimatedValue();
              postInvalidate();
            }
          });
      translateYAnim.start();
      animators.add(translateXAnim);
      animators.add(translateYAnim);
    }
    return animators;
  }
예제 #6
0
  /**
   * Set the thumb to be in the normal/un-pressed state and calls invalidate() to redraw the canvas
   * to reflect the updated state.
   *
   * @param thumb the thumb to release
   */
  private void releasePin(final PinView thumb) {

    final float nearestTickX = mBar.getNearestTickCoordinate(thumb);
    thumb.setX(nearestTickX);
    int tickIndex = mBar.getNearestTickIndex(thumb);
    thumb.setXValue(getPinValue(tickIndex));

    if (mArePinsTemporary) {
      ValueAnimator animator = ValueAnimator.ofFloat(mExpandedPinRadius, 0);
      animator.addUpdateListener(
          new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
              mThumbRadiusDP = (Float) (animation.getAnimatedValue());
              thumb.setSize(
                  mThumbRadiusDP, mPinPadding - (mPinPadding * animation.getAnimatedFraction()));
              invalidate();
            }
          });
      animator.start();
    } else {
      invalidate();
    }

    thumb.release();
  }
예제 #7
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();
 }
예제 #8
0
 private void startAnim() {
   ValueAnimator valueAnimator =
       ValueAnimator.ofFloat(mActiveCircle.angle, mActiveCircle.angle + 360);
   valueAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
   valueAnimator.setDuration(2500);
   valueAnimator.setRepeatCount(Animation.INFINITE);
   valueAnimator.start();
   valueAnimator.addUpdateListener(
       new ValueAnimator.AnimatorUpdateListener() {
         @Override
         public void onAnimationUpdate(ValueAnimator animation) {
           float angle = (Float) animation.getAnimatedValue();
           mActiveCircle.x =
               (float)
                   (mCenterCircle.x
                       + (mCenterCircleRadius + mWallCircleRadius)
                           * Math.cos(Math.toRadians(angle)));
           mActiveCircle.y =
               (float)
                   (mCenterCircle.y
                       + (mCenterCircleRadius + mWallCircleRadius)
                           * Math.sin(Math.toRadians(angle)));
           invalidate();
         }
       });
 }
 public void perform() {
   ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1);
   valueAnimator.setInterpolator(ANIMATION_INTERP);
   valueAnimator.addUpdateListener(this);
   valueAnimator.addListener(this);
   valueAnimator.start();
 }
예제 #10
0
 private void showCheck() {
   if (isAnim) {
     return;
   }
   isAnim = true;
   ValueAnimator va = ValueAnimator.ofFloat(0, 1).setDuration(animDurtion);
   va.setInterpolator(new LinearInterpolator());
   va.start();
   va.addUpdateListener(
       new ValueAnimator.AnimatorUpdateListener() {
         @Override
         public void onAnimationUpdate(ValueAnimator animation) {
           float value = (float) animation.getAnimatedValue(); // 0f ~ 1f
           radius = (int) (value * height * 0.37f + height * 0.125f);
           if (value >= 1) {
             isChecked = true;
             isAnim = false;
             if (listener != null) {
               listener.onCheckedChanged(AnimatedCheckBox.this, true);
             }
             showCorrect();
           }
           invalidate();
         }
       });
 }
 @Override
 public List<Animator> createAnimation() {
   List<Animator> animators = new ArrayList<>();
   float circleSpacing = 4;
   float radius = (getWidth() - circleSpacing * 2) / 6;
   int[] delays = new int[] {70, 140, 210};
   for (int i = 0; i < 3; i++) {
     final int index = i;
     ValueAnimator scaleAnim =
         ValueAnimator.ofFloat(getHeight() / 2, getHeight() / 2 - radius * 2, getHeight() / 2);
     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();
           }
         });
     scaleAnim.start();
     animators.add(scaleAnim);
   }
   return animators;
 }
  @Override
  public List<Animator> createAnimation() {
    ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.3f, 1);
    scaleAnim.setDuration(1000);
    scaleAnim.setRepeatCount(-1);
    scaleAnim.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            scaleFloat1 = (float) animation.getAnimatedValue();
            postInvalidate();
          }
        });
    scaleAnim.start();

    ValueAnimator scaleAnim2 = ValueAnimator.ofFloat(1, 0.6f, 1);
    scaleAnim2.setDuration(1000);
    scaleAnim2.setRepeatCount(-1);
    scaleAnim2.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            scaleFloat2 = (float) animation.getAnimatedValue();
            postInvalidate();
          }
        });
    scaleAnim2.start();

    ValueAnimator rotateAnim = ValueAnimator.ofFloat(0, 180, 360);
    rotateAnim.setDuration(1000);
    rotateAnim.setRepeatCount(-1);
    rotateAnim.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            degrees = (float) animation.getAnimatedValue();
            postInvalidate();
          }
        });
    rotateAnim.start();
    List<Animator> animators = new ArrayList<>();
    animators.add(scaleAnim);
    animators.add(scaleAnim2);
    animators.add(rotateAnim);
    return animators;
  }
  private void init(Context context, AttributeSet attrs) {
    // merge label must be used with attachToRoot=true
    LayoutInflater.from(context).inflate(R.layout.layout_mars_view, this);
    imgMars = (ImageView) findViewById(R.id.netease_mars_img_mars);
    imgMarsCircle = (ImageView) findViewById(R.id.netease_mars_img_mars_circle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NetEaseMarsView);
    int marsDrawableRes =
        a.getResourceId(R.styleable.NetEaseMarsView_marsDrawable, R.drawable.netease_refresh_mars);
    int circleDrawableRes =
        a.getResourceId(
            R.styleable.NetEaseMarsView_marsCircleDrawable, R.drawable.netease_refresh_mars_circle);
    imgMars.setImageResource(marsDrawableRes);
    imgMarsCircle.setImageResource(circleDrawableRes);

    circleAnimDuration = a.getInt(R.styleable.NetEaseMarsView_animationDuration, 1000);
    a.recycle();

    circleAnimators = new AnimatorSet();
    ValueAnimator scaleXAnimator = ValueAnimator.ofFloat(1, 0.5F, 1, 0.5F, 1);
    setAnimators(scaleXAnimator);
    scaleXAnimator.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            circleScaleX = (float) animation.getAnimatedValue();
            postInvalidate();
          }
        });

    ValueAnimator translateYAnimator = ValueAnimator.ofFloat(0F, -0.5F, 0F, 0.5F, 0F);
    setAnimators(translateYAnimator);
    translateYAnimator.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            circleTranslateY = (float) animation.getAnimatedValue();
            postInvalidate();
          }
        });

    circleAnimators.playTogether(scaleXAnimator, translateYAnimator);
  }
 public void setQsbSearchBar(View qsb) {
   mQSBSearchBar = qsb;
   if (mQSBSearchBar != null) {
     mHideSearchBarAnim = LauncherAnimUtils.ofFloat(mQSBSearchBar, "alpha", 1f, 0f);
     setupAnimation(mHideSearchBarAnim, mQSBSearchBar);
   } else {
     // Create a no-op animation of the search bar is null
     mHideSearchBarAnim = ValueAnimator.ofFloat(0, 0);
     mHideSearchBarAnim.setDuration(TRANSITION_DURATION);
   }
 }
예제 #15
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();
 }
 /**
  * This a animates a "blend-in" animation of the figure. The duration can be customised.
  *
  * @param duration The duration in milliseconds
  */
 public void animateText(int duration) {
   ValueAnimator animation = ValueAnimator.ofFloat(0f, 1f);
   animation.setDuration(duration);
   animation.addUpdateListener(
       new ValueAnimator.AnimatorUpdateListener() {
         @Override
         public void onAnimationUpdate(ValueAnimator valueAnimator) {
           setAlphaValue((Float) valueAnimator.getAnimatedValue());
         }
       });
   animation.start();
 }
    protected void updateAccuracy(@NonNull Location location) {
      if (accuracyAnimator != null && accuracyAnimator.isRunning()) {
        // use current accuracy as a starting point
        accuracy = (Float) accuracyAnimator.getAnimatedValue();
        accuracyAnimator.end();
      }

      accuracyAnimator = ValueAnimator.ofFloat(accuracy * 10, location.getAccuracy() * 10);
      accuracyAnimator.setDuration(750);
      accuracyAnimator.start();
      accuracy = location.getAccuracy();
    }
예제 #18
0
  protected void animate(final ImageView backgroundImage) {
    backgroundImage.setScaleType(ImageView.ScaleType.MATRIX);

    final float scaleFactor =
        (float) backgroundImage.getHeight()
            / (float) backgroundImage.getDrawable().getIntrinsicHeight()
            * 1.25f;
    matrix.postScale(scaleFactor, scaleFactor);
    matrix.postTranslate(
        -value * (float) Math.cos(angle), value * (float) Math.sin(angle)); // Translates the matrix
    backgroundImage.setImageMatrix(matrix);

    ValueAnimator animator; // Creates an animator that goes from 0->100 or 100->0
    if (value == 0) animator = ValueAnimator.ofFloat(0, 100);
    else animator = ValueAnimator.ofFloat(value, 0);

    // Updater that translates the image in the direction
    animator.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            value = (float) animation.getAnimatedValue();
            matrix.reset();
            matrix.postScale(scaleFactor, scaleFactor);
            matrix.postTranslate(-value * (float) Math.cos(angle), value * (float) Math.sin(angle));
            backgroundImage.setImageMatrix(matrix);
          }
        });
    animator.addListener(
        new AnimatorListenerAdapter() {
          @Override
          public void onAnimationEnd(Animator animation) {
            animate(backgroundImage);
          }
        });
    animator.setDuration(value == -1 ? 10 : 50000);
    animator.setInterpolator(new LinearInterpolator());
    animator.setStartDelay(0);
    animator.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();
  }
예제 #20
0
  /** Fluid animation for map centering. */
  public void runCenterMapAnim(double lat, double lng) {
    final float latInit = (float) mv.getCenter().getLatitude();
    float lngInit = (float) mv.getCenter().getLongitude();

    ValueAnimator animationLat;
    ValueAnimator animationLng;

    animationLat = ValueAnimator.ofFloat(latInit, (float) lat);
    animationLng = ValueAnimator.ofFloat(lngInit, (float) lng);

    animationLat.setInterpolator(new DecelerateInterpolator());
    animationLat.setDuration(500);
    animationLng.setInterpolator(new DecelerateInterpolator());
    animationLng.setDuration(500);

    animationLat.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            if (animation.getAnimatedValue() instanceof Float) {
              float latValue = ((Float) animation.getAnimatedValue());
              mv.setCenter(new LatLng(latValue, mv.getCenter().getLongitude()));
            }
          }
        });
    animationLng.addUpdateListener(
        new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
            if (animation.getAnimatedValue() instanceof Float) {
              float lngValue = ((Float) animation.getAnimatedValue());
              mv.setCenter(new LatLng(mv.getCenter().getLatitude(), lngValue));
            }
          }
        });
    AnimatorSet a = new AnimatorSet();
    a.playTogether(animationLat, animationLng);
    mv.setZoom(17f);
    a.start();
  }
예제 #21
0
 /** 自由落体 */
 public void verticalRun(View view) {
   ValueAnimator ani = ValueAnimator.ofFloat(0f, mY);
   ani.setTarget(view);
   ani.setDuration(1000);
   ani.addUpdateListener(
       new AnimatorUpdateListener() {
         @Override
         public void onAnimationUpdate(ValueAnimator animation) {
           ivBall.setTranslationY((Float) animation.getAnimatedValue());
         }
       });
   ani.start();
 }
예제 #22
0
  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();
          }
        });
  }
예제 #23
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) {}
          });
    }
  }
예제 #24
0
 /** 第一次展现 饼图的动画 */
 public void aniShowPie() {
   Log.i("显示控件前设置变量代码执行顺序", "饼图展现动画--aniShowPie()");
   if (fillOut) {
     // --setPiedata---到aniShowPie 此时just还没拿到数据(just在onsizechange里面获取值得)
     ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, pieRadius).setDuration(PIEANITIME);
     valueAnimator.setInterpolator(pieInterpolator);
     valueAnimator.start();
     valueAnimator.addUpdateListener(
         new AnimatorUpdateListener() {
           @Override
           public void onAnimationUpdate(ValueAnimator animation) {
             fillouting = (float) animation.getAnimatedValue();
             postInvalidate();
           }
         });
     return;
   }
   //  ---够函--setPiedata---到aniShowPie ---onsizechange----ondraw
   ValueAnimator animator = ValueAnimator.ofFloat(360, 0).setDuration(PIEANITIME);
   animator.setInterpolator(pieInterpolator);
   animator.start();
   animator.addUpdateListener(
       new AnimatorUpdateListener() {
         @Override
         public void onAnimationUpdate(ValueAnimator animation) {
           sweep4 = (float) animation.getAnimatedValue();
           //				if (sweep4<0.3) {
           //					//设置 提示线可见  非背景色非 扫描扇形的颜色
           //					TsColor = backColor;
           //				}else{
           //					TsColor = Color.BLACK;
           //				}
           postInvalidate();
         }
       });
 }
 // valueanimator to animate fractional values which are then set to the object
 public void runValueAnimator(final View view) {
   ValueAnimator anim = ValueAnimator.ofFloat(0, 400);
   anim.setDuration(1000);
   anim.addUpdateListener(
       new ValueAnimator.AnimatorUpdateListener() {
         @Override
         public void onAnimationUpdate(final ValueAnimator animation) {
           float fraction = animation.getAnimatedFraction();
           ((Button) view).setText(String.valueOf(animation.getAnimatedFraction()));
           view.setTranslationX(TX_START + fraction * (TX_END - TX_START));
           view.setTranslationY(TY_START + fraction * (TY_END - TY_START));
         }
       });
   anim.start();
 }
    @Override
    void updateLatLng(@NonNull final Location location) {
      if (latLng == null) {
        // first location update
        latLng = new LatLng(location);
        locationUpdateTimestamp = SystemClock.elapsedRealtime();
      }

      // update LatLng location
      previousLocation = latLng;
      latLng = new LatLng(location);

      // update LatLng direction
      if (location.hasBearing()) {
        gpsDirection = clamp(location.getBearing() - (float) mapboxMap.getCameraPosition().bearing);
      }

      // update LatLng accuracy
      updateAccuracy(location);

      // calculate updateLatLng time + add some extra offset to improve animation
      long previousUpdateTimeStamp = locationUpdateTimestamp;
      locationUpdateTimestamp = SystemClock.elapsedRealtime();
      long locationUpdateDuration =
          (long) ((locationUpdateTimestamp - previousUpdateTimeStamp) * 1.2);

      // calculate interpolated entity
      interpolatedLocation =
          new LatLng(
              (latLng.getLatitude() + previousLocation.getLatitude()) / 2,
              (latLng.getLongitude() + previousLocation.getLongitude()) / 2);

      // animate changes
      if (locationChangeAnimator != null) {
        locationChangeAnimator.end();
        locationChangeAnimator = null;
      }

      locationChangeAnimator = ValueAnimator.ofFloat(0.0f, 1.0f);
      locationChangeAnimator.setDuration((long) (locationUpdateDuration * 1.2));
      locationChangeAnimator.addUpdateListener(
          new MarkerCoordinateAnimatorListener(this, previousLocation, interpolatedLocation));
      locationChangeAnimator.setInterpolator(new FastOutLinearInInterpolator());
      locationChangeAnimator.start();

      // use interpolated location as current location
      latLng = interpolatedLocation;
    }
 /**
  * 自由落体
  *
  * @param view
  */
 public void verticalRun(View view) {
   ValueAnimator animator =
       ValueAnimator.ofFloat(0, mScreenHeight - 2 * mVerticalBall.getHeight());
   animator.setTarget(mVerticalBall); // 设置进行动画的对象
   animator.setDuration(3000).start();
   // Interpolator
   // 被用来修饰动画效果,定义动画的变化率,可以使存在的动画效果accelerated(加速),decelerated(减速),repeated(重复),bounced(弹跳)等。具体并未深究
   // animator.setInterpolator(new AccelerateInterpolator(3f));//加速
   animator.setInterpolator(new LinearInterpolator()); // 弹跳
   animator.addUpdateListener(
       new AnimatorUpdateListener() {
         @Override
         public void onAnimationUpdate(ValueAnimator animation) {
           mVerticalBall.setTranslationY((Float) animation.getAnimatedValue());
         }
       });
 }
  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();
  }
예제 #29
0
 void animateBurger(int targetShape) {
   if (getDrawerToggle() != null) {
     if (targetShape != BURGER && targetShape != ARROW) return;
     ValueAnimator anim = ValueAnimator.ofFloat((targetShape + 1) % 2, targetShape);
     anim.addUpdateListener(
         new ValueAnimator.AnimatorUpdateListener() {
           @Override
           public void onAnimationUpdate(ValueAnimator valueAnimator) {
             float slideOffset = (Float) valueAnimator.getAnimatedValue();
             getDrawerToggle().onDrawerSlide(getDrawerLayout(), slideOffset);
           }
         });
     anim.setInterpolator(new DecelerateInterpolator());
     anim.setDuration(500);
     anim.start();
   }
 }
예제 #30
0
  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);
  }