Example usage for android.animation ObjectAnimator setStartDelay

List of usage examples for android.animation ObjectAnimator setStartDelay

Introduction

In this page you can find the example usage for android.animation ObjectAnimator setStartDelay.

Prototype

@Override
public void setStartDelay(long startDelay) 

Source Link

Document

The amount of time, in milliseconds, to delay starting the animation after #start() is called.

Usage

From source file:com.jarklee.materialdatetimepicker.date.DatePickerDialog.java

private void setCurrentView(final int viewIndex) {
    long millis = mCalendar.getTimeInMillis();
    ObjectAnimator pulseAnimator = null;
    switch (viewIndex) {
    case MONTH_AND_DAY_VIEW:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            pulseAnimator = Utils.getPulseAnimator(mMonthAndDayView, 0.9f, 1.05f);
            if (mDelayAnimation) {
                pulseAnimator.setStartDelay(ANIMATION_DELAY);
                mDelayAnimation = false;
            }/*from  w  w  w.  ja va2 s.c  o  m*/
        } else {
            pulseAnimator = null;
        }
        mDayPickerView.onDateChanged();
        if (mCurrentView != viewIndex) {
            mMonthAndDayView.setSelected(true);
            mYearView.setSelected(false);
            mAnimator.setDisplayedChild(MONTH_AND_DAY_VIEW);
            mCurrentView = viewIndex;
        }
        if (pulseAnimator != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            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:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            pulseAnimator = Utils.getPulseAnimator(mYearView, 0.85f, 1.1f);
            if (mDelayAnimation) {
                pulseAnimator.setStartDelay(ANIMATION_DELAY);
                mDelayAnimation = false;
            }
        } else {
            pulseAnimator = null;
        }
        mYearPickerView.onDateChanged();
        if (mCurrentView != viewIndex) {
            mMonthAndDayView.setSelected(false);
            mYearView.setSelected(true);
            mAnimator.setDisplayedChild(YEAR_VIEW);
            mCurrentView = viewIndex;
        }
        if (pulseAnimator != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            pulseAnimator.start();
        }
        CharSequence yearString = YEAR_FORMAT.format(millis);
        mAnimator.setContentDescription(mYearPickerDescription + ": " + yearString);
        Utils.tryAccessibilityAnnounce(mAnimator, mSelectYear);
        break;
    }
}

From source file:com.taobao.weex.dom.action.AnimationAction.java

private @Nullable ObjectAnimator createAnimator(final View target, final int viewPortWidth) {
    if (target == null) {
        return null;
    }//www.j  av  a 2s.co m
    WXAnimationBean.Style style = mAnimationBean.styles;
    if (style != null) {
        ObjectAnimator animator;
        List<PropertyValuesHolder> holders = style.getHolders();
        if (!TextUtils.isEmpty(style.backgroundColor)) {
            BorderDrawable borderDrawable;
            if ((borderDrawable = WXViewUtils.getBorderDrawable(target)) != null) {
                holders.add(PropertyValuesHolder.ofObject(new BackgroundColorProperty(), new ArgbEvaluator(),
                        borderDrawable.getColor(), WXResourceUtils.getColor(style.backgroundColor)));
            } else if (target.getBackground() instanceof ColorDrawable) {
                holders.add(PropertyValuesHolder.ofObject(new BackgroundColorProperty(), new ArgbEvaluator(),
                        ((ColorDrawable) target.getBackground()).getColor(),
                        WXResourceUtils.getColor(style.backgroundColor)));
            }
        }
        if (style.getPivot() != null) {
            Pair<Float, Float> pair = style.getPivot();
            target.setPivotX(pair.first);
            target.setPivotY(pair.second);
        }
        animator = ObjectAnimator.ofPropertyValuesHolder(target,
                holders.toArray(new PropertyValuesHolder[holders.size()]));
        animator.setStartDelay(mAnimationBean.delay);
        if (target.getLayoutParams() != null
                && (!TextUtils.isEmpty(style.width) || !TextUtils.isEmpty(style.height))) {
            DimensionUpdateListener listener = new DimensionUpdateListener(target);
            ViewGroup.LayoutParams layoutParams = target.getLayoutParams();
            if (!TextUtils.isEmpty(style.width)) {
                listener.setWidth(layoutParams.width,
                        (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.width), viewPortWidth));
            }
            if (!TextUtils.isEmpty(style.height)) {
                listener.setHeight(layoutParams.height,
                        (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.height), viewPortWidth));
            }
            animator.addUpdateListener(listener);
        }
        return animator;
    } else {
        return null;
    }
}

From source file:com.mishiranu.dashchan.ui.navigator.NavigatorActivity.java

private void performNavigation(final PageHolder.Content content, final String chanName, final String boardName,
        final String threadNumber, final String postNumber, final String threadTitle, final String searchQuery,
        final boolean fromCache, boolean animated, final boolean returnable) {
    PageHolder pageHolder = pageManager.getCurrentPage();
    if (pageHolder != null && pageHolder.is(chanName, boardName, threadNumber, content)
            && searchQuery == null) {
        // Page could be deleted from stack during clearStack (when home button pressed, for example)
        pageHolder.returnable &= returnable;
        pageManager.moveCurrentPageTop();
        page.updatePageConfiguration(postNumber, threadTitle);
        drawerForm.invalidateItems(true, false);
        invalidateHomeUpState();/*from  www . j a  v a2  s  . c o  m*/
        return;
    }
    switchView(ListPage.ViewType.LIST, null);
    listView.getWrapper().cancelBusyState();
    listView.getWrapper().setPullSides(PullableWrapper.Side.NONE);
    ClickableToast.cancel(this);
    requestStoreExtraAndPosition();
    cleanupPage();
    handler.removeCallbacks(queuedHandler);
    setActionBarLocked(LOCKER_HANDLE, true);
    if (animated) {
        queuedHandler = () -> {
            queuedHandler = null;
            if (listView.getAnimation() != null) {
                listView.getAnimation().cancel();
            }
            listView.setAlpha(1f);
            handleDataAfterAnimation(content, chanName, boardName, threadNumber, postNumber, threadTitle,
                    searchQuery, fromCache, true, returnable);
        };
        handler.postDelayed(queuedHandler, 300);
        ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(listView, View.ALPHA, 1f, 0f);
        alphaAnimator.setupStartValues();
        alphaAnimator.setStartDelay(150);
        alphaAnimator.setDuration(150);
        startListAnimator(alphaAnimator);
    } else {
        handleDataAfterAnimation(content, chanName, boardName, threadNumber, postNumber, threadTitle,
                searchQuery, fromCache, false, returnable);
    }
}

From source file:com.waz.zclient.pages.main.participants.ParticipantFragment.java

@Override
public void onHidePickUser(IPickUserController.Destination destination, boolean closeWithoutSelectingPeople) {
    if (LayoutSpec.isPhone(getActivity())) {
        return;/*  w  w w. j av  a  2 s . c om*/
    }
    if (!destination.equals(getCurrentPickerDestination())) {
        return;
    }
    // Workaround for animation bug with nested child fragments
    // Animating fragment container views and then popping stack at end of animation

    int showParticipantsDelay = getResources().getInteger(R.integer.framework_animation_delay_long);
    int hidePickUserAnimDuration = getResources().getInteger(R.integer.framework_animation_duration_medium);
    TimeInterpolator hidePickUserInterpolator = new Expo.EaseIn();
    ObjectAnimator hidePickUserAnimator;
    // Fade animation in participants dialog on tablet
    if (LayoutSpec.isTablet(getActivity())) {
        hidePickUserAnimator = ObjectAnimator.ofFloat(pickUserContainerView, View.ALPHA, 1f, 0f);
        hidePickUserAnimator.setInterpolator(new Linear.EaseIn());

    } else {
        hidePickUserAnimator = ObjectAnimator.ofFloat(pickUserContainerView, View.TRANSLATION_Y, 0f,
                pickUserContainerView.getMeasuredHeight());
        hidePickUserAnimator.setInterpolator(hidePickUserInterpolator);
        hidePickUserAnimator.setDuration(hidePickUserAnimDuration);
    }
    hidePickUserAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (!isResumed()) {
                return;
            }
            getChildFragmentManager().popBackStackImmediate(PickUserFragment.TAG,
                    FragmentManager.POP_BACK_STACK_INCLUSIVE);

            if (LayoutSpec.isTablet(getActivity())) {
                // Reset for fade animation in participants dialog on tablet
                pickUserContainerView.setAlpha(1f);
            } else {
                pickUserContainerView.setTranslationY(0f);
            }
        }
    });

    participantsContainerView.setAlpha(0);
    participantsContainerView.setVisibility(View.VISIBLE);
    ObjectAnimator showParticipantsAnimator = ObjectAnimator.ofFloat(participantsContainerView, View.ALPHA, 0f,
            1f);
    showParticipantsAnimator.setInterpolator(new Quart.EaseOut());
    showParticipantsAnimator
            .setDuration(getResources().getInteger(R.integer.framework_animation_duration_medium));
    showParticipantsAnimator.setStartDelay(showParticipantsDelay);

    AnimatorSet hideSet = new AnimatorSet();
    hideSet.playTogether(hidePickUserAnimator, showParticipantsAnimator);
    hideSet.start();

    if (LayoutSpec.isPhone(getActivity()) && getControllerFactory().getNavigationController()
            .getPagerPosition() == NavigationController.SECOND_PAGE) {
        // TODO: https://wearezeta.atlassian.net/browse/AN-3081
        if (getControllerFactory().getConversationScreenController().isShowingParticipant()) {
            getControllerFactory().getNavigationController().setRightPage(Page.PARTICIPANT, TAG);
        } else {
            getControllerFactory().getNavigationController().setRightPage(Page.MESSAGE_STREAM, TAG);
        }
    }
}

From source file:com.borax12.materialdaterangepicker.single.time.TimePickerDialog.java

private void setCurrentItemShowing(int index, boolean animateCircle, boolean delayLabelAnimate,
        boolean announce) {
    mTimePicker.setCurrentItemShowing(index, animateCircle);

    TextView labelToAnimate;//from  w  w  w  .  j av  a2s  .  co m
    switch (index) {
    case HOUR_INDEX:
        int hours = mTimePicker.getHours();
        if (!mIs24HourMode) {
            hours = hours % 12;
        }
        mTimePicker.setContentDescription(mHourPickerDescription + ": " + hours);
        if (announce) {
            Utils.tryAccessibilityAnnounce(mTimePicker, mSelectHours);
        }
        labelToAnimate = mHourView;
        break;
    case MINUTE_INDEX:
        int minutes = mTimePicker.getMinutes();
        mTimePicker.setContentDescription(mMinutePickerDescription + ": " + minutes);
        if (announce) {
            Utils.tryAccessibilityAnnounce(mTimePicker, mSelectMinutes);
        }
        labelToAnimate = mMinuteView;
        break;
    default:
        int seconds = mTimePicker.getSeconds();
        mTimePicker.setContentDescription(mSecondPickerDescription + ": " + seconds);
        if (announce) {
            Utils.tryAccessibilityAnnounce(mTimePicker, mSelectSeconds);
        }
        labelToAnimate = mSecondView;
    }

    int hourColor = (index == HOUR_INDEX) ? mSelectedColor : mUnselectedColor;
    int minuteColor = (index == MINUTE_INDEX) ? mSelectedColor : mUnselectedColor;
    int secondColor = (index == SECOND_INDEX) ? mSelectedColor : mUnselectedColor;
    mHourView.setTextColor(hourColor);
    mMinuteView.setTextColor(minuteColor);
    mSecondView.setTextColor(secondColor);

    ObjectAnimator pulseAnimator = Utils.getPulseAnimator(labelToAnimate, 0.85f, 1.1f);
    if (delayLabelAnimate) {
        pulseAnimator.setStartDelay(PULSE_ANIMATOR_DELAY);
    }
    pulseAnimator.start();
}

From source file:com.jarklee.materialdatetimepicker.time.TimePickerDialog.java

private void setCurrentItemShowing(int index, boolean animateCircle, boolean delayLabelAnimate,
        boolean announce) {
    mTimePicker.setCurrentItemShowing(index, animateCircle);

    TextView labelToAnimate;/*from  w w  w.  j  a  v  a2  s .  co m*/
    switch (index) {
    case HOUR_INDEX:
        int hours = mTimePicker.getHours();
        if (!mIs24HourMode) {
            hours = hours % 12;
        }
        mTimePicker.setContentDescription(mHourPickerDescription + ": " + hours);
        if (announce) {
            Utils.tryAccessibilityAnnounce(mTimePicker, mSelectHours);
        }
        labelToAnimate = mHourView;
        break;
    case MINUTE_INDEX:
        int minutes = mTimePicker.getMinutes();
        mTimePicker.setContentDescription(mMinutePickerDescription + ": " + minutes);
        if (announce) {
            Utils.tryAccessibilityAnnounce(mTimePicker, mSelectMinutes);
        }
        labelToAnimate = mMinuteView;
        break;
    default:
        int seconds = mTimePicker.getSeconds();
        mTimePicker.setContentDescription(mSecondPickerDescription + ": " + seconds);
        if (announce) {
            Utils.tryAccessibilityAnnounce(mTimePicker, mSelectSeconds);
        }
        labelToAnimate = mSecondView;
    }

    int hourColor = (index == HOUR_INDEX) ? mSelectedColor : mUnselectedColor;
    int minuteColor = (index == MINUTE_INDEX) ? mSelectedColor : mUnselectedColor;
    int secondColor = (index == SECOND_INDEX) ? mSelectedColor : mUnselectedColor;
    mHourView.setTextColor(hourColor);
    mMinuteView.setTextColor(minuteColor);
    mSecondView.setTextColor(secondColor);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        ObjectAnimator pulseAnimator = Utils.getPulseAnimator(labelToAnimate, 0.85f, 1.1f);
        if (delayLabelAnimate) {
            pulseAnimator.setStartDelay(PULSE_ANIMATOR_DELAY);
        }
        pulseAnimator.start();
    }
}

From source file:com.kenmeidearu.materialdatetimepicker.date.DatePickerDialog.java

private void setCurrentView(final int viewIndex) {
    long millis = mCalendar.getTimeInMillis();
    switch (viewIndex) {
    case MONTH_AND_DAY_VIEW:
        ObjectAnimator pulseAnimator = Utils.getPulseAnimator(mDayOfWeekView, 0.9f, 1.05f);
        if (mDelayAnimation) {
            pulseAnimator.setStartDelay(ANIMATION_DELAY);
            mDelayAnimation = false;// w  ww  . j av a2  s. c  o m
        }
        mDayPickerView.onDateChanged();
        if (mCurrentView != viewIndex) {
            mMonthAndDayView.setSelected(true);
            mSelectedDayTextView.setSelected(true);//tadinya month and day view
            mSelectedMonthTextView.setSelected(false);
            mYearView.setSelected(false);
            mHourView.setSelected(false);
            mMinuteView.setSelected(false);
            mSecondView.setSelected(false);
            mAmPmTextView.setSelected(false);
            mHourView.setTextColor(getResources().getColor(R.color.mdtp_accent_color_focused));
            mMinuteView.setTextColor(getResources().getColor(R.color.mdtp_accent_color_focused));
            mSecondView.setTextColor(getResources().getColor(R.color.mdtp_accent_color_focused));
            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 MONTH_VIEW:
        pulseAnimator = Utils.getPulseAnimator(mSelectedMonthTextView, 0.85f, 1.1f);
        if (mDelayAnimation) {
            pulseAnimator.setStartDelay(ANIMATION_DELAY);
            mDelayAnimation = false;
        }
        mMonthPickerView.onDateChanged();
        if (mCurrentView != viewIndex) {
            mMonthAndDayView.setSelected(true);
            mSelectedDayTextView.setSelected(false);
            mSelectedMonthTextView.setSelected(true);
            mYearView.setSelected(false);
            mHourView.setSelected(false);
            mMinuteView.setSelected(false);
            mSecondView.setSelected(false);
            mAmPmTextView.setSelected(false);
            mHourView.setTextColor(getResources().getColor(R.color.mdtp_accent_color_focused));
            mMinuteView.setTextColor(getResources().getColor(R.color.mdtp_accent_color_focused));
            mSecondView.setTextColor(getResources().getColor(R.color.mdtp_accent_color_focused));
            mAnimator.setDisplayedChild(MONTH_VIEW);
            mCurrentView = viewIndex;
        }
        pulseAnimator.start();

        CharSequence monthString = MONTH_FORMAT.format(millis);
        mAnimator.setContentDescription(mMonthPickerDescription + ": " + monthString);
        Utils.tryAccessibilityAnnounce(mAnimator, mSelectMonth);
        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);
            mSelectedDayTextView.setSelected(false);
            mSelectedMonthTextView.setSelected(false);
            mYearView.setSelected(true);
            mHourView.setSelected(false);
            mMinuteView.setSelected(false);
            mSecondView.setSelected(false);
            mAmPmTextView.setSelected(false);
            mHourView.setTextColor(getResources().getColor(R.color.mdtp_accent_color_focused));
            mMinuteView.setTextColor(getResources().getColor(R.color.mdtp_accent_color_focused));
            mSecondView.setTextColor(getResources().getColor(R.color.mdtp_accent_color_focused));
            mAnimator.setDisplayedChild(YEAR_VIEW);
            mCurrentView = viewIndex;
        }
        pulseAnimator.start();

        CharSequence yearString = YEAR_FORMAT.format(millis);
        mAnimator.setContentDescription(mYearPickerDescription + ": " + yearString);
        Utils.tryAccessibilityAnnounce(mAnimator, mSelectYear);
        break;
    case HOUR_INDEX:
        pulseAnimator = Utils.getPulseAnimator(mHourView, 0.85f, 1.1f);
        if (mDelayAnimation) {
            pulseAnimator.setStartDelay(ANIMATION_DELAY);
            mDelayAnimation = false;
        }
        mHourPickerView.onDateChanged();
        if (mCurrentView != viewIndex) {
            mMonthAndDayView.setSelected(true);
            mSelectedDayTextView.setSelected(false);
            mSelectedMonthTextView.setSelected(false);
            mYearView.setSelected(false);
            mHourView.setSelected(true);
            mMinuteView.setSelected(false);
            mSecondView.setSelected(false);
            mAmPmTextView.setSelected(false);
            mHourView.setTextColor(getResources().getColor(R.color.mdtp_white));
            mMinuteView.setTextColor(getResources().getColor(R.color.mdtp_accent_color_focused));
            mSecondView.setTextColor(getResources().getColor(R.color.mdtp_accent_color_focused));
            mAnimator.setDisplayedChild(HOUR_INDEX);
            mCurrentView = viewIndex;
        }
        pulseAnimator.start();

        CharSequence hourString = MONTH_FORMAT.format(millis);
        mAnimator.setContentDescription(mHourPickerDescription + ": " + hourString);
        Utils.tryAccessibilityAnnounce(mAnimator, mSelectHours);
        break;
    case MINUTE_INDEX:
        pulseAnimator = Utils.getPulseAnimator(mMinuteView, 0.85f, 1.1f);
        if (mDelayAnimation) {
            pulseAnimator.setStartDelay(ANIMATION_DELAY);
            mDelayAnimation = false;
        }
        mMinutePickerView.onDateChanged();
        if (mCurrentView != viewIndex) {
            mMonthAndDayView.setSelected(true);
            mSelectedDayTextView.setSelected(false);
            mSelectedMonthTextView.setSelected(false);
            mYearView.setSelected(false);
            mHourView.setSelected(false);
            mMinuteView.setSelected(true);
            mSecondView.setSelected(false);
            mAmPmTextView.setSelected(false);
            mHourView.setTextColor(getResources().getColor(R.color.mdtp_accent_color_focused));
            mMinuteView.setTextColor(getResources().getColor(R.color.mdtp_white));
            mSecondView.setTextColor(getResources().getColor(R.color.mdtp_accent_color_focused));
            mAnimator.setDisplayedChild(MINUTE_INDEX);
            mCurrentView = viewIndex;
        }
        pulseAnimator.start();

        CharSequence minuteString = MONTH_FORMAT.format(millis);
        mAnimator.setContentDescription(mMinutePickerDescription + ": " + minuteString);
        Utils.tryAccessibilityAnnounce(mAnimator, mSelectMinutes);
        break;
    case SECOND_INDEX:
        pulseAnimator = Utils.getPulseAnimator(mSecondView, 0.85f, 1.1f);
        if (mDelayAnimation) {
            pulseAnimator.setStartDelay(ANIMATION_DELAY);
            mDelayAnimation = false;
        }
        mSecondPickerView.onDateChanged();
        if (mCurrentView != viewIndex) {
            mMonthAndDayView.setSelected(true);
            mSelectedDayTextView.setSelected(false);
            mSelectedMonthTextView.setSelected(false);
            mYearView.setSelected(false);
            mHourView.setSelected(false);
            mMinuteView.setSelected(false);
            mSecondView.setSelected(true);
            mAmPmTextView.setSelected(false);
            mHourView.setTextColor(getResources().getColor(R.color.mdtp_accent_color_focused));
            mMinuteView.setTextColor(getResources().getColor(R.color.mdtp_accent_color_focused));
            mSecondView.setTextColor(getResources().getColor(R.color.mdtp_white));
            mAnimator.setDisplayedChild(SECOND_INDEX);
            mCurrentView = viewIndex;
        }
        pulseAnimator.start();

        CharSequence secondString = MONTH_FORMAT.format(millis);
        mAnimator.setContentDescription(mSecondPickerDescription + ": " + secondString);
        Utils.tryAccessibilityAnnounce(mAnimator, mSelectSeconds);
        break;
    }
}

From source file:com.bartoszlipinski.viewpropertyobjectanimator.ViewPropertyObjectAnimator.java

@SuppressLint("NewApi")
public ObjectAnimator get() {
    if (hasView()) {
        Collection<PropertyValuesHolder> holders = mPropertyHoldersMap.values();
        ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(mView.get(),
                holders.toArray(new PropertyValuesHolder[holders.size()]));
        if (mWithLayer) {
            animator.addListener(new AnimatorListenerAdapter() {
                int mCurrentLayerType = View.LAYER_TYPE_NONE;

                @Override/*from  w w  w  .  j a v  a2 s.  com*/
                public void onAnimationStart(Animator animation) {
                    if (hasView()) {
                        View view = mView.get();
                        mCurrentLayerType = view.getLayerType();
                        view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
                        if (ViewCompat.isAttachedToWindow(view)) {
                            view.buildLayer();
                        }
                    }
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    if (hasView()) {
                        mView.get().setLayerType(mCurrentLayerType, null);
                    }
                }
            });
        }
        if (mStartDelay != -1) {
            animator.setStartDelay(mStartDelay);
        }
        if (mDuration != -1) {
            animator.setDuration(mDuration);
        }
        if (mInterpolator != null) {
            animator.setInterpolator(mInterpolator);
        }
        for (Animator.AnimatorListener listener : mListeners) {
            animator.addListener(listener);
        }
        if (mMarginListener != null) {
            animator.addUpdateListener(mMarginListener);
        }
        if (mDimensionListener != null) {
            animator.addUpdateListener(mDimensionListener);
        }
        if (mPaddingListener != null) {
            animator.addUpdateListener(mPaddingListener);
        }
        if (mScrollListener != null) {
            animator.addUpdateListener(mScrollListener);
        }
        if (mPercentListener != null) {
            animator.addUpdateListener(mPercentListener);
        }
        for (ValueAnimator.AnimatorUpdateListener listener : mUpdateListeners) {
            animator.addUpdateListener(listener);
        }
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            for (Animator.AnimatorPauseListener listener : mPauseListeners) {
                animator.addPauseListener(listener);
            }
        }
        return animator;
    }
    return ObjectAnimator.ofFloat(null, View.ALPHA, 1, 1);
}

From source file:com.stanleyidesis.quotograph.ui.activity.LWQSettingsActivity.java

Animator generateAnimator(View target, boolean dismiss, long startDelay) {
    float[] fadeIn = new float[] { 0f, 1f };
    float[] fadeOut = new float[] { 1f, 0f };
    final ObjectAnimator propAnimator = ObjectAnimator.ofPropertyValuesHolder(target,
            PropertyValuesHolder.ofFloat(View.ALPHA, dismiss ? fadeOut : fadeIn),
            PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, dismiss ? (target.getHeight() * 2f) : 0f));
    propAnimator.setStartDelay(startDelay);
    propAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
    propAnimator.setDuration(240);/*from  ww  w  . ja v a2s  . c om*/
    return propAnimator;
}

From source file:nu.yona.timepicker.time.TimePickerDialog.java

private void setCurrentItemShowing(int index, boolean animateCircle, boolean delayLabelAnimate,
        boolean announce) {
    TextView labelToAnimate;/*from   w  ww.  j a v  a2  s .  c  o m*/
    if (tabHost.getCurrentTab() == 0) {
        mTimePicker.setCurrentItemShowing(index, animateCircle);

        switch (index) {
        case HOUR_INDEX:
            int hours = mTimePicker.getHours();
            if (!mIs24HourMode) {
                hours = hours % 12;
            }
            mTimePicker.setContentDescription(mHourPickerDescription + ": " + hours);
            if (announce) {
                Utils.tryAccessibilityAnnounce(mTimePicker, mSelectHours);
            }
            labelToAnimate = mHourView;
            break;
        case MINUTE_INDEX:
            int minutes = mTimePicker.getMinutes();
            mTimePicker.setContentDescription(mMinutePickerDescription + ": " + minutes);
            if (announce) {
                Utils.tryAccessibilityAnnounce(mTimePicker, mSelectMinutes);
            }
            labelToAnimate = mMinuteView;
            break;
        default:
            int seconds = mTimePicker.getSeconds();
            mTimePicker.setContentDescription(mSecondPickerDescription + ": " + seconds);
            if (announce) {
                Utils.tryAccessibilityAnnounce(mTimePicker, mSelectSeconds);
            }
            labelToAnimate = mSecondView;
        }

        int hourColor = (index == HOUR_INDEX) ? mSelectedColor : mUnselectedColor;
        int minuteColor = (index == MINUTE_INDEX) ? mSelectedColor : mUnselectedColor;
        int secondColor = (index == SECOND_INDEX) ? mSelectedColor : mUnselectedColor;
        mHourView.setTextColor(hourColor);
        mMinuteView.setTextColor(minuteColor);
        mSecondView.setTextColor(secondColor);

        ObjectAnimator pulseAnimator = Utils.getPulseAnimator(labelToAnimate, 0.85f, 1.1f);
        if (delayLabelAnimate) {
            pulseAnimator.setStartDelay(PULSE_ANIMATOR_DELAY);
        }
        pulseAnimator.start();
    } else {
        mTimePickerEnd.setCurrentItemShowing(index, animateCircle);

        switch (index) {
        case HOUR_INDEX:
            int hours = mTimePickerEnd.getHours();
            if (!mIs24HourMode) {
                hours = hours % 12;
            }
            mTimePickerEnd.setContentDescription(mHourPickerDescription + ": " + hours);
            if (announce) {
                Utils.tryAccessibilityAnnounce(mTimePickerEnd, mSelectHours);
            }
            labelToAnimate = mHourViewEnd;
            break;
        case MINUTE_INDEX:
            int minutes = mTimePickerEnd.getMinutes();
            mTimePickerEnd.setContentDescription(mMinutePickerDescription + ": " + minutes);
            if (announce) {
                Utils.tryAccessibilityAnnounce(mTimePickerEnd, mSelectMinutes);
            }
            labelToAnimate = mMinuteViewEnd;
            break;
        default:
            int seconds = mTimePickerEnd.getSeconds();
            mTimePickerEnd.setContentDescription(mSecondPickerDescription + ": " + seconds);
            if (announce) {
                Utils.tryAccessibilityAnnounce(mTimePickerEnd, mSelectSeconds);
            }
            labelToAnimate = mSecondView;
        }
        int hourColor = (index == HOUR_INDEX) ? mSelectedColor : mUnselectedColor;
        int minuteColor = (index == MINUTE_INDEX) ? mSelectedColor : mUnselectedColor;
        int secondColor = (index == SECOND_INDEX) ? mSelectedColor : mUnselectedColor;
        mHourViewEnd.setTextColor(hourColor);
        mMinuteViewEnd.setTextColor(minuteColor);
        mSecondView.setTextColor(secondColor);

        ObjectAnimator pulseAnimator = Utils.getPulseAnimator(labelToAnimate, 0.85f, 1.1f);
        if (delayLabelAnimate) {
            pulseAnimator.setStartDelay(PULSE_ANIMATOR_DELAY);
        }
        pulseAnimator.start();
    }
}