java类android.animation.IntEvaluator的实例源码

BaseActivity.java 文件源码 项目:minu-poska-android 阅读 35 收藏 0 点赞 0 评论 0
@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    if (mMainContent != null) {
        mMainContent.setAlpha(0);
        mMainContent.animate().alpha(1).setDuration(MAIN_CONTENT_FADEIN_DURATION);
    }
    if (mToolbar != null) {
        int[] attrs = {android.R.attr.textColorPrimary};
        TypedArray ta = obtainStyledAttributes(R.style.ToolbarNormalTheme, attrs);
        final int textColor = ta.getColor(0, Color.WHITE);

        ValueAnimator va = ValueAnimator.ofObject(new IntEvaluator(), 0, 255).setDuration(MAIN_CONTENT_FADEIN_DURATION);
        va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                mToolbar.setTitleTextColor(Color.argb((int) animation.getAnimatedValue(), Color.red(textColor), Color.green(textColor), Color.blue(textColor)));
            }
        });
        va.start();
        ta.recycle();
    }
}
BaseActivity.java 文件源码 项目:minu-poska-android 阅读 50 收藏 0 点赞 0 评论 0
protected void preFinish() {
    View mainContent = findViewById(R.id.mainContent);
    if (mainContent != null) {
        mainContent.animate().alpha(0).setDuration(MAIN_CONTENT_FADEOUT_DURATION);
    }
    if (mToolbar != null) {
        int[] attrs = {android.R.attr.textColorPrimary};
        TypedArray ta = obtainStyledAttributes(R.style.ToolbarNormalTheme, attrs);
        final int textColor = ta.getColor(0, Color.WHITE);

        ValueAnimator va = ValueAnimator.ofObject(new IntEvaluator(), 255, 0).setDuration(MAIN_CONTENT_FADEOUT_DURATION);
        va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                mToolbar.setTitleTextColor(Color.argb((int) animation.getAnimatedValue(), Color.red(textColor), Color.green(textColor), Color.blue(textColor)));
            }
        });
        va.start();
        ta.recycle();
    }
}
GestureView.java 文件源码 项目:Jockey 阅读 32 收藏 0 点赞 0 评论 0
/**
 * Animates the overlay to a specified radius, fades it out, and clears the current gesture
 * @param targetRadius The radius to animate the circular overlay to
 * @param time The time for this animation to last
 * @param alphaDelay An optional delay to add before animating the transparency of the overlay
 */
private void animateOutRadius(int targetRadius, int time, int alphaDelay) {
    ObjectAnimator alphaAnim = ObjectAnimator.ofObject(
            this, "overlayAlpha",
            new IntEvaluator(), mAlpha, 0);
    ObjectAnimator radiusAnim = ObjectAnimator.ofObject(
            this, "radius",
            new IntEvaluator(), (isRight() ? radius() : -radius()), targetRadius);

    radiusAnim
            .setDuration(time)
            .setInterpolator(AnimationUtils.loadInterpolator(getContext(),
                    android.R.interpolator.accelerate_quad));
    alphaAnim
            .setDuration(time)
            .setInterpolator(AnimationUtils.loadInterpolator(getContext(),
                    android.R.interpolator.accelerate_quad));

    radiusAnim.start();
    alphaAnim.setStartDelay(alphaDelay);
    alphaAnim.start();
}
Nearby.java 文件源码 项目:downtown 阅读 30 收藏 0 点赞 0 评论 0
@SuppressLint("NewApi")
private void drawCircle(){
    final Circle circle = map.addCircle(new CircleOptions()
            .center(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude()))
            .strokeColor(Color.BLUE).radius(100));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        ValueAnimator vAnimator = new ValueAnimator();
        vAnimator.setRepeatCount(0);
        vAnimator.setRepeatMode(ValueAnimator.RESTART);  /* PULSE */
        vAnimator.setIntValues(0, 100);
        vAnimator.setDuration(1000);
        vAnimator.setEvaluator(new IntEvaluator());
        vAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
        vAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                float animatedFraction = valueAnimator.getAnimatedFraction();
                // Log.e("", "" + animatedFraction);
                circle.setRadius(animatedFraction * 100);
            }
        });
        vAnimator.start();
    }
}
WXAnimationModule.java 文件源码 项目:weex-3d-map 阅读 39 收藏 0 点赞 0 评论 0
private static @Nullable
ObjectAnimator createAnimator(@NonNull WXAnimationBean animation, final View target) {
  if(target == null){
    return null;
  }
  WXAnimationBean.Style style = animation.styles;
  if (style != null) {
    ObjectAnimator animator;
    List<PropertyValuesHolder> holders =style.getHolders();
    if (!TextUtils.isEmpty(style.backgroundColor)) {
      BorderDrawable borderDrawable;
      if ((borderDrawable=WXViewUtils.getBorderDrawable(target))!=null) {
        holders.add(PropertyValuesHolder.ofObject(
            WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(),
            borderDrawable.getColor(),
            WXResourceUtils.getColor(style.backgroundColor)));
      } else if (target.getBackground() instanceof ColorDrawable) {
        holders.add(PropertyValuesHolder.ofObject(
            WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(),
            ((ColorDrawable) target.getBackground()).getColor(),
            WXResourceUtils.getColor(style.backgroundColor)));
      }
    }
    if (style.getPivot() != null) {
      Pair<Float, Float> pair = style.getPivot();
      target.setPivotX(pair.first);
      target.setPivotY(pair.second);
    }
    animator = ObjectAnimator.ofPropertyValuesHolder(
        target, holders.toArray(new PropertyValuesHolder[holders.size()]));
    animator.setStartDelay(animation.delay);
    final IntEvaluator intEvaluator=new IntEvaluator();
    if (target.getLayoutParams() != null &&
        (!TextUtils.isEmpty(style.width) || !TextUtils.isEmpty(style.height))) {
      DimensionUpdateListener listener = new DimensionUpdateListener(target);
      ViewGroup.LayoutParams layoutParams = target.getLayoutParams();
      if (!TextUtils.isEmpty(style.width)) {
        listener.setWidth(layoutParams.width,
                          (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.width)));
      }
      if (!TextUtils.isEmpty(style.height)) {
        listener.setHeight(layoutParams.height,
                           (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.height)));
      }
      animator.addUpdateListener(listener);
    }
    return animator;
  } else {
    return null;
  }
}
DimensionUpdateListener.java 文件源码 项目:weex-3d-map 阅读 33 收藏 0 点赞 0 评论 0
DimensionUpdateListener(@NonNull View view) {
  this.view = view;
  intEvaluator = new IntEvaluator();
}
ViewPagerAnimator.java 文件源码 项目:ViewPagerAnimator 阅读 33 收藏 0 点赞 0 评论 0
public static ViewPagerAnimator<Integer> ofInt(ViewPager viewPager, Provider<Integer> provider, Property<Integer> property) {
    final IntEvaluator evaluator = new IntEvaluator();
    final Interpolator interpolator = new LinearInterpolator();

    return ofInt(viewPager, provider, property, evaluator, interpolator);
}
DimensionUpdateListener.java 文件源码 项目:weex-uikit 阅读 33 收藏 0 点赞 0 评论 0
DimensionUpdateListener(@NonNull View view) {
  this.view = view;
  intEvaluator = new IntEvaluator();
}
DimensionUpdateListener.java 文件源码 项目:weex-3d-map 阅读 27 收藏 0 点赞 0 评论 0
DimensionUpdateListener(@NonNull View view) {
  this.view = view;
  intEvaluator = new IntEvaluator();
}
WXAnimationModule.java 文件源码 项目:weex-3d-map 阅读 29 收藏 0 点赞 0 评论 0
private static @Nullable
ObjectAnimator createAnimator(@NonNull WXAnimationBean animation, final View target) {
  if(target == null){
    return null;
  }
  WXAnimationBean.Style style = animation.styles;
  if (style != null) {
    ObjectAnimator animator;
    List<PropertyValuesHolder> holders =style.getHolders();
    if (!TextUtils.isEmpty(style.backgroundColor)) {
      BorderDrawable borderDrawable;
      if ((borderDrawable=WXViewUtils.getBorderDrawable(target))!=null) {
        holders.add(PropertyValuesHolder.ofObject(
            WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(),
            borderDrawable.getColor(),
            WXResourceUtils.getColor(style.backgroundColor)));
      } else if (target.getBackground() instanceof ColorDrawable) {
        holders.add(PropertyValuesHolder.ofObject(
            WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(),
            ((ColorDrawable) target.getBackground()).getColor(),
            WXResourceUtils.getColor(style.backgroundColor)));
      }
    }
    if (style.getPivot() != null) {
      Pair<Float, Float> pair = style.getPivot();
      target.setPivotX(pair.first);
      target.setPivotY(pair.second);
    }
    animator = ObjectAnimator.ofPropertyValuesHolder(
        target, holders.toArray(new PropertyValuesHolder[holders.size()]));
    animator.setStartDelay(animation.delay);
    final IntEvaluator intEvaluator=new IntEvaluator();
    if (target.getLayoutParams() != null &&
        (!TextUtils.isEmpty(style.width) || !TextUtils.isEmpty(style.height))) {
      DimensionUpdateListener listener = new DimensionUpdateListener(target);
      ViewGroup.LayoutParams layoutParams = target.getLayoutParams();
      if (!TextUtils.isEmpty(style.width)) {
        listener.setWidth(layoutParams.width,
                          (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.width)));
      }
      if (!TextUtils.isEmpty(style.height)) {
        listener.setHeight(layoutParams.height,
                           (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.height)));
      }
      animator.addUpdateListener(listener);
    }
    return animator;
  } else {
    return null;
  }
}
DimensionUpdateListener.java 文件源码 项目:Weex-TestDemo 阅读 31 收藏 0 点赞 0 评论 0
DimensionUpdateListener(@NonNull View view) {
  this.view = view;
  intEvaluator = new IntEvaluator();
}
WXAnimationModule.java 文件源码 项目:Weex-TestDemo 阅读 57 收藏 0 点赞 0 评论 0
private static @Nullable
ObjectAnimator createAnimator(@NonNull WXAnimationBean animation, final View target) {
  if(target == null){
    return null;
  }
  WXAnimationBean.Style style = animation.styles;
  if (style != null) {
    ObjectAnimator animator;
    List<PropertyValuesHolder> holders =style.getHolders();
    if (!TextUtils.isEmpty(style.backgroundColor)) {
      BorderDrawable borderDrawable;
      if ((borderDrawable=WXViewUtils.getBorderDrawable(target))!=null) {
        holders.add(PropertyValuesHolder.ofObject(
            WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(),
            borderDrawable.getColor(),
            WXResourceUtils.getColor(style.backgroundColor)));
      } else if (target.getBackground() instanceof ColorDrawable) {
        holders.add(PropertyValuesHolder.ofObject(
            WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(),
            ((ColorDrawable) target.getBackground()).getColor(),
            WXResourceUtils.getColor(style.backgroundColor)));
      }
    }
    if (style.getPivot() != null) {
      Pair<Float, Float> pair = style.getPivot();
      target.setPivotX(pair.first);
      target.setPivotY(pair.second);
    }
    animator = ObjectAnimator.ofPropertyValuesHolder(
        target, holders.toArray(new PropertyValuesHolder[holders.size()]));
    animator.setStartDelay(animation.delay);
    final IntEvaluator intEvaluator=new IntEvaluator();
    if (target.getLayoutParams() != null &&
        (!TextUtils.isEmpty(style.width) || !TextUtils.isEmpty(style.height))) {
      DimensionUpdateListener listener = new DimensionUpdateListener(target);
      ViewGroup.LayoutParams layoutParams = target.getLayoutParams();
      if (!TextUtils.isEmpty(style.width)) {
        listener.setWidth(layoutParams.width,
                          (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.width)));
      }
      if (!TextUtils.isEmpty(style.height)) {
        listener.setHeight(layoutParams.height,
                           (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.height)));
      }
      animator.addUpdateListener(listener);
    }
    return animator;
  } else {
    return null;
  }
}
AnimateBiz.java 文件源码 项目:AndroidExerciseProgram 阅读 29 收藏 0 点赞 0 评论 0
@Override
public void perforAnimate(AnimateType animateType, final View view, final DisplayMetrics metrics) {
    float startValue=animateType.getStartValue();
    float endValue=animateType.getEndValue();
    switch (animateType.getType()) {
        case R.id.bt_scale_big:
            ObjectAnimator.ofFloat(view, "scaleX", startValue, endValue).setDuration(1000).start();
            ObjectAnimator.ofFloat(view, "scaleY", startValue, endValue).setDuration(1000).start();
            break;
        case R.id.bt_scale_small:
            ObjectAnimator.ofFloat(view, "scaleX", endValue, startValue).setDuration(1000).start();
            ObjectAnimator.ofFloat(view, "scaleY", endValue, startValue).setDuration(1000).start();
            break;
        case R.id.bt_rotate:
            ObjectAnimator.ofFloat(view, "rotationX", startValue, endValue).setDuration(1000).start();
            ObjectAnimator.ofFloat(view, "rotationY", startValue, endValue).setDuration(1000).start();
            break;
        case R.id.bt_circle:
            final int width = metrics.widthPixels / 2;
            final int height = metrics.heightPixels / 2;
            ValueAnimator valueAnimator = ValueAnimator.ofInt(1, 1000);
            valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

                private IntEvaluator evaluator = new IntEvaluator();

                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    int value = (int) animation.getAnimatedValue();
                    float fraction = (float) (value / 1000.0);

                    Integer evaluate = evaluator.evaluate(fraction, 0, width * 2);
                    if (evaluate <= width) {
                        view.setX((width * 2 - view.getMeasuredWidth()) / 2 + evaluate);
                        view.setY((float) (height + Math.sqrt(Math.pow(width / 2, 2) - Math.pow(width / 2 - evaluate, 2))));
                    } else {
                        view.setX((width * 2 - view.getMeasuredWidth()) / 2 + width - (evaluate - width));
                        view.setY((float) (height - Math.sqrt(Math.pow(width / 2, 2) - Math.pow(width / 2 - (evaluate - width), 2))));
                    }

                }
            });
            valueAnimator.setDuration(2000).start();
            break;
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号