List of usage examples for android.animation ValueAnimator setInterpolator
@Override public void setInterpolator(TimeInterpolator value)
From source file:me.lizheng.deckview.views.DeckChildView.java
/** * Animates the deletion of this task view *//*w ww .j a va2s. c om*/ void startDeleteTaskAnimation(final Runnable r) { // Disabling clipping with the stack while the view is animating away setClipViewInStack(false); ValueAnimator anim = ObjectAnimator.ofFloat(this, View.TRANSLATION_X, getSize()); anim.setInterpolator(new LinearInterpolator()); anim.setDuration(100); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setClipViewInStack(true); setTouchEnabled(true); r.run(); } }); anim.start(); }
From source file:com.ruesga.rview.wizard.WizardActivity.java
private Animator createHeaderAnimation(int from, int to) { final ValueAnimator animator = ValueAnimator.ofInt(from, to); animator.setInterpolator(new AccelerateDecelerateInterpolator()); animator.setDuration(250L);//from ww w . j a v a 2s. c o m animator.addUpdateListener(animation -> { final View v = mBinding.pageHeader; v.getLayoutParams().height = (Integer) animation.getAnimatedValue(); v.requestLayout(); }); animator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animator) { mWorkflow.isBackEnabled = false; mWorkflow.isForwardEnabled = false; mBinding.setWorkflow(mWorkflow); mIsHeaderAnimatorRunning = true; } @Override public void onAnimationEnd(Animator animator) { if (mCurrentPageFragment != null) { onValidationChanged(mCurrentPageFragment); } mBinding.setWorkflow(mWorkflow); mIsHeaderAnimatorRunning = false; } @Override public void onAnimationCancel(Animator animator) { } @Override public void onAnimationRepeat(Animator animator) { } }); return animator; }
From source file:com.alimuzaffar.lib.pin.PinEntryEditText.java
private void animateBottomUp(CharSequence text, final int start) { mCharBottom[start] = mLineCoords[start].bottom - mTextBottomPadding; ValueAnimator animUp = ValueAnimator.ofFloat(mCharBottom[start] + getPaint().getTextSize(), mCharBottom[start]);//w w w . j a v a2s . co m animUp.setDuration(300); animUp.setInterpolator(new OvershootInterpolator()); animUp.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Float value = (Float) animation.getAnimatedValue(); mCharBottom[start] = value; PinEntryEditText.this.invalidate(); } }); mLastCharPaint.setAlpha(255); ValueAnimator animAlpha = ValueAnimator.ofInt(0, 255); animAlpha.setDuration(300); animAlpha.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Integer value = (Integer) animation.getAnimatedValue(); mLastCharPaint.setAlpha(value); } }); AnimatorSet set = new AnimatorSet(); if (text.length() == mMaxLength && mOnPinEnteredListener != null) { set.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mOnPinEnteredListener.onPinEntered(getText()); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); } set.playTogether(animUp, animAlpha); set.start(); }
From source file:android.support.graphics.drawable.AnimatorInflaterCompat.java
/** * Creates a new animation whose parameters come from the specified context * and attributes set./*from w ww.ja va2 s . com*/ * * @param res The resources * @param attrs The set of attributes holding the animation parameters * @param anim Null if this is a ValueAnimator, otherwise this is an */ private static ValueAnimator loadAnimator(Context context, Resources res, Theme theme, AttributeSet attrs, ValueAnimator anim, float pathErrorScale, XmlPullParser parser) throws NotFoundException { TypedArray arrayAnimator = TypedArrayUtils.obtainAttributes(res, theme, attrs, AndroidResources.STYLEABLE_ANIMATOR); TypedArray arrayObjectAnimator = TypedArrayUtils.obtainAttributes(res, theme, attrs, AndroidResources.STYLEABLE_PROPERTY_ANIMATOR); if (anim == null) { anim = new ValueAnimator(); } parseAnimatorFromTypeArray(anim, arrayAnimator, arrayObjectAnimator, pathErrorScale, parser); final int resID = TypedArrayUtils.getNamedResourceId(arrayAnimator, parser, "interpolator", AndroidResources.STYLEABLE_ANIMATOR_INTERPOLATOR, 0); if (resID > 0) { final Interpolator interpolator = AnimationUtilsCompat.loadInterpolator(context, resID); anim.setInterpolator(interpolator); } arrayAnimator.recycle(); if (arrayObjectAnimator != null) { arrayObjectAnimator.recycle(); } return anim; }
From source file:com.awt.supark.LayoutHandler.java
public void smallButtonPressed(final View view, final MainActivity act) { if (!act.pullUp && !act.pullUpStarted) { // If it isn't already up act.pullUpStarted = true;/* w ww . ja v a2s .c om*/ // Declaring animator ValueAnimator animation = ValueAnimator.ofFloat(1f, 0.17f); // ****** UI ELEMENTS FADING OUT ANIMATION ****** // Sets the animation properties animation.setDuration(act.layoutFadeOutDuration); animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (float) animation.getAnimatedValue(); // Fades out contentLinear and all buttons, except the one that is pressed act.contentLinear.setAlpha(value); if (view.getId() != R.id.buttonMap) { act.btnMap.setAlpha(value); } if (view.getId() != R.id.buttonCars) { act.btnCars.setAlpha(value); } if (view.getId() != R.id.buttonStatistics) { act.btnStatistics.setAlpha(value); } if (view.getId() != R.id.buttonEtc) { act.btnEtc.setAlpha(value); } } }); animation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { // Sets the visibility of the other layout and contentlinear act.contentLinear.setVisibility(View.GONE); act.otherContent.setVisibility(View.VISIBLE); // ****** BUTTON PULL UP ANIMATION ****** // Declaring animator ValueAnimator nextAnimation = ValueAnimator.ofFloat(1f, 0f); // Sets the animation properties nextAnimation.setDuration(act.layoutPullUpDuration); nextAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); nextAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (float) animation.getAnimatedValue(); // Sets weight of the two layouts, this makes one smaller and the other bigger act.tableRowTopHalf .setLayoutParams(new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, value)); act.otherContent.setLayoutParams( new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1 - value)); } }); // ****** LAYOUT PULL UP ANIMATION ****** nextAnimation.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { act.otherContentHandler(view); // Takes care of including new views act.otherContent.startAnimation(act.anim_slide_up_fade_in); // Animates the new activity act.pullUp = true; // Changing the pull up status indicator act.pullUpStarted = false; } @Override public void onAnimationCancel(Animator animation) { act.pullUpStarted = false; act.otherContent.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animator animation) { } }); nextAnimation.start(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); animation.start(); } else if (view.getId() == act.openedLayout) { act.pullDown(); // If there is a layout already pulled up we have to pull it down } else if (act.pullUp && (act.openedLayout != 0) && !act.pullUpStarted) { act.pullUpStarted = true; // To prevent more than one highlight // Changing highlight from previous to current button ValueAnimator animation = ValueAnimator.ofFloat(0.17f, 1f); animation.setDuration(act.smallButtonHighlightChangeDuration); animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float value = (float) animation.getAnimatedValue(); act.findViewById(view.getId()).setAlpha(value); act.findViewById(act.openedLayout).setAlpha(1.17f - value); } }); animation.start(); // Fades out current layout act.otherContent.startAnimation(act.anim_fade_out); act.anim_fade_out.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { act.otherContentHandler(view); // Switches the layout to the new one act.otherContent.startAnimation(act.anim_slide_up_fade_in); // Fades in the new layout act.pullUpStarted = false; } @Override public void onAnimationRepeat(Animation animation) { } }); } }
From source file:com.android.deskclock.alarms.AlarmActivity.java
private ValueAnimator getAlarmBounceAnimator(float translationX, final int hintResId) { final ValueAnimator bounceAnimator = ObjectAnimator.ofFloat(mAlarmButton, View.TRANSLATION_X, mAlarmButton.getTranslationX(), translationX, 0.0f); bounceAnimator.setInterpolator(AnimatorUtils.DECELERATE_ACCELERATE_INTERPOLATOR); bounceAnimator.setDuration(ALARM_BOUNCE_DURATION_MILLIS); bounceAnimator.addListener(new AnimatorListenerAdapter() { @Override//from ww w . j av a 2 s . com public void onAnimationStart(Animator animator) { mHintView.setText(hintResId); if (mHintView.getVisibility() != View.VISIBLE) { mHintView.setVisibility(View.VISIBLE); ObjectAnimator.ofFloat(mHintView, View.ALPHA, 0.0f, 1.0f).start(); } } }); return bounceAnimator; }
From source file:fr.julienvermet.bugdroid.ui.tablet.AbsBugsMultiPaneFragment.java
public void expandLeftPane(int speed) { int targetWidth = mMaxLeftWidth; ValueAnimator animator = ValueAnimator.ofObject(new WidthEvaluator(mLeftPane), mLeftPane.getWidth(), targetWidth);/*from w w w . j a v a2s .co m*/ animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mIsLeftCollapsed = false; } }); animator.setInterpolator(new DecelerateInterpolator()); animator.setDuration(speed); animator.start(); }
From source file:com.brayanarias.alarmproject.activity.AlarmScreenActivity.java
private void starAnimation() { View pulseView = findViewById(R.id.pulse); View pulseDismiss = findViewById(R.id.pulseDismiss); View pulseSnooze = findViewById(R.id.pulseSnooze); ValueAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseView, PropertyValuesHolder.ofFloat(View.SCALE_X, 0.0f, 1.0f), PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.0f, 1.0f), PropertyValuesHolder.ofFloat(View.ALPHA, 1.0f, 0.0f)); pulseAnimator.setDuration(2000);//w w w . j a v a2 s .c o m pulseAnimator.setRepeatCount(ValueAnimator.INFINITE); Interpolator interpolator = PathInterpolatorCompat.create(0.0f, 0.0f, 0.2f, 1.0f); pulseAnimator.setInterpolator(interpolator); pulseAnimator.start(); ValueAnimator dismissAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseDismiss, PropertyValuesHolder.ofFloat(View.SCALE_X, 0.0f, 1.0f), PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.0f, 1.0f), PropertyValuesHolder.ofFloat(View.ALPHA, 1.0f, 0.0f)); dismissAnimator.setDuration(1000); dismissAnimator.setRepeatCount(ValueAnimator.INFINITE); dismissAnimator.setInterpolator(interpolator); dismissAnimator.start(); ValueAnimator snoozeAnimator = ObjectAnimator.ofPropertyValuesHolder(pulseSnooze, PropertyValuesHolder.ofFloat(View.SCALE_X, 0.0f, 1.0f), PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.0f, 1.0f), PropertyValuesHolder.ofFloat(View.ALPHA, 1.0f, 0.0f)); snoozeAnimator.setDuration(1000); snoozeAnimator.setRepeatCount(ValueAnimator.INFINITE); snoozeAnimator.setInterpolator(interpolator); snoozeAnimator.start(); }
From source file:chinanurse.cn.nurse.list.WaveSwipeRefreshLayout.java
private void onDropPhase() { mWaveView.animationDropCircle();/*from w w w. j a va 2 s. co m*/ ValueAnimator animator = ValueAnimator.ofFloat(0, 0); animator.setDuration(500); animator.setInterpolator(new AccelerateDecelerateInterpolator()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { mCircleView.setTranslationY(mWaveView.getCurrentCircleCenterY() + mCircleView.getHeight() / 2.f); } }); animator.start(); setRefreshing(true, true); mIsBeingDropped = true; setEventPhase(EVENT_PHASE.DROPPING); setEnabled(false); }
From source file:com.shalzz.attendance.activity.MainActivity.java
public void setDrawerAsUp(boolean enabled) { if (mDrawerLayout == null) return;//from w w w . j a va 2 s . c o m float start = enabled ? 0f : 1f; float end = enabled ? 1f : 0f; mDrawerLayout.setDrawerLockMode( enabled ? DrawerLayout.LOCK_MODE_LOCKED_CLOSED : DrawerLayout.LOCK_MODE_UNLOCKED); ValueAnimator anim = ValueAnimator.ofFloat(start, end); anim.addUpdateListener(valueAnimator -> { float slideOffset = (Float) valueAnimator.getAnimatedValue(); mDrawerToggle.onDrawerSlide(mDrawerLayout, slideOffset); }); anim.setInterpolator(new DecelerateInterpolator()); anim.setDuration(300); anim.start(); }