List of usage examples for android.animation ValueAnimator getAnimatedValue
public Object getAnimatedValue()
ValueAnimator
when there is just one property being animated. From source file:com.telenav.nodeflow.NodeFlowLayout.java
/** * perform alpha animation associated with closing or opening a node * * @param startIndex start index of child views to be animated * @param endIndex end index of child views to be animated * @param destAlpha final alpha of child views to be animated */// w w w .ja v a2 s .co m private void animateDrillAlpha(final int startIndex, final int endIndex, final int destAlpha) { ValueAnimator animator = ValueAnimator.ofFloat(1 - destAlpha, destAlpha); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { for (int i = startIndex; i < endIndex; ++i) { getChildAt(i).setAlpha(((Float) animation.getAnimatedValue())); } } }); animator.addListener(new CustomAnimationListener() { @Override public void onAnimationStart(Animator animator) { for (int i = startIndex; i < getChildCount(); ++i) { getChildAt(i).setAlpha(1 - destAlpha); } } }); animator.setDuration(duration); if (destAlpha == 1) animator.setInterpolator(new AccelerateInterpolator()); else animator.setInterpolator(new DecelerateInterpolator(2)); animator.start(); }
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]);/*from ww w .j ava2s .c om*/ 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:com.example.waitou.rxjava.LoadingView.java
/** * build FlexibleAnimation to control the progress * * @return Animatorset for control the progress *///w w w. jav a 2s . c o m private AnimatorSet buildFlexibleAnimation() { final Ring ring = mRing; AnimatorSet set = new AnimatorSet(); ValueAnimator increment = ValueAnimator.ofFloat(0, MAX_PROGRESS_ARC - MIN_PROGRESS_ARC) .setDuration(ANIMATOR_DURATION / 2); increment.setInterpolator(new LinearInterpolator()); increment.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float sweeping = ring.sweeping; final float value = (float) animation.getAnimatedValue(); ring.sweep = sweeping + value; invalidate(); } }); increment.addListener(animatorListener); ValueAnimator reduce = ValueAnimator.ofFloat(0, MAX_PROGRESS_ARC - MIN_PROGRESS_ARC) .setDuration(ANIMATOR_DURATION / 2); reduce.setInterpolator(interpolator); reduce.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float sweeping = ring.sweeping; float starting = ring.starting; float value = (float) animation.getAnimatedValue(); ring.sweep = sweeping - value; ring.start = starting + value; } }); set.play(reduce).after(increment); return set; }
From source file:com.nshmura.recyclertablayout.RecyclerTabLayout.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) protected void startAnimation(final int position) { float distance = 1; View view = mLinearLayoutManager.findViewByPosition(position); if (view != null) { float currentX = view.getX() + view.getMeasuredWidth() / 2.f; float centerX = getMeasuredWidth() / 2.f; distance = Math.abs(centerX - currentX) / view.getMeasuredWidth(); }//www .j a va 2 s . c om ValueAnimator animator; if (position < mIndicatorPosition) { animator = ValueAnimator.ofFloat(distance, 0); } else { animator = ValueAnimator.ofFloat(-distance, 0); } animator.setDuration(DEFAULT_SCROLL_DURATION); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { scrollToTab(position, (float) animation.getAnimatedValue(), true); } }); animator.start(); }
From source file:com.geecko.QuickLyric.adapter.IntroScreenSlidePagerAdapter.java
public IntroScreenSlidePagerAdapter(FragmentManager fm, final Activity activity) { super(fm);//from w w w .j ava 2 s. c o m this.mActivity = activity; mPager = ((ViewPager) mActivity.findViewById(R.id.pager)); mPager.setOnTouchListener(exitTouchListener); if (Build.VERSION.SDK_INT >= 17) rightToLeft = TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == 1; if (rightToLeft) { List<Integer> list = Arrays.asList(colors); Collections.reverse(list); colors = (Integer[]) list.toArray(); } ImageButton pagerArrow = ((ImageButton) mActivity.findViewById(R.id.pager_arrow)); Button okButton = ((Button) mActivity.findViewById(R.id.pager_ok)); okButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && !Tutorial_5.nlEnabled) { final ViewGroup nlFrame = (ViewGroup) activity.findViewById(R.id.NL_frame); final ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), Color.parseColor("#30000000"), Color.parseColor("#80FFFFFF")); colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { nlFrame.setBackgroundColor((int) animation.getAnimatedValue()); } }); colorAnimation.setInterpolator(new LinearOutSlowInInterpolator()); colorAnimation.setRepeatCount(3); colorAnimation.setRepeatMode(ValueAnimator.REVERSE); colorAnimation.setDuration(650L); colorAnimation.start(); } else if (!hasClicked) { exitAction(); hasClicked = true; } } }); pagerArrow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { nextAction(); } }); }
From source file:com.viewpagerindicator.TabMovablePageIndicator.java
private void animateScrollWithIndicator(TabView tabView) { int scrollPos = tabView.getLeft() - (getWidth() - tabView.getWidth()) / 2; AnimatorSet as = new AnimatorSet(); as.setDuration(300);//w ww .ja v a 2 s . co m ArrayList<Animator> animations = new ArrayList<Animator>(); // scroll ObjectAnimator animScrollX = ObjectAnimator.ofInt(TabMovablePageIndicator.this, "scrollX", scrollPos); animScrollX.setInterpolator(new AccelerateDecelerateInterpolator()); animations.add(animScrollX); // indicator position int left = tabView.getLeft(); // int width = tabView.getWidth(); int textWidth = tabView.wordWidth; // int x = left + (width - textWidth) / 2 - mExtendWidth * 2; // x = x < 0 ? 0 : x; ObjectAnimator translateXAnim = ObjectAnimator.ofFloat(mIndicator, "translationX", left); translateXAnim.setInterpolator(new OvershootInterpolator(0.8f)); animations.add(translateXAnim); // indicator width ValueAnimator animWidth = ValueAnimator.ofInt(mIndicator.getLayoutParams().width, textWidth + mExtendWidth * 2); animWidth.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mIndicator.getLayoutParams(); lp.width = (Integer) animation.getAnimatedValue(); mIndicator.setLayoutParams(lp); requestLayout(); } }); animations.add(animWidth); as.playTogether(animations); as.start(); }
From source file:com.lixplor.rocketpulltorefresh.RefreshLayout.java
/** * Perform header view shrink back animation * @param from animation start Y px/* www. jav a2 s . c o m*/ * @param to animation stop Y px */ private void animHeader(int from, final int to) { if (mHeaderBackAnimator == null) { mHeaderBackAnimator = new ValueAnimator(); mHeaderBackAnimator.setDuration(mBackAnimDuration); mHeaderBackAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int destY = (int) animation.getAnimatedValue(); scrollTo(0, destY); if (destY == 0) { // when back finished, reset header mCurrentState = STATE_PULL_DOWN_TO_REFRESH; mAbsHeader.reset(); } } }); mHeaderBackAnimator.setTarget(this); } mHeaderBackAnimator.setIntValues(from, to); mHeaderBackAnimator.start(); }
From source file:com.lixplor.rocketpulltorefresh.RefreshLayout.java
/** * Perform footer view shrink back animation * @param from animation start Y px// w w w . j av a 2 s.c o m * @param to animation stop Y px */ private void animFooter(int from, int to) { if (mFooterBackAnimator == null) { mFooterBackAnimator = new ValueAnimator(); mFooterBackAnimator.setDuration(mBackAnimDuration); mFooterBackAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int destY = (int) animation.getAnimatedValue(); scrollTo(0, destY); if (destY == 0) { // when back finished, reset footer mCurrentState = STATE_PULL_UP_TO_LOAD; mAbsFooter.reset(); } } }); mFooterBackAnimator.setTarget(this); } mFooterBackAnimator.setIntValues(from, to); mFooterBackAnimator.start(); }
From source file:com.tomeokin.widget.jotablayout2.JoTabLayout.java
@Override public void onAnimationUpdate(ValueAnimator animation) { View currentTabView = getChildAt(mCurrentTab); IndicatorPoint p = (IndicatorPoint) animation.getAnimatedValue(); mIndicatorAnimOffset = (int) p.left - currentTabView.getLeft(); invalidate();// w w w .j a v a 2s. c om }
From source file:ch.gianulli.flashcards.ui.Flashcard.java
private void expandButtonBar() { mButtonBarShowing = true;// w w w . j a v a 2 s.c o m mButtonBar.setVisibility(View.VISIBLE); mButtonBar.setAlpha(0.0f); final int startingHeight = mCardView.getHeight(); final ViewTreeObserver observer = mCardView.getViewTreeObserver(); observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { // We don't want to continue getting called for every listview drawing. if (observer.isAlive()) { observer.removeOnPreDrawListener(this); } final int endingHeight = mCardView.getHeight(); final int distance = endingHeight - startingHeight; mCardView.getLayoutParams().height = startingHeight; mCardView.requestLayout(); ValueAnimator heightAnimator = ValueAnimator.ofFloat(0f, 1f).setDuration(300); heightAnimator.setInterpolator(new DecelerateInterpolator()); heightAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { Float value = (Float) animator.getAnimatedValue(); mCardView.getLayoutParams().height = (int) (value * distance + startingHeight); mCardView.requestLayout(); } }); heightAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCardView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT; } }); mButtonBar.setLayerType(View.LAYER_TYPE_HARDWARE, null); ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(mButtonBar, "alpha", 0.0f, 1.0f); alphaAnimator.setInterpolator(new DecelerateInterpolator()); alphaAnimator.setDuration(300); alphaAnimator.setStartDelay(100); AnimatorSet set = new AnimatorSet(); set.playTogether(heightAnimator, alphaAnimator); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mButtonBar.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } }); set.start(); return false; } }); }