android.animation.ValueAnimator.AnimatorUpdateListener Java Examples

The following examples show how to use android.animation.ValueAnimator.AnimatorUpdateListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FadeThroughProvider.java    From material-components-android with Apache License 2.0 7 votes vote down vote up
private static Animator createFadeThroughAnimator(
    final View view,
    final float startValue,
    final float endValue,
    final @FloatRange(from = 0.0, to = 1.0) float startFraction,
    final @FloatRange(from = 0.0, to = 1.0) float endFraction) {
  ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f);
  animator.addUpdateListener(
      new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
          float progress = (float) animation.getAnimatedValue();
          view.setAlpha(lerp(startValue, endValue, startFraction, endFraction, progress));
        }
      });
  return animator;
}
 
Example #2
Source File: FadeProvider.java    From material-components-android with Apache License 2.0 7 votes vote down vote up
private static Animator createFadeAnimator(
    final View view,
    final float startValue,
    final float endValue,
    final @FloatRange(from = 0.0, to = 1.0) float startFraction,
    final @FloatRange(from = 0.0, to = 1.0) float endFraction) {
  ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f);
  animator.addUpdateListener(
      new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
          float progress = (float) animation.getAnimatedValue();
          view.setAlpha(lerp(startValue, endValue, startFraction, endFraction, progress));
        }
      });
  return animator;
}
 
Example #3
Source File: PaymentRequestUI.java    From 365browser with Apache License 2.0 7 votes vote down vote up
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
        int oldLeft, int oldTop, int oldRight, int oldBottom) {
    if (mSheetAnimator != null) mSheetAnimator.cancel();

    mRequestView.removeOnLayoutChangeListener(this);
    mContainerHeightDifference = (bottom - top) - (oldBottom - oldTop);

    ValueAnimator containerAnimator = ValueAnimator.ofFloat(1f, 0f);
    containerAnimator.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float alpha = (Float) animation.getAnimatedValue();
            update(alpha);
        }
    });

    mSheetAnimator = containerAnimator;
    mSheetAnimator.setDuration(DIALOG_ENTER_ANIMATION_MS);
    mSheetAnimator.setInterpolator(new LinearOutSlowInInterpolator());
    mSheetAnimator.addListener(this);
    mSheetAnimator.start();
}
 
Example #4
Source File: FadeThroughProvider.java    From material-components-android with Apache License 2.0 7 votes vote down vote up
private static Animator createFadeThroughAnimator(
    final View view,
    final float startValue,
    final float endValue,
    final @FloatRange(from = 0.0, to = 1.0) float startFraction,
    final @FloatRange(from = 0.0, to = 1.0) float endFraction) {
  ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f);
  animator.addUpdateListener(
      new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
          float progress = (float) animation.getAnimatedValue();
          view.setAlpha(lerp(startValue, endValue, startFraction, endFraction, progress));
        }
      });
  return animator;
}
 
Example #5
Source File: FadeProvider.java    From material-components-android with Apache License 2.0 7 votes vote down vote up
private static Animator createFadeAnimator(
    final View view,
    final float startValue,
    final float endValue,
    final @FloatRange(from = 0.0, to = 1.0) float startFraction,
    final @FloatRange(from = 0.0, to = 1.0) float endFraction) {
  ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f);
  animator.addUpdateListener(
      new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
          float progress = (float) animation.getAnimatedValue();
          view.setAlpha(lerp(startValue, endValue, startFraction, endFraction, progress));
        }
      });
  return animator;
}
 
Example #6
Source File: DragView.java    From Trebuchet with GNU General Public License v3.0 7 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void animateFilterTo(float[] targetFilter) {
    float[] oldFilter = mCurrentFilter == null ? new ColorMatrix().getArray() : mCurrentFilter;
    mCurrentFilter = Arrays.copyOf(oldFilter, oldFilter.length);

    if (mFilterAnimator != null) {
        mFilterAnimator.cancel();
    }
    mFilterAnimator = ValueAnimator.ofObject(new FloatArrayEvaluator(mCurrentFilter),
            oldFilter, targetFilter);
    mFilterAnimator.setDuration(COLOR_CHANGE_DURATION);
    mFilterAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mPaint.setColorFilter(new ColorMatrixColorFilter(mCurrentFilter));
            invalidate();
        }
    });
    mFilterAnimator.start();
}
 
Example #7
Source File: PieRadarChartBase.java    From Ticket-Analysis with MIT License 6 votes vote down vote up
/**
 * Applys a spin animation to the Chart.
 *
 * @param durationmillis
 * @param fromangle
 * @param toangle
 */
@SuppressLint("NewApi")
public void spin(int durationmillis, float fromangle, float toangle, Easing.EasingOption easing) {

    if (android.os.Build.VERSION.SDK_INT < 11)
        return;

    setRotationAngle(fromangle);

    ObjectAnimator spinAnimator = ObjectAnimator.ofFloat(this, "rotationAngle", fromangle,
            toangle);
    spinAnimator.setDuration(durationmillis);
    spinAnimator.setInterpolator(Easing.getEasingFunctionFromOption(easing));

    spinAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            postInvalidate();
        }
    });
    spinAnimator.start();
}
 
Example #8
Source File: PlaybackOverlaySupportFragment.java    From adt-leanback-support with Apache License 2.0 6 votes vote down vote up
private void loadBgAnimator() {
    AnimatorUpdateListener listener = new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator arg0) {
            setBgAlpha((Integer) arg0.getAnimatedValue());
        }
    };

    mBgFadeInAnimator = loadAnimator(getActivity(), R.animator.lb_playback_bg_fade_in);
    mBgFadeInAnimator.addUpdateListener(listener);
    mBgFadeInAnimator.addListener(mFadeListener);

    mBgFadeOutAnimator = loadAnimator(getActivity(), R.animator.lb_playback_bg_fade_out);
    mBgFadeOutAnimator.addUpdateListener(listener);
    mBgFadeOutAnimator.addListener(mFadeListener);
}
 
Example #9
Source File: DragView.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
public void animateShift(final int shiftX, final int shiftY) {
    if (mAnim.isStarted()) {
        return;
    }
    mAnimatedShiftX = shiftX;
    mAnimatedShiftY = shiftY;
    applyTranslation();
    mAnim.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float fraction = 1 - animation.getAnimatedFraction();
            mAnimatedShiftX = (int) (fraction * shiftX);
            mAnimatedShiftY = (int) (fraction * shiftY);
            applyTranslation();
        }
    });
}
 
Example #10
Source File: Workspace.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
public ValueAnimator createHotseatAlphaAnimator(float finalValue) {
    if (Float.compare(finalValue, mHotseatAlpha[HOTSEAT_STATE_ALPHA_INDEX]) == 0) {
        // Return a dummy animator to avoid null checks.
        return ValueAnimator.ofFloat(0, 0);
    } else {
        ValueAnimator animator = ValueAnimator
                .ofFloat(mHotseatAlpha[HOTSEAT_STATE_ALPHA_INDEX], finalValue);
        animator.addUpdateListener(new AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                float value = (Float) valueAnimator.getAnimatedValue();
                setHotseatAlphaAtIndex(value, HOTSEAT_STATE_ALPHA_INDEX);
            }
        });

        AccessibilityManager am = (AccessibilityManager)
                mLauncher.getSystemService(Context.ACCESSIBILITY_SERVICE);
        final boolean accessibilityEnabled = am.isEnabled();
        animator.addUpdateListener(
                new AlphaUpdateListener(mLauncher.getHotseat(), accessibilityEnabled));
        animator.addUpdateListener(
                new AlphaUpdateListener(mPageIndicator, accessibilityEnabled));
        return animator;
    }
}
 
Example #11
Source File: PlaybackOverlayFragment.java    From adt-leanback-support with Apache License 2.0 6 votes vote down vote up
private void loadBgAnimator() {
    AnimatorUpdateListener listener = new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator arg0) {
            setBgAlpha((Integer) arg0.getAnimatedValue());
        }
    };

    mBgFadeInAnimator = loadAnimator(getActivity(), R.animator.lb_playback_bg_fade_in);
    mBgFadeInAnimator.addUpdateListener(listener);
    mBgFadeInAnimator.addListener(mFadeListener);

    mBgFadeOutAnimator = loadAnimator(getActivity(), R.animator.lb_playback_bg_fade_out);
    mBgFadeOutAnimator.addUpdateListener(listener);
    mBgFadeOutAnimator.addListener(mFadeListener);
}
 
Example #12
Source File: SwipeHelper.java    From NotificationPeekPort with Apache License 2.0 6 votes vote down vote up
public void snapChild(final View view, float velocity) {
    final View animView = mCallback.getChildContentView(view);
    final boolean canAnimViewBeDismissed = mCallback.canChildBeDismissed(animView);
    ObjectAnimator anim = createTranslationAnimation(animView, 0);
    anim.setInterpolator(new OvershootInterpolator(2.5f));
    int duration = OVERSHOOT_DURATION;
    anim.setDuration(duration);
    anim.addUpdateListener(new AnimatorUpdateListener() {
        public void onAnimationUpdate(ValueAnimator animation) {
            updateAlphaFromOffset(animView, canAnimViewBeDismissed);
        }
    });
    anim.addListener(new AnimatorListenerAdapter() {
        public void onAnimationEnd(Animator animator) {
            updateAlphaFromOffset(animView, canAnimViewBeDismissed);
        }
    });
    anim.start();
}
 
Example #13
Source File: SwipeHelper.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
private void snapChild(final View animView, final float targetLeft, float velocity) {
    final boolean canBeDismissed = mCallback.canChildBeDismissed(animView);
    AnimatorUpdateListener updateListener = new AnimatorUpdateListener() {
        public void onAnimationUpdate(ValueAnimator animation) {
            onTranslationUpdate(animView, (float) animation.getAnimatedValue(), canBeDismissed);
        }
    };

    Animator anim = getViewTranslationAnimator(animView, targetLeft, updateListener);
    if (anim == null) {
        return;
    }
    int duration = SNAP_ANIM_LEN;
    anim.setDuration(duration);
    anim.addListener(new AnimatorListenerAdapter() {
        public void onAnimationEnd(Animator animator) {
            mSnappingChild = false;
            updateSwipeProgressFromOffset(animView, canBeDismissed);
            mCallback.onChildSnappedBack(animView, targetLeft);
        }
    });
    prepareSnapBackAnimation(animView, anim);
    mSnappingChild = true;
    anim.start();
}
 
Example #14
Source File: AppBarLayout.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
private void startLiftOnScrollElevationOverlayAnimation(
    @NonNull final MaterialShapeDrawable background, boolean lifted) {
  float appBarElevation = getResources().getDimension(R.dimen.design_appbar_elevation);
  float fromElevation = lifted ? 0 : appBarElevation;
  float toElevation = lifted ? appBarElevation : 0;

  if (elevationOverlayAnimator != null) {
    elevationOverlayAnimator.cancel();
  }

  elevationOverlayAnimator = ValueAnimator.ofFloat(fromElevation, toElevation);
  elevationOverlayAnimator.setDuration(
      getResources().getInteger(R.integer.app_bar_elevation_anim_duration));
  elevationOverlayAnimator.setInterpolator(AnimationUtils.LINEAR_INTERPOLATOR);
  elevationOverlayAnimator.addUpdateListener(
      new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(@NonNull ValueAnimator valueAnimator) {
          background.setElevation((float) valueAnimator.getAnimatedValue());
        }
      });
  elevationOverlayAnimator.start();
}
 
Example #15
Source File: SwipeHelper.java    From HeadsUp with GNU General Public License v2.0 6 votes vote down vote up
public void snapChild(final View view, float velocity) {
    final View animView = mCallback.getChildContentView(view);
    final boolean canAnimViewBeDismissed = mCallback.canChildBeDismissed(animView);
    ObjectAnimator anim = createTranslationAnimation(animView, 0);
    int duration = SNAP_ANIM_LEN;
    anim.setDuration(duration);
    anim.addUpdateListener(new AnimatorUpdateListener() {
        public void onAnimationUpdate(ValueAnimator animation) {
            updateAlphaFromOffset(animView, canAnimViewBeDismissed);
        }
    });
    anim.addListener(new AnimatorListenerAdapter() {
        public void onAnimationEnd(Animator animator) {
            updateAlphaFromOffset(animView, canAnimViewBeDismissed);
        }
    });
    anim.start();
}
 
Example #16
Source File: PieRadarChartBase.java    From StockChart-MPAndroidChart with MIT License 6 votes vote down vote up
/**
 * Applys a spin animation to the Chart.
 *
 * @param durationmillis
 * @param fromangle
 * @param toangle
 */
@SuppressLint("NewApi")
public void spin(int durationmillis, float fromangle, float toangle, EasingFunction easing) {

    if (android.os.Build.VERSION.SDK_INT < 11) {
        return;
    }

    setRotationAngle(fromangle);

    ObjectAnimator spinAnimator = ObjectAnimator.ofFloat(this, "rotationAngle", fromangle,
            toangle);
    spinAnimator.setDuration(durationmillis);
    spinAnimator.setInterpolator(easing);

    spinAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            postInvalidate();
        }
    });
    spinAnimator.start();
}
 
Example #17
Source File: ValueAnimatorActivity.java    From coursera-android with MIT License 6 votes vote down vote up
private void startAnimation() {
	
	final ImageView imageView = findViewById(R.id.image_view);
	
	ValueAnimator anim = ValueAnimator.ofObject(new ArgbEvaluator(), RED,
			BLUE);

	anim.addUpdateListener(new AnimatorUpdateListener() {

		@Override
		public void onAnimationUpdate(ValueAnimator animation) {
			imageView.setBackgroundColor((Integer) animation
					.getAnimatedValue());
		}
	});
	
	anim.setDuration(10000);
	anim.start();
}
 
Example #18
Source File: DragView.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
private void animateFilterTo(float[] targetFilter) {
    float[] oldFilter = mCurrentFilter == null ? new ColorMatrix().getArray() : mCurrentFilter;
    mCurrentFilter = Arrays.copyOf(oldFilter, oldFilter.length);

    if (mFilterAnimator != null) {
        mFilterAnimator.cancel();
    }
    mFilterAnimator = ValueAnimator.ofObject(new FloatArrayEvaluator(mCurrentFilter),
            oldFilter, targetFilter);
    mFilterAnimator.setDuration(COLOR_CHANGE_DURATION);
    mFilterAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mPaint.setColorFilter(new ColorMatrixColorFilter(mCurrentFilter));
            invalidate();
        }
    });
    mFilterAnimator.start();
}
 
Example #19
Source File: ValueAnimatorActivity.java    From coursera-android with MIT License 6 votes vote down vote up
public void startAnimation() {
	
	final ImageView imageView = (ImageView) findViewById(R.id.image_view);
	
	ValueAnimator anim = ValueAnimator.ofObject(new ArgbEvaluator(), RED,
			BLUE);

	anim.addUpdateListener(new AnimatorUpdateListener() {

		@Override
		public void onAnimationUpdate(ValueAnimator animation) {
			imageView.setBackgroundColor((Integer) animation
					.getAnimatedValue());
		}
	});
	
	anim.setDuration(10000);
	anim.start();
}
 
Example #20
Source File: PieRadarChartBase.java    From android-kline with Apache License 2.0 6 votes vote down vote up
/**
 * Applys a spin animation to the Chart.
 *
 * @param durationmillis
 * @param fromangle
 * @param toangle
 */
@SuppressLint("NewApi")
public void spin(int durationmillis, float fromangle, float toangle, Easing.EasingOption easing) {

    if (android.os.Build.VERSION.SDK_INT < 11)
        return;

    setRotationAngle(fromangle);

    ObjectAnimator spinAnimator = ObjectAnimator.ofFloat(this, "rotationAngle", fromangle,
            toangle);
    spinAnimator.setDuration(durationmillis);
    spinAnimator.setInterpolator(Easing.getEasingFunctionFromOption(easing));

    spinAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            postInvalidate();
        }
    });
    spinAnimator.start();
}
 
Example #21
Source File: PieRadarChartBase.java    From iMoney with Apache License 2.0 6 votes vote down vote up
/**
 * Applys a spin animation to the Chart.
 * 
 * @param durationmillis
 * @param fromangle
 * @param toangle
 */
@SuppressLint("NewApi")
public void spin(int durationmillis, float fromangle, float toangle, Easing.EasingOption easing) {

    if (android.os.Build.VERSION.SDK_INT < 11)
        return;

    setRotationAngle(fromangle);

    ObjectAnimator spinAnimator = ObjectAnimator.ofFloat(this, "rotationAngle", fromangle,
            toangle);
    spinAnimator.setDuration(durationmillis);
    spinAnimator.setInterpolator(Easing.getEasingFunctionFromOption(easing));

    spinAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            postInvalidate();
        }
    });
    spinAnimator.start();
}
 
Example #22
Source File: PieRadarChartBase.java    From Stayfit with Apache License 2.0 6 votes vote down vote up
/**
 * Applys a spin animation to the Chart.
 * 
 * @param durationmillis
 * @param fromangle
 * @param toangle
 */
@SuppressLint("NewApi")
public void spin(int durationmillis, float fromangle, float toangle, Easing.EasingOption easing) {

    if (android.os.Build.VERSION.SDK_INT < 11)
        return;

    setRotationAngle(fromangle);

    ObjectAnimator spinAnimator = ObjectAnimator.ofFloat(this, "rotationAngle", fromangle,
            toangle);
    spinAnimator.setDuration(durationmillis);
    spinAnimator.setInterpolator(Easing.getEasingFunctionFromOption(easing));

    spinAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            postInvalidate();
        }
    });
    spinAnimator.start();
}
 
Example #23
Source File: PieRadarChartBase.java    From NetKnight with Apache License 2.0 6 votes vote down vote up
/**
 * Applys a spin animation to the Chart.
 * 
 * @param durationmillis
 * @param fromangle
 * @param toangle
 */
@SuppressLint("NewApi")
public void spin(int durationmillis, float fromangle, float toangle, Easing.EasingOption easing) {

    if (android.os.Build.VERSION.SDK_INT < 11)
        return;

    setRotationAngle(fromangle);

    ObjectAnimator spinAnimator = ObjectAnimator.ofFloat(this, "rotationAngle", fromangle,
            toangle);
    spinAnimator.setDuration(durationmillis);
    spinAnimator.setInterpolator(Easing.getEasingFunctionFromOption(easing));

    spinAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            postInvalidate();
        }
    });
    spinAnimator.start();
}
 
Example #24
Source File: PaymentRequestUI.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
        int oldLeft, int oldTop, int oldRight, int oldBottom) {
    if (mSheetAnimator != null) mSheetAnimator.cancel();

    mRequestView.removeOnLayoutChangeListener(this);
    mContainerHeightDifference = (bottom - top) - (oldBottom - oldTop);

    ValueAnimator containerAnimator = ValueAnimator.ofFloat(1f, 0f);
    containerAnimator.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float alpha = (Float) animation.getAnimatedValue();
            update(alpha);
        }
    });

    mSheetAnimator = containerAnimator;
    mSheetAnimator.setDuration(DIALOG_ENTER_ANIMATION_MS);
    mSheetAnimator.setInterpolator(new LinearOutSlowInInterpolator());
    mSheetAnimator.addListener(this);
    mSheetAnimator.start();
}
 
Example #25
Source File: PieRadarChartBase.java    From JNChartDemo with Apache License 2.0 6 votes vote down vote up
/**
 * Applys a spin animation to the Chart.
 * 
 * @param durationmillis
 * @param fromangle
 * @param toangle
 */
@SuppressLint("NewApi")
public void spin(int durationmillis, float fromangle, float toangle, Easing.EasingOption easing) {

    if (android.os.Build.VERSION.SDK_INT < 11)
        return;

    setRotationAngle(fromangle);

    ObjectAnimator spinAnimator = ObjectAnimator.ofFloat(this, "rotationAngle", fromangle,
            toangle);
    spinAnimator.setDuration(durationmillis);
    spinAnimator.setInterpolator(Easing.getEasingFunctionFromOption(easing));

    spinAnimator.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            postInvalidate();
        }
    });
    spinAnimator.start();
}
 
Example #26
Source File: PaymentRequestUI.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
        int oldLeft, int oldTop, int oldRight, int oldBottom) {
    if (mSheetAnimator != null) mSheetAnimator.cancel();

    mRequestView.removeOnLayoutChangeListener(this);
    mContainerHeightDifference = (bottom - top) - (oldBottom - oldTop);

    ValueAnimator containerAnimator = ValueAnimator.ofFloat(1f, 0f);
    containerAnimator.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float alpha = (Float) animation.getAnimatedValue();
            update(alpha);
        }
    });

    mSheetAnimator = containerAnimator;
    mSheetAnimator.setDuration(DIALOG_ENTER_ANIMATION_MS);
    mSheetAnimator.setInterpolator(new LinearOutSlowInInterpolator());
    mSheetAnimator.addListener(this);
    mSheetAnimator.start();
}
 
Example #27
Source File: TestFragment.java    From glide-support with The Unlicense 6 votes vote down vote up
@TargetApi(VERSION_CODES.HONEYCOMB)
private void animateColors(Palette palette) {
	int color = palette.getVibrantColor(defaultColor);
	Swatch swatch = palette.getMutedSwatch();
	anims = new AnimatorSet();

	ValueAnimator cardBG = ValueAnimator.ofObject(new ArgbEvaluator(),
			defaultColor/* cannot retrieve card BG */, color);
	cardBG.addUpdateListener(new AnimatorUpdateListener() {
		@Override public void onAnimationUpdate(ValueAnimator animation) {
			holder.card.setCardBackgroundColor((Integer)animation.getAnimatedValue());
		}
	});
	anims.play(cardBG);
	if (swatch != null) {
		ObjectAnimator textColorBG = ofObject(holder.titleView, "backgroundColor", new ArgbEvaluator(),
				((ColorDrawable)holder.titleView.getBackground()).getColor(), swatch.getRgb());
		ObjectAnimator textColor = ofObject(holder.titleView, "textColor", new ArgbEvaluator(),
				holder.titleView.getCurrentTextColor(), swatch.getTitleTextColor());
		anims.play(textColor);
		anims.play(textColorBG);
	}
	anims.playTogether(anims.getChildAnimations());
	anims.setDuration(3000);
	anims.start();
}
 
Example #28
Source File: MyDownloadActivity.java    From letv with Apache License 2.0 6 votes vote down vote up
private void doTabPageIndicatorAnimator(int start, int end) {
    this.mTabPIValueAnimator = ValueAnimator.ofInt(new int[]{start, end});
    this.mTabPIValueAnimator.addUpdateListener(new AnimatorUpdateListener(this) {
        final /* synthetic */ MyDownloadActivity this$0;

        {
            if (HotFix.PREVENT_VERIFY) {
                System.out.println(VerifyLoad.class);
            }
            this.this$0 = this$0;
        }

        public void onAnimationUpdate(ValueAnimator animation) {
            int value = ((Integer) animation.getAnimatedValue()).intValue();
            LayoutParams layoutParams = this.this$0.mIndicator.getLayoutParams();
            layoutParams.height = value;
            this.this$0.mIndicator.setLayoutParams(layoutParams);
        }
    });
    this.mTabPIValueAnimator.start();
}
 
Example #29
Source File: ClearTextEndIconDelegate.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
private ValueAnimator getScaleAnimator() {
  ValueAnimator animator = ValueAnimator.ofFloat(ANIMATION_SCALE_FROM_VALUE, 1);
  animator.setInterpolator(AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR);
  animator.setDuration(ANIMATION_SCALE_DURATION);
  animator.addUpdateListener(
      new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(@NonNull ValueAnimator animation) {
          float scale = (float) animation.getAnimatedValue();
          endIconView.setScaleX(scale);
          endIconView.setScaleY(scale);
        }
      });
  return animator;
}
 
Example #30
Source File: DragView.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
public void crossFade(int duration) {
    ValueAnimator va = LauncherAnimUtils.ofFloat(this, 0f, 1f);
    va.setDuration(duration);
    va.setInterpolator(new DecelerateInterpolator(1.5f));
    va.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mCrossFadeProgress = animation.getAnimatedFraction();
        }
    });
    va.start();
}