Search in sources :

Example 46 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project datetimepicker by flavienlaurent.

the class Utils method getPulseAnimator.

public static ObjectAnimator getPulseAnimator(View labelToAnimate, float decreaseRatio, float increaseRatio) {
    Keyframe k0 = Keyframe.ofFloat(0f, 1f);
    Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio);
    Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio);
    Keyframe k3 = Keyframe.ofFloat(1f, 1f);
    PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3);
    PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3);
    ObjectAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY);
    pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION);
    return pulseAnimator;
}
Also used : Keyframe(com.nineoldandroids.animation.Keyframe) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) PropertyValuesHolder(com.nineoldandroids.animation.PropertyValuesHolder)

Example 47 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project datetimepicker by flavienlaurent.

the class RadialPickerLayout method setCurrentItemShowing.

/**
     * Set either minutes or hours as showing.
     *
     * @param animate True to animate the transition, false to show with no animation.
     */
public void setCurrentItemShowing(int index, boolean animate) {
    if (index != HOUR_INDEX && index != MINUTE_INDEX) {
        Log.e(TAG, "TimePicker does not support view at index " + index);
        return;
    }
    //NineOldDroids does not work in this case due to dependency recursion.
    //Don't animate on API 14
    animate = animate && Build.VERSION.SDK_INT > 14;
    int lastIndex = getCurrentItemShowing();
    mCurrentItemShowing = index;
    if (animate && (index != lastIndex)) {
        ObjectAnimator[] anims = new ObjectAnimator[4];
        if (index == MINUTE_INDEX) {
            anims[0] = mHourRadialTextsView.getDisappearAnimator();
            anims[1] = mHourRadialSelectorView.getDisappearAnimator();
            anims[2] = mMinuteRadialTextsView.getReappearAnimator();
            anims[3] = mMinuteRadialSelectorView.getReappearAnimator();
        } else if (index == HOUR_INDEX) {
            anims[0] = mHourRadialTextsView.getReappearAnimator();
            anims[1] = mHourRadialSelectorView.getReappearAnimator();
            anims[2] = mMinuteRadialTextsView.getDisappearAnimator();
            anims[3] = mMinuteRadialSelectorView.getDisappearAnimator();
        }
        if (mTransition != null && mTransition.isRunning()) {
            mTransition.end();
        }
        mTransition = new AnimatorSet();
        mTransition.playTogether(anims);
        mTransition.start();
    } else {
        if (Build.VERSION.SDK_INT >= 11) {
            int hourAlpha = (index == HOUR_INDEX) ? 255 : 0;
            int minuteAlpha = (index == MINUTE_INDEX) ? 255 : 0;
            mHourRadialTextsView.setAlpha(hourAlpha);
            mHourRadialSelectorView.setAlpha(hourAlpha);
            mMinuteRadialTextsView.setAlpha(minuteAlpha);
            mMinuteRadialSelectorView.setAlpha(minuteAlpha);
        } else {
            int hourVisibility = (index == HOUR_INDEX) ? View.VISIBLE : View.INVISIBLE;
            int minuteVisibility = (index == MINUTE_INDEX) ? View.VISIBLE : View.INVISIBLE;
            mHourRadialTextsView.setVisibility(hourVisibility);
            mHourRadialSelectorView.setVisibility(hourVisibility);
            mMinuteRadialTextsView.setVisibility(minuteVisibility);
            mMinuteRadialSelectorView.setVisibility(minuteVisibility);
        }
    }
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet) SuppressLint(android.annotation.SuppressLint)

Example 48 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project datetimepicker by flavienlaurent.

the class RadialSelectorView method getDisappearAnimator.

public ObjectAnimator getDisappearAnimator() {
    if (!mIsInitialized || !mDrawValuesReady) {
        Log.e(TAG, "RadialSelectorView was not ready for animation.");
        return null;
    }
    Keyframe kf0, kf1, kf2;
    float midwayPoint = 0.2f;
    int duration = 500;
    kf0 = Keyframe.ofFloat(0f, 1);
    kf1 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
    kf2 = Keyframe.ofFloat(1f, mTransitionEndRadiusMultiplier);
    PropertyValuesHolder radiusDisappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2);
    kf0 = Keyframe.ofFloat(0f, 1f);
    kf1 = Keyframe.ofFloat(1f, 0f);
    PropertyValuesHolder fadeOut = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1);
    ObjectAnimator disappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusDisappear, fadeOut).setDuration(duration);
    disappearAnimator.addUpdateListener(mInvalidateUpdateListener);
    return disappearAnimator;
}
Also used : Keyframe(com.nineoldandroids.animation.Keyframe) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) PropertyValuesHolder(com.nineoldandroids.animation.PropertyValuesHolder) Paint(android.graphics.Paint)

Example 49 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project datetimepicker by flavienlaurent.

the class RadialSelectorView method getReappearAnimator.

public ObjectAnimator getReappearAnimator() {
    if (!mIsInitialized || !mDrawValuesReady) {
        Log.e(TAG, "RadialSelectorView was not ready for animation.");
        return null;
    }
    Keyframe kf0, kf1, kf2, kf3;
    float midwayPoint = 0.2f;
    int duration = 500;
    // The time points are half of what they would normally be, because this animation is
    // staggered against the disappear so they happen seamlessly. The reappear starts
    // halfway into the disappear.
    float delayMultiplier = 0.25f;
    float transitionDurationMultiplier = 1f;
    float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier;
    int totalDuration = (int) (duration * totalDurationMultiplier);
    float delayPoint = (delayMultiplier * duration) / totalDuration;
    midwayPoint = 1 - (midwayPoint * (1 - delayPoint));
    kf0 = Keyframe.ofFloat(0f, mTransitionEndRadiusMultiplier);
    kf1 = Keyframe.ofFloat(delayPoint, mTransitionEndRadiusMultiplier);
    kf2 = Keyframe.ofFloat(midwayPoint, mTransitionMidRadiusMultiplier);
    kf3 = Keyframe.ofFloat(1f, 1);
    PropertyValuesHolder radiusReappear = PropertyValuesHolder.ofKeyframe("animationRadiusMultiplier", kf0, kf1, kf2, kf3);
    kf0 = Keyframe.ofFloat(0f, 0f);
    kf1 = Keyframe.ofFloat(delayPoint, 0f);
    kf2 = Keyframe.ofFloat(1f, 1f);
    PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("alpha", kf0, kf1, kf2);
    ObjectAnimator reappearAnimator = ObjectAnimator.ofPropertyValuesHolder(this, radiusReappear, fadeIn).setDuration(totalDuration);
    reappearAnimator.addUpdateListener(mInvalidateUpdateListener);
    return reappearAnimator;
}
Also used : Keyframe(com.nineoldandroids.animation.Keyframe) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) PropertyValuesHolder(com.nineoldandroids.animation.PropertyValuesHolder) Paint(android.graphics.Paint)

Example 50 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator 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

ObjectAnimator (com.nineoldandroids.animation.ObjectAnimator)81 AnimatorSet (com.nineoldandroids.animation.AnimatorSet)27 Animator (com.nineoldandroids.animation.Animator)20 View (android.view.View)11 PropertyValuesHolder (com.nineoldandroids.animation.PropertyValuesHolder)10 Keyframe (com.nineoldandroids.animation.Keyframe)9 Paint (android.graphics.Paint)8 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)8 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)6 TextView (android.widget.TextView)5 AdapterView (android.widget.AdapterView)4 AnimatorListenerAdapter (com.nineoldandroids.animation.AnimatorListenerAdapter)4 SuppressLint (android.annotation.SuppressLint)3 TargetApi (android.annotation.TargetApi)3 LinearInterpolator (android.view.animation.LinearInterpolator)3 OvershootInterpolator (android.view.animation.OvershootInterpolator)3 AbsListView (android.widget.AbsListView)3 ListView (android.widget.ListView)3 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)3 SupportAnimator (io.codetail.animation.SupportAnimator)3