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; }
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; }
@CheckResult PropertyValuesHolder createReverse() { final int max; if (isFloat) { float[] newfVals = new float[fVals.length]; max = fVals.length; for (int i = 0; i < max; i++) { newfVals[i] = fVals[max - i - 1]; } return PropertyValuesHolder.ofFloat(property, newfVals); } else { int[] newiVals = new int[iVals.length]; max = iVals.length; for (int i = 0; i < max; i++) { newiVals[i] = iVals[max - i - 1]; } return PropertyValuesHolder.ofInt(property, newiVals); } }
/** * 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(sPropertyScaleX, k0, k1, k2, k3); PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe(sPropertyScaleY, 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; kf0 = Keyframe.ofFloat(0f, 1f); kf1 = Keyframe.ofFloat(1f, 0f); PropertyValuesHolder fade = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1); ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, fade).setDuration(300); disappearAnimator.addUpdateListener(mInvalidateUpdateListener); return disappearAnimator; }
public ObjectAnimator getReappearAnimator() { if (!mIsInitialized || !mDrawValuesReady) { Log.e(TAG, "RadialSelectorView was not ready for animation."); return null; } Keyframe kf0, kf1; kf0 = Keyframe.ofFloat(0f, 0f); kf1 = Keyframe.ofFloat(1f, 1f); PropertyValuesHolder fade = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1); ObjectAnimator reappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, fade).setDuration(300); reappearAnimator.addUpdateListener(mInvalidateUpdateListener); return reappearAnimator; }
/** * 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; }
/** * 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( AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(labelToAnimate) : labelToAnimate, scaleX, scaleY); pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION); return pulseAnimator; }
/** * 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(AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(labelToAnimate) : labelToAnimate, scaleX, scaleY); pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION); return pulseAnimator; }
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 getReappearAnimator() { if (!mIsInitialized || !mDrawValuesReady) { Log.e(TAG, "RadialSelectorView was not ready for animation."); return null; } Keyframe kf0, kf1, kf2, kf3; float midwayPoint = 0.2f; int duration = 500; // The time points are half of what they would normally be, because this animation is // staggered against the disappear so they happen seamlessly. The reappear starts // halfway into the disappear. float delayMultiplier = 0.25f; float transitionDurationMultiplier = 1f; float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; int totalDuration = (int) (duration * totalDurationMultiplier); float delayPoint = (delayMultiplier * duration) / totalDuration; 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); ObjectAnimator reappearAnimator = ObjectAnimator.ofPropertyValuesHolder( this, radiusReappear, fadeIn).setDuration(totalDuration); reappearAnimator.addUpdateListener(mInvalidateUpdateListener); return reappearAnimator; }
/** * 缩放动画 * * @param view */ public void viewAnimationScal(final View view) { PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("scaleX", 1, 1.5f, 1); PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("scaleY", 1, 1.5f, 1); ViewHelper.setPivotX(view, view.getWidth() >> 1); ViewHelper.setPivotY(view, view.getHeight() >> 1); ObjectAnimator animator2 = ObjectAnimator.ofPropertyValuesHolder(view, pvhX, pvhY).setDuration(300); animator2.setInterpolator(mInterpolator); animator2.start(); }
@Override public List<Animator> createAnimation() { List<Animator> animators=new ArrayList<>(); PropertyValuesHolder rotation5=PropertyValuesHolder.ofFloat("rotationX",0,180,180,0,0); PropertyValuesHolder rotation6=PropertyValuesHolder.ofFloat("rotationY",0,0,180,180,0); ObjectAnimator animator=ObjectAnimator.ofPropertyValuesHolder(getTarget(), rotation6,rotation5); animator.setInterpolator(new LinearInterpolator()); animator.setRepeatCount(-1); animator.setDuration(2500); animator.start(); animators.add(animator); return animators; }
@Override public List<Animator> createAnimation() { PropertyValuesHolder rotation6=PropertyValuesHolder.ofFloat("rotationX",0,360); ObjectAnimator animator=ObjectAnimator.ofPropertyValuesHolder(getTarget(), rotation6); animator.setInterpolator(new LinearInterpolator()); animator.setRepeatCount(-1); animator.setDuration(1500); animator.start(); List<Animator> animators=new ArrayList<>(); animators.add(animator); return animators; }
/** * 缩放动画 * @param view */ public static void viewScaleAnimation(View view) { PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("scaleX", 1, 1.3f, 1); PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("scaleY", 1, 1.3f, 1); ViewHelper.setPivotX(view, view.getWidth() >> 1); ViewHelper.setPivotY(view, view.getHeight() >> 1); ObjectAnimator animator2 = ObjectAnimator.ofPropertyValuesHolder(view, pvhX, pvhY).setDuration(150); animator2.setInterpolator(mInterpolator); animator2.start(); }
private void move(boolean isFrom, String strX, String strY) { float currentX = ViewHelper.getX(view); float currentY = ViewHelper.getY(view); PropertyValuesHolder x = PropertyValuesHolder.ofFloat(strX, !isFrom ? currentX : floatTargets[0], isFrom ? currentX : floatTargets[0]); PropertyValuesHolder y = PropertyValuesHolder.ofFloat(strY, !isFrom ? currentY : floatTargets[1], isFrom ? currentY : floatTargets[1]); setValues(x, y); addListener(strX, strY); }
private void scale(boolean isFrom, String strX, String strY) { float currentScaleX = ViewHelper.getScaleX(view); float currentScaleY = ViewHelper.getScaleY(view); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat(strX, !isFrom ? currentScaleX : floatTargets[0], isFrom ? currentScaleX : floatTargets[0]); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat(strY, !isFrom ? currentScaleY : floatTargets[1], isFrom ? currentScaleY : floatTargets[1]); setValues(scaleX, scaleY); addListener(strX, strY); }
protected PropertyValuesHolder[] getValuesHolders() { final int size = mHolders.size(); PropertyValuesHolder[] holders = new PropertyValuesHolder[size]; for (int i = 0; i < size; i++) { holders[i] = mHolders.valueAt(i); } return holders; }
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( AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : this, radiusDisappear, fadeOut).setDuration( duration); disappearAnimator.addUpdateListener(mInvalidateUpdateListener); return disappearAnimator; }
public ObjectAnimator getReappearAnimator() { if (!mIsInitialized || !mDrawValuesReady) { Log.e(TAG, "RadialSelectorView was not ready for animation."); return null; } Keyframe kf0, kf1, kf2, kf3; float midwayPoint = 0.2f; int duration = 500; // The time points are half of what they would normally be, because this animation is // staggered against the disappear so they happen seamlessly. The reappear starts // halfway into the disappear. float delayMultiplier = 0.25f; float transitionDurationMultiplier = 1f; float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; int totalDuration = (int) (duration * totalDurationMultiplier); float delayPoint = (delayMultiplier * duration) / totalDuration; 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); ObjectAnimator reappearAnimator = ObjectAnimator.ofPropertyValuesHolder( AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : this, radiusReappear, fadeIn) .setDuration(totalDuration); reappearAnimator.addUpdateListener(mInvalidateUpdateListener); return reappearAnimator; }
/** * Translation animator object applied to the view * @param view view to set the animation * @param top current view top * @param bottom curret view bottom * @param translateTop amount of top translation to the view * @param translateBottom amount of bottom translation to the view * @return animator object */ private Animator getAnimation(final View view, int top, int bottom, float translateTop, float translateBottom) { int endTop = (int)(top + translateTop); int endBottom = (int)(bottom + translateBottom); PropertyValuesHolder translationTop = PropertyValuesHolder.ofInt("top", top, endTop); PropertyValuesHolder translationBottom = PropertyValuesHolder.ofInt("bottom", bottom, endBottom); return ObjectAnimator.ofPropertyValuesHolder(view, translationTop, translationBottom); }
public ObjectAnimator getReappearAnimator() { if (!mIsInitialized || !mDrawValuesReady) { Log.e(TAG, "RadialSelectorView was not ready for animation."); return null; } Keyframe kf0, kf1, kf2, kf3; float midwayPoint = 0.2f; int duration = 500; // The time points are half of what they would normally be, because this animation is // staggered against the disappear so they happen seamlessly. The reappear starts // halfway into the disappear. float delayMultiplier = 0.25f; float transitionDurationMultiplier = 1f; float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; int totalDuration = (int) (duration * totalDurationMultiplier); float delayPoint = (delayMultiplier * duration) / totalDuration; 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); ObjectAnimator reappearAnimator = ObjectAnimator.ofPropertyValuesHolder( AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : this, radiusReappear, fadeIn).setDuration( totalDuration); reappearAnimator.addUpdateListener(mInvalidateUpdateListener); return reappearAnimator; }
/** * Render the animations for appearing and disappearing. */ private void renderAnimations() { Keyframe kf0, kf1, kf2, kf3; float midwayPoint = 0.2f; int duration = 500; // Set up animator for disappearing. 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); mDisappearAnimator = ObjectAnimator.ofPropertyValuesHolder( this, radiusDisappear, fadeOut).setDuration(duration); mDisappearAnimator.addUpdateListener(mInvalidateUpdateListener); // Set up animator for reappearing. float delayMultiplier = 0.25f; float transitionDurationMultiplier = 1f; float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier; int totalDuration = (int) (duration * totalDurationMultiplier); float delayPoint = (delayMultiplier * duration) / totalDuration; 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); mReappearAnimator = ObjectAnimator.ofPropertyValuesHolder( this, radiusReappear, fadeIn).setDuration(totalDuration); mReappearAnimator.addUpdateListener(mInvalidateUpdateListener); }
public static PropertyValuesHolder glide(Skill skill, float duration, PropertyValuesHolder propertyValuesHolder){ propertyValuesHolder.setEvaluator(skill.getMethod(duration)); return propertyValuesHolder; }