/** * Shake the view from left to right * * @param view * @return */ public static ObjectAnimator leftRightShake(View view) { // int delta = view.getResources().getDimensionPixelOffset(R.dimen.spacing_medium); int delta = 40; PropertyValuesHolder pvhTranslateX = PropertyValuesHolder.ofKeyframe(View.TRANSLATION_X, Keyframe.ofFloat(0f, 0), Keyframe.ofFloat(.10f, -delta), Keyframe.ofFloat(.26f, delta), Keyframe.ofFloat(.42f, -delta), Keyframe.ofFloat(.58f, delta), Keyframe.ofFloat(.74f, -delta), Keyframe.ofFloat(.90f, delta), Keyframe.ofFloat(1f, 0f) ); return ObjectAnimator.ofPropertyValuesHolder(view, pvhTranslateX). setDuration(500); }
public KeyframeAssert hasFraction(float fraction) { isNotNull(); float actualFraction = actual.getFraction(); assertThat(actualFraction) // .overridingErrorMessage("Expected fraction <%s> but was <%s>.", fraction, actualFraction) // .isEqualTo(fraction); return this; }
public KeyframeAssert hasInterpolator(TimeInterpolator interpolator) { isNotNull(); TimeInterpolator actualInterpolator = actual.getInterpolator(); assertThat(actualInterpolator) // .overridingErrorMessage("Expected interpolator <%s> but was <%s>.", interpolator, actualInterpolator) // .isSameAs(interpolator); return this; }
public KeyframeAssert hasType(Class type) { isNotNull(); Class actualType = actual.getType(); assertThat(actualType) // .overridingErrorMessage("Expected type <%s> but was <%s>.", type, actualType) // .isEqualTo(type); return this; }
public KeyframeAssert hasType(Class type) { isNotNull(); Class actualType = actual.getType(); assertThat(actualType) // .overridingErrorMessage("Expected type <%s> but was <%s>.", type, actualType) // .isEqualTo(type); return this; }
public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio, float increaseRatio) { Keyframe k0 = Keyframe.ofFloat(0f, 1f); Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio); Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio); Keyframe k3 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3); PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3); ObjectAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY); pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION); return pulseAnimator; }
public KeyframeAssert hasFraction(float fraction) { isNotNull(); float actualFraction = actual.getFraction(); assertThat(actualFraction) // .overridingErrorMessage("Expected fraction <%s> but was <%s>.", fraction, actualFraction) // .isEqualTo(fraction); return this; }
public KeyframeAssert hasInterpolator(TimeInterpolator interpolator) { isNotNull(); TimeInterpolator actualInterpolator = actual.getInterpolator(); assertThat(actualInterpolator) // .overridingErrorMessage("Expected interpolator <%s> but was <%s>.", interpolator, actualInterpolator) // .isSameAs(interpolator); return this; }
Keyframe.ofFloat(0f, 1f), Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f), Keyframe.ofFloat(.4f, 1.1f), Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f), Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f), Keyframe.ofFloat(.9f, 1.1f), Keyframe.ofFloat(1f, 1f) ); Keyframe.ofFloat(0f, 1f), Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f), Keyframe.ofFloat(.4f, 1.1f), Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f), Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f), Keyframe.ofFloat(.9f, 1.1f), Keyframe.ofFloat(1f, 1f) ); Keyframe.ofFloat(0f, 0f), Keyframe.ofFloat(.1f, -3f * shakeFactor), Keyframe.ofFloat(.2f, -3f * shakeFactor),
/** * Render an animator to pulsate a view in place. * @param labelToAnimate the view to pulsate. * @return The animator object. Use .start() to begin. */ public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio, float increaseRatio) { Keyframe k0 = Keyframe.ofFloat(0f, 1f); Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio); Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio); Keyframe k3 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3); PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3); ObjectAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY); pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION); return pulseAnimator; }
midwayPoint = 1 - (midwayPoint * (1 - delayPoint)); kf0 = Keyframe.ofFloat(0f, mTransitionEndRadiusMultiplier); kf1 = Keyframe.ofFloat(delayPoint, mTransitionEndRadiusMultiplier); kf2 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf3 = Keyframe.ofFloat(1f, 1); PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe( "animationRadiusMultiplier", kf0, kf1, kf2, kf3); kf0 = Keyframe.ofFloat(0f, 0f); kf1 = Keyframe.ofFloat(delayPoint, 0f); kf2 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2);
public ObjectAnimator getDisappearAnimator() { if (!mIsInitialized || !mDrawValuesReady) { Log.e(TAG, "RadialSelectorView was not ready for animation."); return null; } Keyframe kf0, kf1, kf2; float midwayPoint = 0.2f; int duration = 500; kf0 = Keyframe.ofFloat(0f, 1); kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier); PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe( "animationRadiusMultiplier", kf0, kf1, kf2); kf0 = Keyframe.ofFloat(0f, 1f); kf1 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1); ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder( this, radiusDisappear, fadeOut).setDuration(duration); disappearAnimator.addUpdateListener(mInvalidateUpdateListener); return disappearAnimator; }
/** * Render an animator to pulsate a view in place. * @param labelToAnimate the view to pulsate. * @return The animator object. Use .start() to begin. */ public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio, float increaseRatio) { Keyframe k0 = Keyframe.ofFloat(0f, 1f); Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio); Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio); Keyframe k3 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3); PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3); ObjectAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY); pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION); return pulseAnimator; } }
public ObjectAnimator getDisappearAnimator() { if (!mIsInitialized || !mDrawValuesReady) { Log.e(TAG, "RadialSelectorView was not ready for animation."); return null; } Keyframe kf0, kf1, kf2; float midwayPoint = 0.2f; int duration = 500; kf0 = Keyframe.ofFloat(0f, 1); kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier); PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe( "animationRadiusMultiplier", kf0, kf1, kf2); kf0 = Keyframe.ofFloat(0f, 1f); kf1 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1); ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder( this, radiusDisappear, fadeOut).setDuration(duration); disappearAnimator.addUpdateListener(mInvalidateUpdateListener); return disappearAnimator; }
Keyframe scaleXFrame1 = Keyframe.ofFloat(0f, 1.0f); Keyframe scaleXFrame2 = Keyframe.ofFloat(0.05f, 1.5f); Keyframe scaleXFrame3 = Keyframe.ofFloat(0.1f, 0.8f); Keyframe scaleXFrame4 = Keyframe.ofFloat(0.15f, 1.0f); Keyframe scaleXFrame5 = Keyframe.ofFloat(0.5f, 1.0f); Keyframe scaleXFrame6 = Keyframe.ofFloat(0.55f, 1.5f); Keyframe scaleXFrame7 = Keyframe.ofFloat(0.6f, 0.8f); Keyframe scaleXFrame8 = Keyframe.ofFloat(0.65f, 1.0f); PropertyValuesHolder scaleXHolder = PropertyValuesHolder.ofKeyframe("scaleX", scaleXFrame1, scaleXFrame2, scaleXFrame3, scaleXFrame4, scaleXFrame5, scaleXFrame6, scaleXFrame7, scaleXFrame8); Keyframe scaleYFrame1 = Keyframe.ofFloat(0f, 1.0f); Keyframe scaleYFrame2 = Keyframe.ofFloat(0.05f, 0.5f); Keyframe scaleYFrame3 = Keyframe.ofFloat(0.1f, 1.15f); Keyframe scaleYFrame4 = Keyframe.ofFloat(0.15f, 1.0f); Keyframe scaleYFrame5 = Keyframe.ofFloat(0.5f, 1.0f); Keyframe scaleYFrame6 = Keyframe.ofFloat(0.55f, 0.5f); Keyframe scaleYFrame7 = Keyframe.ofFloat(0.6f, 1.15f); Keyframe scaleYFrame8 = Keyframe.ofFloat(0.65f, 1.0f); PropertyValuesHolder scaleYHolder = PropertyValuesHolder.ofKeyframe("scaleY", scaleYFrame1, scaleYFrame2, scaleYFrame3, scaleYFrame4, scaleYFrame5, scaleYFrame6, scaleYFrame7, scaleYFrame8); Keyframe translationY1 = Keyframe.ofFloat(0f, 0f); Keyframe translationY2 = Keyframe.ofFloat(0.085f, 0f); Keyframe translationY3 = Keyframe.ofFloat(0.2f, -jumpHeight); Keyframe translationY4 = Keyframe.ofFloat(0.25f, -jumpHeight); Keyframe translationY5 = Keyframe.ofFloat(0.375f, 0f);
midwayPoint = 1 - (midwayPoint * (1 - delayPoint)); kf0 = Keyframe.ofFloat(0f, mTransitionEndRadiusMultiplier); kf1 = Keyframe.ofFloat(delayPoint, mTransitionEndRadiusMultiplier); kf2 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf3 = Keyframe.ofFloat(1f, 1); PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe( "animationRadiusMultiplier", kf0, kf1, kf2, kf3); kf0 = Keyframe.ofFloat(0f, 0f); kf1 = Keyframe.ofFloat(delayPoint, 0f); kf2 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2);
public ObjectAnimator getDisappearAnimator() { if (!mIsInitialized || !mDrawValuesReady) { Log.e(TAG, "RadialSelectorView was not ready for animation."); return null; } Keyframe kf0, kf1, kf2; float midwayPoint = 0.2f; int duration = 500; kf0 = Keyframe.ofFloat(0f, 1); kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier); PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe( "animationRadiusMultiplier", kf0, kf1, kf2); kf0 = Keyframe.ofFloat(0f, 1f); kf1 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1); ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder( this, radiusDisappear, fadeOut).setDuration(duration); disappearAnimator.addUpdateListener(mInvalidateUpdateListener); return disappearAnimator; }
midwayPoint = 1 - (midwayPoint * (1 - delayPoint)); kf0 = Keyframe.ofFloat(0f, mTransitionEndRadiusMultiplier); kf1 = Keyframe.ofFloat(delayPoint, mTransitionEndRadiusMultiplier); kf2 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf3 = Keyframe.ofFloat(1f, 1); PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe( "animationRadiusMultiplier", kf0, kf1, kf2, kf3); kf0 = Keyframe.ofFloat(0f, 0f); kf1 = Keyframe.ofFloat(delayPoint, 0f); kf2 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2);
kf0 = Keyframe.ofFloat(0f, 1); kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier); PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe( "animationRadiusMultiplier", kf0, kf1, kf2); kf0 = Keyframe.ofFloat(0f, 1f); kf1 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1); midwayPoint = 1 - (midwayPoint * (1 - delayPoint)); kf0 = Keyframe.ofFloat(0f, mTransitionEndRadiusMultiplier); kf1 = Keyframe.ofFloat(delayPoint, mTransitionEndRadiusMultiplier); kf2 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier); kf3 = Keyframe.ofFloat(1f, 1); PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe( "animationRadiusMultiplier", kf0, kf1, kf2, kf3); kf0 = Keyframe.ofFloat(0f, 0f); kf1 = Keyframe.ofFloat(delayPoint, 0f); kf2 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2);