Search in sources :

Example 1 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project android-betterpickers by code-troopers.

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(AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(this) : 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 2 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project android-betterpickers by code-troopers.

the class RadialTimePickerDialogFragment method setCurrentItemShowing.

// Show either Hours or Minutes.
private void setCurrentItemShowing(int index, boolean animateCircle, boolean delayLabelAnimate, boolean announce) {
    mTimePicker.setCurrentItemShowing(index, animateCircle);
    TextView labelToAnimate;
    if (index == HOUR_INDEX) {
        int hours = mTimePicker.getHours();
        if (!mIs24HourMode) {
            hours = hours % 12;
        }
        mTimePicker.setContentDescription(mHourPickerDescription + ": " + hours);
        if (announce) {
            Utils.tryAccessibilityAnnounce(mTimePicker, mSelectHours);
        }
        labelToAnimate = mHourView;
    } else {
        int minutes = mTimePicker.getMinutes();
        mTimePicker.setContentDescription(mMinutePickerDescription + ": " + minutes);
        if (announce) {
            Utils.tryAccessibilityAnnounce(mTimePicker, mSelectMinutes);
        }
        labelToAnimate = mMinuteView;
    }
    int hourColor = (index == HOUR_INDEX) ? mSelectedColor : mUnselectedColor;
    int minuteColor = (index == MINUTE_INDEX) ? mSelectedColor : mUnselectedColor;
    mHourView.setTextColor(hourColor);
    mMinuteView.setTextColor(minuteColor);
    ObjectAnimator pulseAnimator = Utils.getPulseAnimator(labelToAnimate, 0.85f, 1.1f);
    if (delayLabelAnimate) {
        pulseAnimator.setStartDelay(PULSE_ANIMATOR_DELAY);
    }
    pulseAnimator.start();
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) NumberPickerErrorTextView(com.codetroopers.betterpickers.numberpicker.NumberPickerErrorTextView) TextView(android.widget.TextView)

Example 3 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project android-betterpickers by code-troopers.

the class CalendarDatePickerDialogFragment method setCurrentView.

private void setCurrentView(final int viewIndex) {
    long millis = mCalendar.getTimeInMillis();
    switch(viewIndex) {
        case MONTH_AND_DAY_VIEW:
            ObjectAnimator pulseAnimator = Utils.getPulseAnimator(mMonthAndDayView, 0.9f, 1.05f);
            if (mDelayAnimation) {
                pulseAnimator.setStartDelay(ANIMATION_DELAY);
                mDelayAnimation = false;
            }
            mDayPickerView.onDateChanged();
            if (mCurrentView != viewIndex) {
                mMonthAndDayView.setSelected(true);
                mYearView.setSelected(false);
                mSelectedDayTextView.setTextColor(mSelectedColor);
                mSelectedMonthTextView.setTextColor(mSelectedColor);
                mYearView.setTextColor(mUnselectedColor);
                mAnimator.setDisplayedChild(MONTH_AND_DAY_VIEW);
                mCurrentView = viewIndex;
            }
            pulseAnimator.start();
            int flags = DateUtils.FORMAT_SHOW_DATE;
            String dayString = DateUtils.formatDateTime(getActivity(), millis, flags);
            mAnimator.setContentDescription(mDayPickerDescription + ": " + dayString);
            Utils.tryAccessibilityAnnounce(mAnimator, mSelectDay);
            break;
        case YEAR_VIEW:
            pulseAnimator = Utils.getPulseAnimator(mYearView, 0.85f, 1.1f);
            if (mDelayAnimation) {
                pulseAnimator.setStartDelay(ANIMATION_DELAY);
                mDelayAnimation = false;
            }
            mYearPickerView.onDateChanged();
            if (mCurrentView != viewIndex) {
                mMonthAndDayView.setSelected(false);
                mYearView.setSelected(true);
                mSelectedDayTextView.setTextColor(mUnselectedColor);
                mSelectedMonthTextView.setTextColor(mUnselectedColor);
                mYearView.setTextColor(mSelectedColor);
                mAnimator.setDisplayedChild(YEAR_VIEW);
                mCurrentView = viewIndex;
            }
            pulseAnimator.start();
            CharSequence yearString = YEAR_FORMAT.format(millis);
            mAnimator.setContentDescription(mYearPickerDescription + ": " + yearString);
            Utils.tryAccessibilityAnnounce(mAnimator, mSelectYear);
            break;
    }
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator)

Example 4 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project Meizhi by drakeet.

the class HeadsUpManager method animDismiss.

protected void animDismiss() {
    if (floatView != null && floatView.getParent() != null) {
        ObjectAnimator a = ObjectAnimator.ofFloat(floatView.rootView, "translationY", 0, -700);
        a.setDuration(700);
        a.start();
        a.addListener(new Animator.AnimatorListener() {

            @Override
            public void onAnimationStart(Animator animator) {
            }

            @Override
            public void onAnimationEnd(Animator animator) {
                dismiss();
            }

            @Override
            public void onAnimationCancel(Animator animator) {
            }

            @Override
            public void onAnimationRepeat(Animator animator) {
            }
        });
    }
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator)

Example 5 with ObjectAnimator

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

the class DynamicListView method handleCellSwitch.

/**
     * This method determines whether the hover cell has been shifted far enough
     * to invoke a cell swap. If so, then the respective cell swap candidate is
     * determined and the data set is changed. Upon posting a notification of the
     * data set change, a layout is invoked to place the cells in the right place.
     * Using a ViewTreeObserver and a corresponding OnPreDrawListener, we can
     * offset the cell being swapped to where it previously was and then animate it to
     * its new position.
     */
private void handleCellSwitch() {
    final int deltaY = mLastEventY - mDownY;
    int deltaYTotal = mHoverCellOriginalBounds.top + mTotalOffset + deltaY;
    View belowView = getViewForId(mBelowItemId);
    View mobileView = getViewForId(mMobileItemId);
    View aboveView = getViewForId(mAboveItemId);
    boolean isBelow = (belowView != null) && (deltaYTotal > belowView.getTop());
    boolean isAbove = (aboveView != null) && (deltaYTotal < aboveView.getTop());
    if (isBelow || isAbove) {
        final long switchItemId = isBelow ? mBelowItemId : mAboveItemId;
        View switchView = isBelow ? belowView : aboveView;
        final int originalItem = getPositionForView(mobileView);
        if (switchView == null) {
            updateNeighborViewsForId(mMobileItemId);
            return;
        }
        if (getPositionForView(switchView) < getHeaderViewsCount()) {
            return;
        }
        swapElements(originalItem, getPositionForView(switchView));
        BaseAdapter adapter;
        if (getAdapter() instanceof HeaderViewListAdapter) {
            adapter = (BaseAdapter) ((HeaderViewListAdapter) getAdapter()).getWrappedAdapter();
        } else {
            adapter = (BaseAdapter) getAdapter();
        }
        adapter.notifyDataSetChanged();
        mDownY = mLastEventY;
        mDownX = mLastEventX;
        final int switchViewStartTop = switchView.getTop();
        mobileView.setVisibility(View.VISIBLE);
        switchView.setVisibility(View.INVISIBLE);
        updateNeighborViewsForId(mMobileItemId);
        final ViewTreeObserver observer = getViewTreeObserver();
        observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

            public boolean onPreDraw() {
                observer.removeOnPreDrawListener(this);
                View switchView = getViewForId(switchItemId);
                mTotalOffset += deltaY;
                int switchViewNewTop = switchView.getTop();
                int delta = switchViewStartTop - switchViewNewTop;
                ViewHelper.setTranslationY(switchView, delta);
                ObjectAnimator animator = ObjectAnimator.ofFloat(switchView, "translationY", 0);
                animator.setDuration(MOVE_DURATION);
                animator.start();
                return true;
            }
        });
    }
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) HeaderViewListAdapter(android.widget.HeaderViewListAdapter) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) BaseAdapter(android.widget.BaseAdapter) ViewTreeObserver(android.view.ViewTreeObserver)

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