Java Code Examples for com.nineoldandroids.animation.ValueAnimator#ofFloat()
The following examples show how to use
com.nineoldandroids.animation.ValueAnimator#ofFloat() .
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: BallPulseIndicator.java From AndroidPlayground with MIT License | 6 votes |
@Override public List<Animator> createAnimation() { List<Animator> animators = new ArrayList<>(); for (int i = 0; i < CIRCLE_NUM; i++) { final int index = i; ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.3f, 1); scaleAnim.setDuration(BASE_DELAY_MILLIS * CIRCLE_NUM * 3 / 2); scaleAnim.setRepeatCount(-1); scaleAnim.setStartDelay(delays[i]); scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { scaleFloats[index] = (float) animation.getAnimatedValue(); postInvalidate(); } }); scaleAnim.start(); animators.add(scaleAnim); } return animators; }
Example 2
Source File: ViewPropertyAnimatorPreHC.java From Mover with Apache License 2.0 | 6 votes |
/** * Starts the underlying Animator for a set of properties. We use a single animator that * simply runs from 0 to 1, and then use that fractional value to set each property * value accordingly. */ private void startAnimation() { ValueAnimator animator = ValueAnimator.ofFloat(1.0f); ArrayList<NameValuesHolder> nameValueList = (ArrayList<NameValuesHolder>) mPendingAnimations.clone(); mPendingAnimations.clear(); int propertyMask = 0; int propertyCount = nameValueList.size(); for (int i = 0; i < propertyCount; ++i) { NameValuesHolder nameValuesHolder = nameValueList.get(i); propertyMask |= nameValuesHolder.mNameConstant; } mAnimatorMap.put(animator, new PropertyBundle(propertyMask, nameValueList)); animator.addUpdateListener(mAnimatorEventListener); animator.addListener(mAnimatorEventListener); if (mStartDelaySet) { animator.setStartDelay(mStartDelay); } if (mDurationSet) { animator.setDuration(mDuration); } if (mInterpolatorSet) { animator.setInterpolator(mInterpolator); } animator.start(); }
Example 3
Source File: ViewPropertyAnimatorHC.java From Mover with Apache License 2.0 | 6 votes |
/** * Starts the underlying Animator for a set of properties. We use a single animator that * simply runs from 0 to 1, and then use that fractional value to set each property * value accordingly. */ private void startAnimation() { ValueAnimator animator = ValueAnimator.ofFloat(1.0f); ArrayList<NameValuesHolder> nameValueList = (ArrayList<NameValuesHolder>) mPendingAnimations.clone(); mPendingAnimations.clear(); int propertyMask = 0; int propertyCount = nameValueList.size(); for (int i = 0; i < propertyCount; ++i) { NameValuesHolder nameValuesHolder = nameValueList.get(i); propertyMask |= nameValuesHolder.mNameConstant; } mAnimatorMap.put(animator, new PropertyBundle(propertyMask, nameValueList)); animator.addUpdateListener(mAnimatorEventListener); animator.addListener(mAnimatorEventListener); if (mStartDelaySet) { animator.setStartDelay(mStartDelay); } if (mDurationSet) { animator.setDuration(mDuration); } if (mInterpolatorSet) { animator.setInterpolator(mInterpolator); } animator.start(); }
Example 4
Source File: FancyProgress2.java From FancyProgress with Apache License 2.0 | 6 votes |
public FancyProgress2 show(){ setVisibility(View.VISIBLE); mAnim = ValueAnimator.ofFloat(1.0f); mAnim.setInterpolator(new LinearInterpolator()); mAnim.setDuration(2000); mAnim.setRepeatCount(ValueAnimator.INFINITE); mAnim.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mPercent = animation.getAnimatedFraction(); isFront = mPercent < 0.5f; invalidate(); } }); mAnim.start(); invalidate(); return this; }
Example 5
Source File: PullToNextView.java From Android-PullToNextLayout with Apache License 2.0 | 6 votes |
public void moveTo(final float i, int duration) { int topMargin = getHeaderTopMargin(); ValueAnimator animator = ValueAnimator.ofFloat(topMargin, i); animator.setDuration(duration); animator.setInterpolator(new DecelerateInterpolator()); mPullStateE = PullStateE.PULL_STATE_NONE; animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @TargetApi(Build.VERSION_CODES.HONEYCOMB) public void onAnimationUpdate(ValueAnimator valueAnimator) { float temp = (Float) valueAnimator.getAnimatedValue(); if (temp == i) { mPullStateE = PullStateE.PULL_STATE_NONE; } setHeaderTopMargin((int) temp); } }); animator.start(); }
Example 6
Source File: ChartSeries.java From android-DecoView-charting with Apache License 2.0 | 5 votes |
/** * Kick off an animation to hide or show the arc. This results in an animation where * both the width of the line used for the arc and the transparency of the arc is * altered over the duration provided * * @param event Event to process * @param showArc True to show the arc, false to hide */ public void startAnimateHideShow(@NonNull final DecoEvent event, final boolean showArc) { cancelAnimation(); event.notifyStartListener(); mDrawMode = event.getEventType(); mPercentComplete = showArc ? 1.0f : 0f; mVisible = true; final float maxValue = 1.0f; mValueAnimator = ValueAnimator.ofFloat(0, maxValue); mValueAnimator.setDuration(event.getEffectDuration()); mValueAnimator.setInterpolator(new LinearInterpolator()); mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float current = Float.valueOf(valueAnimator.getAnimatedValue().toString()); mPercentComplete = showArc ? (maxValue - current) : current; for (SeriesItem.SeriesItemListener seriesItemListener : mSeriesItem.getListeners()) { seriesItemListener.onSeriesItemDisplayProgress(mPercentComplete); } } }); mValueAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (event.getEventType() != DecoEvent.EventType.EVENT_EFFECT) { event.notifyEndListener(); } } }); mValueAnimator.start(); }
Example 7
Source File: FancyProgress4.java From FancyProgress with Apache License 2.0 | 5 votes |
public void show(){ mAnim = ValueAnimator.ofFloat(1.0f); mAnim.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mPercent = animation.getAnimatedFraction(); invalidate(); } }); mAnim.setInterpolator(new LinearInterpolator()); mAnim.setRepeatCount(ValueAnimator.INFINITE); mAnim.setDuration(mOneShotDuration * 4); mAnim.start(); }
Example 8
Source File: b.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
private void a() { ValueAnimator valueanimator = ValueAnimator.ofFloat(new float[] { 1.0F }); ArrayList arraylist = (ArrayList)a.clone(); a.clear(); int i1 = arraylist.size(); int j1 = 0; int k1 = 0; do { if (j1 >= i1) { x.put(valueanimator, new f(k1, arraylist)); valueanimator.addUpdateListener(j); valueanimator.addListener(j); if (f) { valueanimator.setStartDelay(e); } if (d) { valueanimator.setDuration(c); } if (h) { valueanimator.setInterpolator(g); } valueanimator.start(); return; } k1 |= ((e)arraylist.get(j1)).a; j1++; } while (true); }
Example 9
Source File: i.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
private void a() { ValueAnimator valueanimator = ValueAnimator.ofFloat(new float[] { 1.0F }); ArrayList arraylist = (ArrayList)a.clone(); a.clear(); int i1 = arraylist.size(); int j1 = 0; int k1 = 0; do { if (j1 >= i1) { y.put(valueanimator, new m(k1, arraylist)); valueanimator.addUpdateListener(k); valueanimator.addListener(k); if (g) { valueanimator.setStartDelay(f); } if (e) { valueanimator.setDuration(d); } if (i) { valueanimator.setInterpolator(h); } valueanimator.start(); return; } k1 |= ((l)arraylist.get(j1)).a; j1++; } while (true); }
Example 10
Source File: CameraXVideoCaptureHelper.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private void shrinkCaptureArea() { Size screenSize = getScreenSize(); Size videoRecordingSize = VideoUtil.getVideoRecordingSize(); float scale = getSurfaceScaleForRecording(); float targetWidthForAnimation = videoRecordingSize.getWidth() * scale; float scaleX = targetWidthForAnimation / screenSize.getWidth(); if (scaleX == 1f) { float targetHeightForAnimation = videoRecordingSize.getHeight() * scale; if (screenSize.getHeight() == targetHeightForAnimation) { return; } cameraMetricsAnimator = ValueAnimator.ofFloat(screenSize.getHeight(), targetHeightForAnimation); } else { if (screenSize.getWidth() == targetWidthForAnimation) { return; } cameraMetricsAnimator = ValueAnimator.ofFloat(screenSize.getWidth(), targetWidthForAnimation); } ViewGroup.LayoutParams params = camera.getLayoutParams(); cameraMetricsAnimator.setInterpolator(new LinearInterpolator()); cameraMetricsAnimator.setDuration(200); cameraMetricsAnimator.addUpdateListener(animation -> { if (scaleX == 1f) { params.height = Math.round((float) animation.getAnimatedValue()); } else { params.width = Math.round((float) animation.getAnimatedValue()); } camera.setLayoutParams(params); }); cameraMetricsAnimator.start(); }
Example 11
Source File: DeleteAnimation.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
public DeleteAnimation(SwipeToDeleteListView listView, ItemState itemState, long duration) { this.listView = listView; this.itemState = itemState; float dragPercentage = itemState.getDragPercentage(); float end = dragPercentage > 0 ? 1f : -1f; animator = ValueAnimator.ofFloat(dragPercentage, end); animator.setDuration(duration); animator.addUpdateListener(this); animator.addListener(this); }
Example 12
Source File: BackAnimation.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
public BackAnimation(SwipeToDeleteListView listView, ItemState itemState, long duration) { this.listView = listView; this.itemState = itemState; float dragPercentage = itemState.getDragPercentage(); animator = ValueAnimator.ofFloat(dragPercentage, 0); animator.setDuration(duration); animator.addUpdateListener(this); animator.addListener(this); }
Example 13
Source File: DeletionConfirmedAnimation.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
public DeletionConfirmedAnimation(SwipeToDeleteListView listView, ItemState itemState, long duration) { this.listView = listView; this.itemState = itemState; animator = ValueAnimator.ofFloat(1f, 0f); animator.setDuration(duration); animator.addUpdateListener(this); animator.addListener(this); }
Example 14
Source File: ToggleButton.java From DMusic with Apache License 2.0 | 5 votes |
private void init(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { setLayerType(LAYER_TYPE_SOFTWARE, null); // Disable hardware acceleration } mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mRect = new Rect(); mRectF = new RectF(); mPaintThumb = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintThumb.setColor(mColorThumb); mPaintTrack = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintTrack.setColor(mColorTrackOff); mPaintPadding = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintPadding.setColor(mColorPadding); mPaintShader = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintShader.setColor(mColorThumb); mPaintShader.setShadowLayer(mPadding * 2, 0, 0, mColorPadding); mAnimation = ValueAnimator.ofFloat(0f, 1f); mAnimation.setDuration(mDuration); mAnimation.setInterpolator(new LinearInterpolator()); mAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mFactor = (float) animation.getAnimatedValue(); // 更新进度因子 invalidate(); } }); }
Example 15
Source File: HistoryChartView.java From YiZhi with Apache License 2.0 | 5 votes |
/** * 开启动画 */ private void startAnimation() { if (mValueAnimator != null) { mValueAnimator.cancel(); } final float targetTempLength = mTargetTempPathMeasure.getLength(); final float roomTempLength = mRoomTempPathMeasure.getLength(); mValueAnimator = ValueAnimator.ofFloat(1, 0); mValueAnimator.setDuration(ANIM_DURATION); // 减速插值器 mValueAnimator.setInterpolator(new DecelerateInterpolator()); mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float fraction = (Float) animation.getAnimatedValue(); // 更新mtargetTempEffect mtargetTempEffect = new DashPathEffect(new float[]{ targetTempLength, targetTempLength}, fraction * targetTempLength); targetTempPaint.setPathEffect(mtargetTempEffect); // 更新mRoomTempEffect mRoomTempEffect = new DashPathEffect(new float[]{ roomTempLength, roomTempLength}, fraction * roomTempLength); roomTempPaint.setPathEffect(mRoomTempEffect); // 更新rect绘制fraction进度 mRectFration = 1 - fraction;// fraction是1->0 我们需要的柱形图绘制比例是0->1 postInvalidate(); } }); mValueAnimator.start(); }
Example 16
Source File: ToggleButton.java From Common with Apache License 2.0 | 5 votes |
private void init(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { setLayerType(LAYER_TYPE_SOFTWARE, null); // Disable hardware acceleration } mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mRect = new Rect(); mRectF = new RectF(); mPaintThumb = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintThumb.setColor(mColorThumb); mPaintTrack = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintTrack.setColor(mColorTrackOff); mPaintPadding = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintPadding.setColor(mColorPadding); mPaintShader = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintShader.setColor(mColorThumb); mPaintShader.setShadowLayer(mPadding * 2, 0, 0, mColorPadding); mAnimation = ValueAnimator.ofFloat(0f, 1f); mAnimation.setDuration(mDuration); mAnimation.setInterpolator(new LinearInterpolator()); mAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mFactor = (float) animation.getAnimatedValue(); // 更新进度因子 invalidate(); } }); }
Example 17
Source File: ChartSeries.java From android-DecoView-charting with Apache License 2.0 | 4 votes |
/** * Animate change of color * * @param event Event to process */ public void startAnimateColorChange(@NonNull final DecoEvent event) { cancelAnimation(); event.notifyStartListener(); mVisible = true; mDrawMode = event.getEventType(); mPercentComplete = 0f; final boolean changeColors = event.isColorSet(); if (changeColors) { mColorAnimate = new ColorAnimate(mSeriesItem.getColor(), event.getColor()); mSeriesItem.setColor(event.getColor()); } else { Log.w(TAG, "Must set new color to start CHANGE_COLOR event"); return; } final float maxValue = 1.0f; mValueAnimator = ValueAnimator.ofFloat(0, maxValue); mValueAnimator.setDuration(event.getEffectDuration()); if (event.getInterpolator() != null) { mValueAnimator.setInterpolator(event.getInterpolator()); } else { mValueAnimator.setInterpolator(new LinearInterpolator()); } mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { mPercentComplete = Float.valueOf(valueAnimator.getAnimatedValue().toString()); for (SeriesItem.SeriesItemListener seriesItemListener : mSeriesItem.getListeners()) { seriesItemListener.onSeriesItemDisplayProgress(mPercentComplete); } } }); mValueAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { event.notifyEndListener(); } }); mValueAnimator.start(); }
Example 18
Source File: ChartSeries.java From android-DecoView-charting with Apache License 2.0 | 4 votes |
/** * Execute an Animation effect by starting the Value Animator * * @param event Event to process effect * @throws IllegalStateException No effect set in event */ public void startAnimateEffect(@NonNull final DecoEvent event) throws IllegalStateException { if (event.getEffectType() == null) { throw new IllegalStateException("Unable to execute null effect type"); } // All effects run from 0.0 .. 1.0f in duration final float maxValue = 1.0f; cancelAnimation(); event.notifyStartListener(); mVisible = true; mDrawMode = event.getEventType(); mEffect = new DecoDrawEffect(event.getEffectType(), mPaint, event.getDisplayText()); mEffect.setRotationCount(event.getEffectRotations()); mPercentComplete = 0f; mValueAnimator = ValueAnimator.ofFloat(0, maxValue); mValueAnimator.setDuration(event.getEffectDuration()); Interpolator interpolator = (event.getInterpolator() != null) ? event.getInterpolator() : new LinearInterpolator(); mValueAnimator.setInterpolator(interpolator); mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { mPercentComplete = Float.valueOf(valueAnimator.getAnimatedValue().toString()); for (SeriesItem.SeriesItemListener seriesItemListener : mSeriesItem.getListeners()) { seriesItemListener.onSeriesItemDisplayProgress(mPercentComplete); } } }); mValueAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { event.notifyEndListener(); mDrawMode = DecoEvent.EventType.EVENT_MOVE; mVisible = mEffect.postExecuteVisibility(); mEffect = null; } }); mValueAnimator.start(); }
Example 19
Source File: AnimatedZoomableControllerSupport.java From CommentGallery with Apache License 2.0 | 4 votes |
public AnimatedZoomableControllerSupport(TransformGestureDetector transformGestureDetector) { super(transformGestureDetector); mValueAnimator = ValueAnimator.ofFloat(0, 1); mValueAnimator.setInterpolator(new DecelerateInterpolator()); }