Search in sources :

Example 56 with ValueAnimator

use of com.nineoldandroids.animation.ValueAnimator in project fresco by facebook.

the class AnimatedDrawableSupportTest method testValueAnimator.

@Test
public void testValueAnimator() {
    ValueAnimator valueAnimator = mDrawable.createValueAnimator();
    assertEquals(mBackend.getDurationMs(), valueAnimator.getDuration());
    assertEquals(ValueAnimator.INFINITE, valueAnimator.getRepeatCount());
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Test(org.junit.Test)

Example 57 with ValueAnimator

use of com.nineoldandroids.animation.ValueAnimator in project Android-ObservableScrollView by ksoichiro.

the class ToolbarControlBaseActivity method moveToolbar.

private void moveToolbar(float toTranslationY) {
    if (ViewHelper.getTranslationY(mToolbar) == toTranslationY) {
        return;
    }
    ValueAnimator animator = ValueAnimator.ofFloat(ViewHelper.getTranslationY(mToolbar), toTranslationY).setDuration(200);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float translationY = (float) animation.getAnimatedValue();
            ViewHelper.setTranslationY(mToolbar, translationY);
            ViewHelper.setTranslationY((View) mScrollable, translationY);
            FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) ((View) mScrollable).getLayoutParams();
            lp.height = (int) -translationY + getScreenHeight() - lp.topMargin;
            ((View) mScrollable).requestLayout();
        }
    });
    animator.start();
}
Also used : FrameLayout(android.widget.FrameLayout) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) View(android.view.View)

Example 58 with ValueAnimator

use of com.nineoldandroids.animation.ValueAnimator in project Android-ObservableScrollView by ksoichiro.

the class FillGap3BaseActivity method changeHeaderBackgroundHeightAnimated.

private void changeHeaderBackgroundHeightAnimated(boolean shouldShowGap, boolean animated) {
    if (mGapIsChanging) {
        return;
    }
    final int heightOnGapShown = mHeaderBar.getHeight();
    final int heightOnGapHidden = mHeaderBar.getHeight() + mActionBarSize;
    final float from = mHeaderBackground.getLayoutParams().height;
    final float to;
    if (shouldShowGap) {
        if (!mGapHidden) {
            // Already shown
            return;
        }
        to = heightOnGapShown;
    } else {
        if (mGapHidden) {
            // Already hidden
            return;
        }
        to = heightOnGapHidden;
    }
    if (animated) {
        ViewPropertyAnimator.animate(mHeaderBackground).cancel();
        ValueAnimator a = ValueAnimator.ofFloat(from, to);
        a.setDuration(100);
        a.setInterpolator(new AccelerateDecelerateInterpolator());
        a.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float height = (float) animation.getAnimatedValue();
                changeHeaderBackgroundHeight(height, to, heightOnGapHidden);
            }
        });
        a.start();
    } else {
        changeHeaderBackgroundHeight(to, to, heightOnGapHidden);
    }
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 59 with ValueAnimator

use of com.nineoldandroids.animation.ValueAnimator in project loadtoast by code-mc.

the class LoadToastView method done.

private void done() {
    cmp = ValueAnimator.ofFloat(0, 1);
    cmp.setDuration(600);
    cmp.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            WIDTH_SCALE = 2f * (valueAnimator.getAnimatedFraction());
            //Log.d("lt", "ws " + WIDTH_SCALE);
            postInvalidate();
        }
    });
    cmp.setInterpolator(new DecelerateInterpolator());
    cmp.start();
}
Also used : AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator)

Example 60 with ValueAnimator

use of com.nineoldandroids.animation.ValueAnimator in project UltimateAndroid by cymcsg.

the class DynamicListView method touchEventsEnded.

/**
     * Resets all the appropriate fields to a default state while also animating
     * the hover cell back to its correct location.
     */
private void touchEventsEnded() {
    final View mobileView = getViewForId(mMobileItemId);
    if (mCellIsMobile || mIsWaitingForScrollFinish) {
        mCellIsMobile = false;
        mIsWaitingForScrollFinish = false;
        mIsMobileScrolling = false;
        mActivePointerId = INVALID_POINTER_ID;
        /* Restore the transcript mode */
        setTranscriptMode(mOriginalTranscriptMode);
        // should be animated to.
        if (mScrollState != OnScrollListener.SCROLL_STATE_IDLE) {
            mIsWaitingForScrollFinish = true;
            return;
        }
        mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left, mobileView.getTop());
        ObjectAnimator hoverViewAnimator = ObjectAnimator.ofObject(mHoverCell, "bounds", sBoundEvaluator, mHoverCellCurrentBounds);
        hoverViewAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                invalidate();
            }
        });
        hoverViewAnimator.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationStart(Animator animation) {
                setEnabled(false);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mAboveItemId = INVALID_ID;
                mMobileItemId = INVALID_ID;
                mBelowItemId = INVALID_ID;
                mobileView.setVisibility(VISIBLE);
                mHoverCell = null;
                setEnabled(true);
                invalidate();
                if (mOnItemMovedListener != null) {
                    mOnItemMovedListener.onItemMoved(mLastMovedToIndex - getHeaderViewsCount());
                }
            }
        });
        hoverViewAnimator.start();
    } else {
        touchEventsCancelled();
    }
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView)

Aggregations

ValueAnimator (com.nineoldandroids.animation.ValueAnimator)105 Animator (com.nineoldandroids.animation.Animator)55 AnimatorListenerAdapter (com.nineoldandroids.animation.AnimatorListenerAdapter)46 StateAnimator (carbon.animation.StateAnimator)30 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)19 View (android.view.View)17 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)15 Interpolator (android.view.animation.Interpolator)11 Reveal (carbon.internal.Reveal)11 Paint (android.graphics.Paint)7 ObjectAnimator (com.nineoldandroids.animation.ObjectAnimator)6 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)5 RecyclerView (android.support.v7.widget.RecyclerView)4 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)4 FrameLayout (android.widget.FrameLayout)4 ImageView (android.widget.ImageView)4 ArrayList (java.util.ArrayList)4 MotionEvent (android.view.MotionEvent)3 TouchInterceptionFrameLayout (com.github.ksoichiro.android.observablescrollview.TouchInterceptionFrameLayout)3 AnimatorUpdateListener (com.nineoldandroids.animation.ValueAnimator.AnimatorUpdateListener)3