當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。