@Override public Animator onDisappear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) { if (view == null || view.getBackground() == null) return null; return ObjectAnimator.ofInt(view.getBackground(), ViewUtils.DRAWABLE_ALPHA, 0); } }
@Override public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues, TransitionValues endValues) { if (view == null || view.getBackground() == null) return null; Drawable background = view.getBackground(); background.setAlpha(0); return ObjectAnimator.ofInt(background, ViewUtils.DRAWABLE_ALPHA, 0, 255); }
public void doEndAnim() { mAnimator = ObjectAnimator.ofInt(this, "InnViewPositionX", mInnViewPositionX, mInnCenterPositionX); mAnimator.setDuration(250); mAnimator.start(); } }
@NonNull public static <T> ObjectAnimator ofInt(@Nullable T target, @NonNull Property<T, Integer> xProperty, @NonNull Property<T, Integer> yProperty, @NonNull Path path) { return ObjectAnimator.ofInt(target, xProperty, yProperty, path); } }
public void showLeft() { translateWidgets(leftWidth, left, middle, right); ObjectAnimator.ofInt(this, "middleWidth", leftWidth, middleWidthNormal).setDuration(ANIM_DURATION) .start(); }
private void animateArrow(boolean shouldRotateUp) { int start = shouldRotateUp ? 0 : MAX_LEVEL; int end = shouldRotateUp ? MAX_LEVEL : 0; arrowAnimator = ObjectAnimator.ofInt(arrowDrawable, "level", start, end); arrowAnimator.setInterpolator(new LinearOutSlowInInterpolator()); arrowAnimator.start(); }
@Override public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues); if (startValues == null || endValues == null || !(endValues.view instanceof ParallaxScrimageView)) return changeBounds; ParallaxScrimageView psv = ((ParallaxScrimageView) endValues.view); if (psv.getOffset() == 0) return changeBounds; Animator deparallax = ObjectAnimator.ofInt(psv, ParallaxScrimageView.OFFSET, 0); AnimatorSet transition = new AnimatorSet(); transition.playTogether(changeBounds, deparallax); return transition; } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); word=findViewById(R.id.word); ValueAnimator positionAnim = ObjectAnimator.ofInt(this, "wordPosition", 0, 25); positionAnim.setDuration(12500); positionAnim.setRepeatCount(ValueAnimator.INFINITE); positionAnim.setRepeatMode(ValueAnimator.RESTART); positionAnim.start(); }
@NonNull public static <T> ObjectAnimator ofArgb(@Nullable T target, @NonNull Property<T, Integer> property, int... values) { ObjectAnimator animator = ObjectAnimator.ofInt(target, property, values); animator.setEvaluator(new ArgbEvaluator()); return animator; }
public void setLoadingProgress(int progress, int max) { if (!isShowingProgress) { viewAnimator.setDisplayedChild(1); isShowingProgress = true; return; } int newPosition = (int) (progress / (float) max * PROGRESS_MAX_WITH_MARGIN); int currentPosition = progressBar.getProgress(); if (newPosition > currentPosition) { ObjectAnimator.ofInt(progressBar, "progress", currentPosition, newPosition) .setDuration(PROGRESS_STEP_DURATION).start(); } else { progressBar.setProgress(newPosition); } }
@NonNull public static ObjectAnimator ofArgb(@Nullable Object target, @NonNull String propertyName, int... values) { ObjectAnimator animator = ObjectAnimator.ofInt(target, propertyName, values); animator.setEvaluator(new ArgbEvaluator()); return animator; }
public void startFromLocation(int[] tapLocationOnScreen) { changeState(STATE_FILL_STARTED); startLocationX = tapLocationOnScreen[0]; startLocationY = tapLocationOnScreen[1]; revealAnimator = ObjectAnimator.ofInt(this, "currentRadius", 0, getWidth() + getHeight()).setDuration(FILL_TIME); revealAnimator.setInterpolator(INTERPOLATOR); revealAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { changeState(STATE_FINISHED); } }); revealAnimator.start(); }
@Override @Nullable public ObjectAnimator ofInt(@Nullable View view, @NonNull Property<View, Integer> property, float startFraction, float endFraction) { int start = (int) (property.get(view) * startFraction); int end = (int) (property.get(view) * endFraction); if (start == end) { return null; } property.set(view, start); return ObjectAnimator.ofInt(view, property, end); } }
public AnimationBuilder backgroundColor(int... colors) { for (View view : views) { ObjectAnimator objectAnimator = ObjectAnimator.ofInt(view, "backgroundColor", colors); objectAnimator.setEvaluator(new ArgbEvaluator()); this.animatorList.add(objectAnimator); } return this; }
public AnimationBuilder textColor(int... colors) { for (View view : views) { if (view instanceof TextView) { TextView textView = (TextView) view; ObjectAnimator objectAnimator = ObjectAnimator.ofInt(textView, "textColor", colors); objectAnimator.setEvaluator(new ArgbEvaluator()); this.animatorList.add(objectAnimator); } } return this; }
private void animateForegroundColor(@ColorInt final int targetColor) { ObjectAnimator animator = ObjectAnimator.ofInt(this, FOREGROUND_COLOR, Color.TRANSPARENT, targetColor); animator.setEvaluator(new ArgbEvaluator()); animator.setStartDelay(DELAY_COLOR_CHANGE); animator.start(); }
public void hideLeft() { if (leftWidth == -1) { leftWidth=left.getWidth(); middleWidthNormal=middle.getWidth(); resetWidget(left, leftWidth); resetWidget(middle, middleWidthNormal); resetWidget(right, middleWidthNormal); requestLayout(); } translateWidgets(-1 * leftWidth, left, middle, right); ObjectAnimator.ofInt(this, "middleWidth", middleWidthNormal, leftWidth).setDuration(ANIM_DURATION).start(); }
@Override public Animator getAnimator(View viewToMove) { if (viewToMove instanceof TextView) { final ObjectAnimator objectAnimator = ObjectAnimator.ofInt(viewToMove, "textColor", ((TextView) viewToMove).getCurrentTextColor(), textColor); objectAnimator.setEvaluator(new ArgbEvaluator()); return objectAnimator; } else { return null; } } }
private AnimationBuilder color(String propertyName, int... colors) { for (final RichPath path : paths) { ObjectAnimator objectAnimator = ObjectAnimator.ofInt(path, propertyName, colors); objectAnimator.setEvaluator(new ArgbEvaluator()); applyAnimatorProperties(objectAnimator, path); } return this; }
@Test public void start_shouldRunAnimation() { final ObjectAnimator animator = ObjectAnimator.ofInt(target, "transparency", 0, 1, 2, 3, 4); Robolectric.getForegroundThreadScheduler().pause(); animator.setDuration(1000); animator.addListener(listener); animator.start(); assertThat(listenerEvents).containsExactly("started"); assertThat(target.getTransparency()).isEqualTo(0); Robolectric.flushForegroundThreadScheduler(); assertThat(listenerEvents).containsExactly("started", "ended"); assertThat(target.getTransparency()).isEqualTo(4); }