当前位置: 首页>>代码示例>>Java>>正文


Java TypeEvaluator类代码示例

本文整理汇总了Java中android.animation.TypeEvaluator的典型用法代码示例。如果您正苦于以下问题:Java TypeEvaluator类的具体用法?Java TypeEvaluator怎么用?Java TypeEvaluator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TypeEvaluator类属于android.animation包,在下文中一共展示了TypeEvaluator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setCodeSegment

import android.animation.TypeEvaluator; //导入依赖的package包/类
private void setCodeSegment(final TextView codeView, String segment) {
  if (Build.VERSION.SDK_INT >= 11) {
    ValueAnimator valueAnimator = new ValueAnimator();
    valueAnimator.setObjectValues(0, Integer.parseInt(segment));

    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
      @RequiresApi(api = Build.VERSION_CODES.HONEYCOMB)
      @Override
      public void onAnimationUpdate(ValueAnimator animation) {
        int value = (int) animation.getAnimatedValue();
        codeView.setText(String.format("%05d", value));
      }
    });

    valueAnimator.setEvaluator(new TypeEvaluator<Integer>() {
      public Integer evaluate(float fraction, Integer startValue, Integer endValue) {
        return Math.round(startValue + (endValue - startValue) * fraction);
      }
    });

    valueAnimator.setDuration(1000);
    valueAnimator.start();
  } else {
    codeView.setText(segment);
  }
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:27,代码来源:VerifyIdentityActivity.java

示例2: createFrameAnimatorWithDelay

import android.animation.TypeEvaluator; //导入依赖的package包/类
/**
 * Returns an animator which animates the source image of the {@link ImageView} with start delay.
 *
 * <p>The frame rate is 60 fps.
 */
public static ObjectAnimator createFrameAnimatorWithDelay(ImageView imageView, int[] frames,
        long startDelay) {
    ObjectAnimator animator = ObjectAnimator.ofInt(imageView, "imageResource", frames);
    // Make it 60 fps.
    animator.setDuration(frames.length * 1000 / 60);
    animator.setInterpolator(null);
    animator.setStartDelay(startDelay);
    animator.setEvaluator(new TypeEvaluator<Integer>() {
        @Override
        public Integer evaluate(float fraction, Integer startValue, Integer endValue) {
            return startValue;
        }
    });
    return animator;
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:21,代码来源:SetupAnimationHelper.java

示例3: objectAnimator_shouldSetTheStartingAndEndingValues

import android.animation.TypeEvaluator; //导入依赖的package包/类
@Test
public void objectAnimator_shouldSetTheStartingAndEndingValues() throws Exception {
  ValueObject object = new ValueObject();
  ObjectAnimator animator = ObjectAnimator.ofObject(object, "value", new TypeEvaluator<String>() {
    @Override
    public String evaluate(float fraction, String startValue, String endValue) {
      if (fraction < 0.5) {
        return startValue;
      } else {
        return endValue;
      }
    }
  }, "human", "replicant", "unicorn");
  animator.setDuration(2000);

  animator.start();

  assertThat(object.getValue()).isEqualTo("human");
  Robolectric.idleMainLooper(1000);
  assertThat(object.getValue()).isEqualTo("replicant");
  Robolectric.idleMainLooper(1000);
  assertThat(object.getValue()).isEqualTo("unicorn");
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:24,代码来源:ObjectAnimatorTest.java

示例4: ofInt

import android.animation.TypeEvaluator; //导入依赖的package包/类
@VisibleForTesting
static ViewPagerAnimator<Integer> ofInt(ViewPager viewPager,
                                        Provider<Integer> provider,
                                        Property<Integer> property,
                                        TypeEvaluator<Integer> evaluator,
                                        Interpolator interpolator) {
    return new ViewPagerAnimator<>(viewPager, provider, property, evaluator, interpolator);
}
 
开发者ID:StylingAndroid,项目名称:ViewPagerAnimator,代码行数:9,代码来源:ViewPagerAnimator.java

示例5: ofArgb

import android.animation.TypeEvaluator; //导入依赖的package包/类
@VisibleForTesting
static ViewPagerAnimator<Integer> ofArgb(ViewPager viewPager,
                                         Provider<Integer> provider,
                                         Property<Integer> property,
                                         TypeEvaluator<Integer> evaluator,
                                         Interpolator interpolator) {
    return new ViewPagerAnimator<>(viewPager, provider, property, evaluator, interpolator);
}
 
开发者ID:StylingAndroid,项目名称:ViewPagerAnimator,代码行数:9,代码来源:ViewPagerAnimator.java

示例6: ofFloat

import android.animation.TypeEvaluator; //导入依赖的package包/类
@VisibleForTesting
static ViewPagerAnimator<Number> ofFloat(ViewPager viewPager,
                                         Provider<Number> provider,
                                         Property<Number> property,
                                         TypeEvaluator<Number> evaluator,
                                         Interpolator interpolator) {
    return new ViewPagerAnimator<>(viewPager, provider, property, evaluator, interpolator);
}
 
开发者ID:StylingAndroid,项目名称:ViewPagerAnimator,代码行数:9,代码来源:ViewPagerAnimator.java

示例7: ViewPagerAnimator

import android.animation.TypeEvaluator; //导入依赖的package包/类
public ViewPagerAnimator(@NonNull ViewPager viewPager,
                         @NonNull Provider<V> provider,
                         @NonNull Property<V> property,
                         @NonNull TypeEvaluator<V> evaluator,
                         @NonNull Interpolator interpolator) {
    setViewPager(viewPager);
    this.provider = provider;
    this.property = property;
    this.evaluator = evaluator;
    setInterpolator(interpolator);
}
 
开发者ID:StylingAndroid,项目名称:ViewPagerAnimator,代码行数:12,代码来源:ViewPagerAnimator.java

示例8: createArgbAnimator

import android.animation.TypeEvaluator; //导入依赖的package包/类
static ObjectAnimator createArgbAnimator(View view, String propertyName, int startColor, int endColor) {
	if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
		return ObjectAnimator.ofObject(view, propertyName, new TypeEvaluator() {
			@Override
			public Object evaluate(float fraction, Object startValue, Object endValue) {
				int startInt = (Integer) startValue;
				int startA = (startInt >> 24) & 0xff;
				int startR = (startInt >> 16) & 0xff;
				int startG = (startInt >> 8) & 0xff;
				int startB = startInt & 0xff;

				int endInt = (Integer) endValue;
				int endA = (endInt >> 24) & 0xff;
				int endR = (endInt >> 16) & 0xff;
				int endG = (endInt >> 8) & 0xff;
				int endB = endInt & 0xff;

				return (startA + (int)(fraction * (endA - startA))) << 24 |
						(startR + (int)(fraction * (endR - startR))) << 16 |
						(startG + (int)(fraction * (endG - startG))) << 8 |
						(startB + (int)(fraction * (endB - startB)));
			}
		}, startColor, endColor);
	} else {
		return ObjectAnimator.ofArgb(view, propertyName, startColor, endColor);
	}
}
 
开发者ID:fython,项目名称:MaterialStepperView,代码行数:28,代码来源:ViewUtils.java

示例9: getPathValuesHolder

import android.animation.TypeEvaluator; //导入依赖的package包/类
@TargetApi(LOLLIPOP)
private PropertyValuesHolder getPathValuesHolder(Run run, int dy, int dx) {
    PropertyValuesHolder propertyValuesHolder;
    if (IS_LOLLIPOP_OR_ABOVE) {
        PathMotion pathMotion = new PathMotion() {
            @Override
            public Path getPath(float startX, float startY, float endX, float endY) {
                return ReflowTextAnimatorHelper.getPath(startX, startY, endX, endY);
            }
        };
        propertyValuesHolder = PropertyValuesHolder.ofObject(SwitchDrawable.TOP_LEFT, null,
                pathMotion.getPath(
                        run.getStart().left,
                        run.getStart().top,
                        run.getEnd().left - dx,
                        run.getEnd().top - dy));
    } else {
        PointF startPoint = new PointF(run.getStart().left, run.getStart().top);
        PointF endPoint = new PointF(run.getEnd().left - dx, run.getEnd().top - dy);
        propertyValuesHolder = PropertyValuesHolder.ofObject(SwitchDrawable.TOP_LEFT, new TypeEvaluator<PointF>() {
            private final PointF point = new PointF();

            @Override
            public PointF evaluate(float fraction, PointF startValue, PointF endValue) {
                float x = startValue.x + (endValue.x - startValue.x) * fraction;
                float y = startValue.y + (endValue.y - startValue.y) * fraction;

                point.set(x, y);

                return point;
            }
        }, startPoint, endPoint);
    }

    return propertyValuesHolder;
}
 
开发者ID:shazam,项目名称:reflow-animator,代码行数:37,代码来源:ReflowTextAnimatorHelper.java

示例10: animateMarkerToICS

import android.animation.TypeEvaluator; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
static void animateMarkerToICS(Marker marker, LatLng finalPosition, final LatLngInterpolator latLngInterpolator) {
    TypeEvaluator<LatLng> typeEvaluator = new TypeEvaluator<LatLng>() {
        @Override
        public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) {
            return latLngInterpolator.interpolate(fraction, startValue, endValue);
        }
    };
    Property<Marker, LatLng> property = Property.of(Marker.class, LatLng.class, "position");
    ObjectAnimator animator = ObjectAnimator.ofObject(marker, property, typeEvaluator, finalPosition);
    animator.setDuration(3000);
    animator.start();
}
 
开发者ID:Chao-wei-chu,项目名称:GoogleMap_Animating_markers,代码行数:14,代码来源:MarkerAnimation.java

示例11: animateMarkerToICS

import android.animation.TypeEvaluator; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public static void animateMarkerToICS(IMarker marker, LatLng finalPosition, final LatLngInterpolator latLngInterpolator, long duration) {
    TypeEvaluator<LatLng> typeEvaluator = new TypeEvaluator<LatLng>() {
        @Override
        public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) {
            return latLngInterpolator.interpolate(fraction, startValue, endValue);
        }
    };
    Property<IMarker, LatLng> property = Property.of(IMarker.class, LatLng.class, "position");
    ObjectAnimator animator = ObjectAnimator.ofObject(marker, property, typeEvaluator, finalPosition);
    animator.setDuration(duration);
    animator.start();
}
 
开发者ID:RSDT,项目名称:Japp16,代码行数:14,代码来源:AnimateMarkerTool.java

示例12: parseAnimatorFromTypeArray

import android.animation.TypeEvaluator; //导入依赖的package包/类
/**
 * @param anim                The animator, must not be null
 * @param arrayAnimator       Incoming typed array for Animator's attributes.
 * @param arrayObjectAnimator Incoming typed array for Object Animator's
 *                            attributes.
 */
private static void parseAnimatorFromTypeArray(ValueAnimator anim,
                                               TypedArray arrayAnimator, TypedArray arrayObjectAnimator) {
    long duration = arrayAnimator.getInt(R.styleable.Animator_android_duration, 300);

    long startDelay = arrayAnimator.getInt(R.styleable.Animator_android_startOffset, 0);

    int valueType = arrayAnimator.getInt(R.styleable.Animator_vc_valueType, 0);

    TypeEvaluator evaluator = null;

    // Must be a path animator by the time I reach here
    if (valueType == VALUE_TYPE_PATH) {
        evaluator = setupAnimatorForPath(anim, arrayAnimator);
    } else {
        throw new IllegalArgumentException("target is not a pathType target");
    }

    anim.setDuration(duration);
    anim.setStartDelay(startDelay);

    if (arrayAnimator.hasValue(R.styleable.Animator_android_repeatCount)) {
        anim.setRepeatCount(
                arrayAnimator.getInt(R.styleable.Animator_android_repeatCount, 0));
    }
    if (arrayAnimator.hasValue(R.styleable.Animator_android_repeatMode)) {
        anim.setRepeatMode(
                arrayAnimator.getInt(R.styleable.Animator_android_repeatMode,
                        ValueAnimator.RESTART));
    }
    if (evaluator != null) {
        anim.setEvaluator(evaluator);
    }

    if (arrayObjectAnimator != null) {
        setupObjectAnimator(anim, arrayObjectAnimator);
    }
}
 
开发者ID:michelelacorte,项目名称:ElasticProgressBar,代码行数:44,代码来源:PathAnimatorInflater.java

示例13: setupAnimatorForPath

import android.animation.TypeEvaluator; //导入依赖的package包/类
/**
 * Setup the Animator to achieve path morphing.
 *
 * @param anim          The target Animator which will be updated.
 * @param arrayAnimator TypedArray for the ValueAnimator.
 * @return the PathDataEvaluator.
 */
private static TypeEvaluator setupAnimatorForPath(ValueAnimator anim,
                                                  TypedArray arrayAnimator) {
    TypeEvaluator evaluator = null;
    String fromString = arrayAnimator.getString(R.styleable.Animator_vc_valueFrom);
    String toString = arrayAnimator.getString(R.styleable.Animator_vc_valueTo);
    PathParser.PathDataNode[] nodesFrom = PathParser.createNodesFromPathData(fromString);
    PathParser.PathDataNode[] nodesTo = PathParser.createNodesFromPathData(toString);

    if (nodesFrom != null) {
        if (nodesTo != null) {
            anim.setObjectValues(nodesFrom, nodesTo);
            if (!PathParser.canMorph(nodesFrom, nodesTo)) {
                throw new InflateException(arrayAnimator.getPositionDescription()
                        + " Can't morph from " + fromString + " to " + toString);
            }
        } else {
            anim.setObjectValues((Object) nodesFrom);
        }
        evaluator = new PathDataEvaluator(PathParser.deepCopyNodes(nodesFrom));
    } else if (nodesTo != null) {
        anim.setObjectValues((Object) nodesTo);
        evaluator = new PathDataEvaluator(PathParser.deepCopyNodes(nodesTo));
    }

    if (DBG_ANIMATOR_INFLATER && evaluator != null) {
        Log.v(LOG_TAG, "create a new PathDataEvaluator here");
    }

    return evaluator;
}
 
开发者ID:michelelacorte,项目名称:ElasticProgressBar,代码行数:38,代码来源:PathAnimatorInflater.java

示例14: ofObject

import android.animation.TypeEvaluator; //导入依赖的package包/类
@Implementation
public static ObjectAnimator ofObject(Object target, String propertyName, TypeEvaluator typeEvaluator, Object... values) {
  ObjectAnimator result = new ObjectAnimator();

  result.setTarget(target);
  result.setPropertyName(propertyName);
  result.setObjectValues(values);
  result.setEvaluator(typeEvaluator);

  getAnimatorMapFor(target).put(propertyName, result);
  return result;
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:13,代码来源:ShadowObjectAnimator.java

示例15: animateMarkerToICS

import android.animation.TypeEvaluator; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public static ObjectAnimator animateMarkerToICS(final MapView map, Marker marker, GeoPoint finalPosition, final GeoPointInterpolator GeoPointInterpolator) {
    TypeEvaluator<GeoPoint> typeEvaluator = new TypeEvaluator<GeoPoint>() {
        @Override
        public GeoPoint evaluate(float fraction, GeoPoint startValue, GeoPoint endValue) {
            return GeoPointInterpolator.interpolate(fraction, startValue, endValue);
        }
    };
    Property<Marker, GeoPoint> property = Property.of(Marker.class, GeoPoint.class, "position");
    ObjectAnimator animator = ObjectAnimator.ofObject(marker, property, typeEvaluator, finalPosition);
    animator.setDuration(3000);
    animator.start();
    return animator;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:15,代码来源:MarkerAnimation.java


注:本文中的android.animation.TypeEvaluator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。