Java Code Examples for android.animation.ValueAnimator#ofPropertyValuesHolder()
The following examples show how to use
android.animation.ValueAnimator#ofPropertyValuesHolder() .
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: DragState.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private ValueAnimator createCancelAnimationLocked() { final ValueAnimator animator = ValueAnimator.ofPropertyValuesHolder( PropertyValuesHolder.ofFloat( ANIMATED_PROPERTY_X, mCurrentX - mThumbOffsetX, mCurrentX), PropertyValuesHolder.ofFloat( ANIMATED_PROPERTY_Y, mCurrentY - mThumbOffsetY, mCurrentY), PropertyValuesHolder.ofFloat(ANIMATED_PROPERTY_SCALE, 1, 0), PropertyValuesHolder.ofFloat(ANIMATED_PROPERTY_ALPHA, mOriginalAlpha, 0)); final AnimationListener listener = new AnimationListener(); animator.setDuration(MIN_ANIMATION_DURATION_MS); animator.setInterpolator(mCubicEaseOutInterpolator); animator.addListener(listener); animator.addUpdateListener(listener); mService.mAnimationHandler.post(() -> animator.start()); return animator; }
Example 2
Source File: RippleAnimator.java From TheGlowingLoader with Apache License 2.0 | 6 votes |
public void startCircleMajor(final Callback callback) { PropertyValuesHolder rp = PropertyValuesHolder.ofFloat("radius", 0, circleMaxRadius); PropertyValuesHolder ap = PropertyValuesHolder.ofFloat("alpha", 1, 0); PropertyValuesHolder sp = PropertyValuesHolder.ofInt("stroke", (int) (circleMaxRadius * .15f), 0); ValueAnimator va = ValueAnimator.ofPropertyValuesHolder(rp, ap, sp); va.setInterpolator(new AccelerateInterpolator(.4f)); va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { circleRadius = (float) animation.getAnimatedValue("radius"); circleAlpha = (float) animation.getAnimatedValue("alpha"); circleStroke = (int) animation.getAnimatedValue("stroke"); callback.onValueUpdated(); } }); va.setDuration(450); va.start(); }
Example 3
Source File: RippleAnimator.java From TheGlowingLoader with Apache License 2.0 | 6 votes |
public void startCircleMinor(final Callback callback) { PropertyValuesHolder rp2 = PropertyValuesHolder.ofFloat("radius", 0, circleMaxRadius * .60f); PropertyValuesHolder ap2 = PropertyValuesHolder.ofFloat("alpha", 1, 0); PropertyValuesHolder sp2 = PropertyValuesHolder.ofInt("stroke", (int) (circleMaxRadius * .06f), 0); ValueAnimator va2 = ValueAnimator.ofPropertyValuesHolder(rp2, ap2, sp2); va2.setInterpolator(new AccelerateInterpolator(.4f)); va2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { circleRadius2 = (float) animation.getAnimatedValue("radius"); circleAlpha2 = (float) animation.getAnimatedValue("alpha"); circleStroke2 = (int) animation.getAnimatedValue("stroke"); callback.onValueUpdated(); } }); va2.setDuration(380); va2.start(); }
Example 4
Source File: CircleAnimView.java From customview-samples with Apache License 2.0 | 6 votes |
public void startAnim(){ if(mValueAnimator!=null&&mValueAnimator.isRunning()){ return; } Keyframe k1 = Keyframe.ofFloat(0,mMinSize/2); Keyframe k2 = Keyframe.ofFloat(0.5f,mMinSize/4); Keyframe k3 = Keyframe.ofFloat(1,mMinSize/2); PropertyValuesHolder propertyValuesHolder = PropertyValuesHolder.ofKeyframe("scale",k1,k2,k3); mValueAnimator = ValueAnimator.ofPropertyValuesHolder(propertyValuesHolder); mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mRadius = (float) animation.getAnimatedValue(); invalidate(); } }); mValueAnimator.setRepeatCount(ValueAnimator.INFINITE); mValueAnimator.setDuration(2000); mValueAnimator.start(); }
Example 5
Source File: ImageMatrixTouchHandler.java From PinchToZoom with MIT License | 6 votes |
@Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (mode == DRAG) { if (flingDuration > 0 && !isAnimating()) { float factor = ((float) flingDuration / 1000f) * flingExaggeration; float[] values = corrector.getValues(); float dx = (velocityX * factor) * values[Matrix.MSCALE_X]; float dy = (velocityY * factor) * values[Matrix.MSCALE_Y]; PropertyValuesHolder flingX = PropertyValuesHolder.ofFloat(FlingAnimatorHandler.PROPERTY_TRANSLATE_X, values[Matrix.MTRANS_X], values[Matrix.MTRANS_X] + dx); PropertyValuesHolder flingY = PropertyValuesHolder.ofFloat(FlingAnimatorHandler.PROPERTY_TRANSLATE_Y, values[Matrix.MTRANS_Y], values[Matrix.MTRANS_Y] + dy); valueAnimator = ValueAnimator.ofPropertyValuesHolder(flingX, flingY); valueAnimator.setDuration(flingDuration); valueAnimator.addUpdateListener(new FlingAnimatorHandler(corrector)); valueAnimator.setInterpolator(new DecelerateInterpolator()); valueAnimator.start(); return true; } } return super.onFling(e1, e2, velocityX, velocityY); }
Example 6
Source File: BallScale.java From crystal-preloaders with Apache License 2.0 | 6 votes |
@Override protected List<ValueAnimator> setupAnimation() { PropertyValuesHolder radiusValueHolder = PropertyValuesHolder.ofInt("radius", 0, Math.min(getWidth() / 2, getHeight() / 2)); PropertyValuesHolder opacityValueHolder = PropertyValuesHolder.ofInt("opacity", 200, 0); valueAnimator = ValueAnimator.ofPropertyValuesHolder(radiusValueHolder, opacityValueHolder); valueAnimator.setDuration(1000); valueAnimator.setRepeatCount(ValueAnimator.INFINITE); valueAnimator.setRepeatMode(ValueAnimator.RESTART); valueAnimator.setInterpolator(new LinearInterpolator()); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { radius = (int) animation.getAnimatedValue("radius"); opacity = (int) animation.getAnimatedValue("opacity"); getTarget().invalidate(); } }); // create animator list final List<ValueAnimator> animators = new ArrayList<>(); animators.add(valueAnimator); return animators; }
Example 7
Source File: BallSpinFade.java From crystal-preloaders with Apache License 2.0 | 6 votes |
private void setAnimator(final int index){ valueAnimators[index] = ValueAnimator.ofPropertyValuesHolder(radiusValueHolder, opacityValueHolder); valueAnimators[index].setStartDelay(index * DELAY); valueAnimators[index].setDuration(1000); valueAnimators[index].setRepeatCount(ValueAnimator.INFINITE); valueAnimators[index].setRepeatMode(ValueAnimator.REVERSE); valueAnimators[index].setInterpolator(new AccelerateInterpolator()); valueAnimators[index].addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { circleRadius[index] = (int) animation.getAnimatedValue("radius"); circleOpacity[index] = (int) animation.getAnimatedValue("opacity"); if(index == 0 || index == valueAnimators.length){ getTarget().invalidate(); } } }); }
Example 8
Source File: ClockView.java From MiClockView with Apache License 2.0 | 6 votes |
private void startNewSteadyAnim() { final String propertyNameRotateX = "canvasRotateX"; final String propertyNameRotateY = "canvasRotateY"; PropertyValuesHolder holderRotateX = PropertyValuesHolder.ofFloat(propertyNameRotateX, canvasRotateX, 0); PropertyValuesHolder holderRotateY = PropertyValuesHolder.ofFloat(propertyNameRotateY, canvasRotateY, 0); steadyAnim = ValueAnimator.ofPropertyValuesHolder(holderRotateX, holderRotateY); steadyAnim.setDuration(1000); steadyAnim.setInterpolator(new BounceInterpolator()); steadyAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { canvasRotateX = (float) animation.getAnimatedValue(propertyNameRotateX); canvasRotateY = (float) animation.getAnimatedValue(propertyNameRotateY); } }); steadyAnim.start(); }
Example 9
Source File: DragState.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private ValueAnimator createReturnAnimationLocked() { final ValueAnimator animator = ValueAnimator.ofPropertyValuesHolder( PropertyValuesHolder.ofFloat( ANIMATED_PROPERTY_X, mCurrentX - mThumbOffsetX, mOriginalX - mThumbOffsetX), PropertyValuesHolder.ofFloat( ANIMATED_PROPERTY_Y, mCurrentY - mThumbOffsetY, mOriginalY - mThumbOffsetY), PropertyValuesHolder.ofFloat(ANIMATED_PROPERTY_SCALE, 1, 1), PropertyValuesHolder.ofFloat( ANIMATED_PROPERTY_ALPHA, mOriginalAlpha, mOriginalAlpha / 2)); final float translateX = mOriginalX - mCurrentX; final float translateY = mOriginalY - mCurrentY; // Adjust the duration to the travel distance. final double travelDistance = Math.sqrt(translateX * translateX + translateY * translateY); final double displayDiagonal = Math.sqrt(mDisplaySize.x * mDisplaySize.x + mDisplaySize.y * mDisplaySize.y); final long duration = MIN_ANIMATION_DURATION_MS + (long) (travelDistance / displayDiagonal * (MAX_ANIMATION_DURATION_MS - MIN_ANIMATION_DURATION_MS)); final AnimationListener listener = new AnimationListener(); animator.setDuration(duration); animator.setInterpolator(mCubicEaseOutInterpolator); animator.addListener(listener); animator.addUpdateListener(listener); mService.mAnimationHandler.post(() -> animator.start()); return animator; }
Example 10
Source File: RotaProgressBar.java From OTTLivePlayer_vlc with MIT License | 5 votes |
private void init() { pvh = PropertyValuesHolder.ofFloat("sweepAngle", 0, 360.0f); valueAnimator = ValueAnimator.ofPropertyValuesHolder(pvh); valueAnimator.setInterpolator(interpolator); valueAnimator.setDuration(1500); valueAnimator.setRepeatCount(Integer.MAX_VALUE); valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { invalidate(); } }); }
Example 11
Source File: AnimUtil.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
public static Animator animNumSwitch(int i1, int j1, TextView textview) { int k1 = j1 - i1; String s = String.valueOf(Math.abs(k1)); int ai[] = new int[s.length()]; for (int l1 = 0; l1 < s.length(); l1++) { ai[l1] = -48 + s.charAt(-1 + (s.length() - l1)); } ArrayList arraylist = new ArrayList(); arraylist.add(formatNumStyle(i1)); int i2 = 0; int j2 = 1; do { if (i2 >= ai.length) { break; } int i3 = Integer.valueOf(ai[i2]).intValue(); int j3 = 0; while (j3 < i3) { if (k1 > 0) { i1 += j2; } else if (k1 < 0) { i1 -= j2; } arraylist.add(formatNumStyle(i1)); j3++; } j2 *= 10; i2++; } while (true); arraylist.add(formatNumStyle(j1)); Keyframe akeyframe[] = new Keyframe[1 + arraylist.size()]; int k2 = 0; while (k2 <= arraylist.size()) { float f1 = (1.0F / (float)arraylist.size()) * (float)k2; int l2; if (k2 == 0) { l2 = 0; } else { l2 = k2 - 1; } akeyframe[k2] = Keyframe.ofObject(f1, arraylist.get(l2)); k2++; } ValueAnimator valueanimator = ValueAnimator.ofPropertyValuesHolder(new PropertyValuesHolder[] { PropertyValuesHolder.ofKeyframe("Text", akeyframe) }); valueanimator.setEvaluator(new g()); valueanimator.addUpdateListener(new h(textview)); valueanimator.setDuration(20 * akeyframe.length); return valueanimator; }
Example 12
Source File: AnimUtil.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
public static Animator animNumSwitch1(int i1, int j1, TextView textview) { String s = String.valueOf(i1); int ai[] = new int[s.length()]; for (int k1 = 0; k1 < s.length(); k1++) { ai[-1 + (s.length() - k1)] = -48 + s.charAt(k1); Debug.i("Chart.AnimUtil", (new StringBuilder()).append("Num : ").append(ai[-1 + (s.length() - k1)]).toString()); } String s1 = String.valueOf(j1); int ai1[] = new int[s1.length()]; for (int l1 = 0; l1 < s1.length(); l1++) { ai1[-1 + (s1.length() - l1)] = -48 + s1.charAt(l1); Debug.i("Chart.AnimUtil", (new StringBuilder()).append("Num : ").append(ai1[-1 + (s1.length() - l1)]).toString()); } ArrayList arraylist = new ArrayList(); for (int i2 = -1 + ai1.length; i2 >= 0; i2--) { int k2 = ai1[i2]; int l2; if (ai.length > i2) { l2 = ai[i2]; } else { l2 = 0; } if (k2 > l2) { for (int j3 = 0; j3 < 1 + (k2 - l2); j3++) { arraylist.add(a(s, s1, i2, l2 + j3)); } continue; } if (k2 < l2) { for (int i3 = 0; i3 < 1 + (l2 - k2); i3++) { arraylist.add(a(s, s1, i2, l2 - i3)); } } else { arraylist.add(a(s, s1, i2, l2)); } } Keyframe akeyframe[] = new Keyframe[1 + arraylist.size()]; Iterator iterator = arraylist.iterator(); int j2 = 0; while (iterator.hasNext()) { String s2 = (String)iterator.next(); j2++; akeyframe[j2] = Keyframe.ofObject((1.0F / (float)arraylist.size()) * (float)j2, s2); } akeyframe[0] = akeyframe[1]; ValueAnimator valueanimator = ValueAnimator.ofPropertyValuesHolder(new PropertyValuesHolder[] { PropertyValuesHolder.ofKeyframe("Text", akeyframe) }); valueanimator.setEvaluator(new i()); valueanimator.addUpdateListener(new j(textview)); valueanimator.setDuration(20L); return valueanimator; }
Example 13
Source File: ShadowView.java From ZDepthShadow with MIT License | 4 votes |
protected void changeZDepth(ZDepth zDepth) { int newAlphaTopShadow = zDepth.getAlphaTopShadow(); int newAlphaBottomShadow = zDepth.getAlphaBottomShadow(); float newOffsetYTopShadow = zDepth.getOffsetYTopShadowPx(getContext()); float newOffsetYBottomShadow = zDepth.getOffsetYBottomShadowPx(getContext()); float newBlurTopShadow = zDepth.getBlurTopShadowPx(getContext()); float newBlurBottomShadow = zDepth.getBlurBottomShadowPx(getContext()); if (!mZDepthDoAnimation) { mZDepthParam.mAlphaTopShadow = newAlphaTopShadow; mZDepthParam.mAlphaBottomShadow = newAlphaBottomShadow; mZDepthParam.mOffsetYTopShadowPx = newOffsetYTopShadow; mZDepthParam.mOffsetYBottomShadowPx = newOffsetYBottomShadow; mZDepthParam.mBlurTopShadowPx = newBlurTopShadow; mZDepthParam.mBlurBottomShadowPx = newBlurBottomShadow; mShadow.setParameter(mZDepthParam, mZDepthPaddingLeft, mZDepthPaddingTop, getWidth() - mZDepthPaddingRight, getHeight() - mZDepthPaddingBottom); invalidate(); return; } int nowAlphaTopShadow = mZDepthParam.mAlphaTopShadow; int nowAlphaBottomShadow = mZDepthParam.mAlphaBottomShadow; float nowOffsetYTopShadow = mZDepthParam.mOffsetYTopShadowPx; float nowOffsetYBottomShadow = mZDepthParam.mOffsetYBottomShadowPx; float nowBlurTopShadow = mZDepthParam.mBlurTopShadowPx; float nowBlurBottomShadow = mZDepthParam.mBlurBottomShadowPx; PropertyValuesHolder alphaTopShadowHolder = PropertyValuesHolder.ofInt(ANIM_PROPERTY_ALPHA_TOP_SHADOW, nowAlphaTopShadow, newAlphaTopShadow); PropertyValuesHolder alphaBottomShadowHolder = PropertyValuesHolder.ofInt(ANIM_PROPERTY_ALPHA_BOTTOM_SHADOW, nowAlphaBottomShadow, newAlphaBottomShadow); PropertyValuesHolder offsetTopShadowHolder = PropertyValuesHolder.ofFloat(ANIM_PROPERTY_OFFSET_TOP_SHADOW, nowOffsetYTopShadow, newOffsetYTopShadow); PropertyValuesHolder offsetBottomShadowHolder = PropertyValuesHolder.ofFloat(ANIM_PROPERTY_OFFSET_BOTTOM_SHADOW, nowOffsetYBottomShadow, newOffsetYBottomShadow); PropertyValuesHolder blurTopShadowHolder = PropertyValuesHolder.ofFloat(ANIM_PROPERTY_BLUR_TOP_SHADOW, nowBlurTopShadow, newBlurTopShadow); PropertyValuesHolder blurBottomShadowHolder = PropertyValuesHolder.ofFloat(ANIM_PROPERTY_BLUR_BOTTOM_SHADOW, nowBlurBottomShadow, newBlurBottomShadow); ValueAnimator anim = ValueAnimator .ofPropertyValuesHolder( alphaTopShadowHolder, alphaBottomShadowHolder, offsetTopShadowHolder, offsetBottomShadowHolder, blurTopShadowHolder, blurBottomShadowHolder); anim.setDuration(mZDepthAnimDuration); anim.setInterpolator(new LinearInterpolator()); anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int alphaTopShadow = (Integer) animation.getAnimatedValue(ANIM_PROPERTY_ALPHA_TOP_SHADOW); int alphaBottomShadow = (Integer) animation.getAnimatedValue(ANIM_PROPERTY_ALPHA_BOTTOM_SHADOW); float offsetTopShadow = (Float) animation.getAnimatedValue(ANIM_PROPERTY_OFFSET_TOP_SHADOW); float offsetBottomShadow = (Float) animation.getAnimatedValue(ANIM_PROPERTY_OFFSET_BOTTOM_SHADOW); float blurTopShadow = (Float) animation.getAnimatedValue(ANIM_PROPERTY_BLUR_TOP_SHADOW); float blurBottomShadow = (Float) animation.getAnimatedValue(ANIM_PROPERTY_BLUR_BOTTOM_SHADOW); mZDepthParam.mAlphaTopShadow = alphaTopShadow; mZDepthParam.mAlphaBottomShadow = alphaBottomShadow; mZDepthParam.mOffsetYTopShadowPx = offsetTopShadow; mZDepthParam.mOffsetYBottomShadowPx = offsetBottomShadow; mZDepthParam.mBlurTopShadowPx = blurTopShadow; mZDepthParam.mBlurBottomShadowPx = blurBottomShadow; mShadow.setParameter(mZDepthParam, mZDepthPaddingLeft, mZDepthPaddingTop, getWidth() - mZDepthPaddingRight, getHeight() - mZDepthPaddingBottom); invalidate(); } }); anim.start(); }