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.borax12.materialdaterangepicker.date.DatePickerDialog.java

private void setCurrentView(final int viewIndex) {
    long millis = mCalendar.getTimeInMillis();
    long millisEnd = mCalendarEnd.getTimeInMillis();

    switch (viewIndex) {
    case MONTH_AND_DAY_VIEW:
        ObjectAnimator pulseAnimator = Utils.getPulseAnimator(mMonthAndDayView, 0.9f, 1.05f);
        ObjectAnimator pulseAnimatorTwo = Utils.getPulseAnimator(mMonthAndDayViewEnd, 0.9f, 1.05f);
        if (mDelayAnimation) {
            pulseAnimator.setStartDelay(ANIMATION_DELAY);
            pulseAnimatorTwo.setStartDelay(ANIMATION_DELAY);
            mDelayAnimation = false;//from  w  ww.  j a  va2 s  .  c o m
        }
        mDayPickerView.onDateChanged();
        if (mCurrentView != viewIndex) {
            mMonthAndDayView.setSelected(true);
            mMonthAndDayViewEnd.setSelected(true);
            mYearView.setSelected(false);
            mYearViewEnd.setSelected(false);
            mAnimator.setDisplayedChild(MONTH_AND_DAY_VIEW);
            mAnimatorEnd.setDisplayedChild(MONTH_AND_DAY_VIEW);
            mCurrentView = viewIndex;
        }
        pulseAnimator.start();
        pulseAnimatorTwo.start();

        int flags = DateUtils.FORMAT_SHOW_DATE;
        String dayString = DateUtils.formatDateTime(getActivity(), millis, flags);
        String dayStringEnd = DateUtils.formatDateTime(getActivity(), millisEnd, flags);
        mAnimator.setContentDescription(mDayPickerDescription + ": " + dayString);
        mAnimatorEnd.setContentDescription(mDayPickerDescription + ": " + dayStringEnd);
        Utils.tryAccessibilityAnnounce(mAnimator, mSelectDay);
        Utils.tryAccessibilityAnnounce(mAnimatorEnd, mSelectDay);
        break;
    case YEAR_VIEW:
        pulseAnimator = Utils.getPulseAnimator(mYearView, 0.85f, 1.1f);
        pulseAnimatorTwo = Utils.getPulseAnimator(mYearViewEnd, 0.85f, 1.1f);
        if (mDelayAnimation) {
            pulseAnimator.setStartDelay(ANIMATION_DELAY);
            pulseAnimatorTwo.setStartDelay(ANIMATION_DELAY);
            mDelayAnimation = false;
        }
        mYearPickerView.onDateChanged();
        mYearPickerViewEnd.onDateChanged();
        if (mCurrentView != viewIndex) {
            mMonthAndDayView.setSelected(false);
            mYearView.setSelected(true);
            mAnimator.setDisplayedChild(YEAR_VIEW);
            mCurrentView = viewIndex;

            mMonthAndDayViewEnd.setSelected(false);
            mYearViewEnd.setSelected(true);
            mAnimatorEnd.setDisplayedChild(YEAR_VIEW);
            mCurrentViewEnd = viewIndex;
        }
        pulseAnimator.start();
        pulseAnimatorTwo.start();

        CharSequence yearString = YEAR_FORMAT.format(millis);
        CharSequence yearStringEnd = YEAR_FORMAT.format(millisEnd);
        mAnimator.setContentDescription(mYearPickerDescription + ": " + yearString);
        mAnimatorEnd.setContentDescription(mYearPickerDescription + ": " + yearStringEnd);
        Utils.tryAccessibilityAnnounce(mAnimator, mSelectYear);
        Utils.tryAccessibilityAnnounce(mAnimatorEnd, mSelectYear);
        break;
    }
}

From source file:com.serenegiant.aceparrot.BaseFragment.java

/**
 * 01??(View)??/*from w  w w.j av a  2  s  . c  om*/
 * @param target
 * @param startDelay
 */
@SuppressLint("NewApi")
protected final void fadeIn(final View target, final long duration, final long startDelay) {
    //      if (DEBUG) Log.v(TAG, "fadeIn:target=" + target);
    if (target == null)
        return;
    target.clearAnimation();
    target.setVisibility(View.VISIBLE);
    target.setTag(R.id.anim_type, ANIM_FADE_IN); // ???
    target.setScaleX(1.0f);
    target.setScaleY(1.0f);
    target.setAlpha(0.0f);
    final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(target, "alpha", 0f, 1f);
    objectAnimator.addListener(mAnimatorListener);
    if (BuildCheck.isJellyBeanMR2())
        objectAnimator.setAutoCancel(true); // API >= 18 ??????Animator????
    objectAnimator.setDuration(duration > 0 ? duration : 500); // 0.5???
    objectAnimator.setStartDelay(startDelay > 0 ? startDelay : 0); // ???
    objectAnimator.start(); // 
}

From source file:com.serenegiant.aceparrot.BaseFragment.java

/**
 * 01??(View)??/* w ww.  ja  v a 2  s .com*/
 * @param target
 * @param startDelay
 */
@SuppressLint("NewApi")
protected final void zoomIn(final View target, final long duration, final long startDelay) {
    //      if (DEBUG) Log.v(TAG, "zoomIn:target=" + target);
    if (target == null)
        return;
    target.clearAnimation();
    target.setVisibility(View.VISIBLE);
    target.setTag(R.id.anim_type, ANIM_ZOOM_IN); // ???
    target.setScaleX(0.0f);
    target.setScaleY(0.0f);
    target.setAlpha(1.0f);
    final PropertyValuesHolder scale_x = PropertyValuesHolder.ofFloat("scaleX", 0.01f, 1f);
    final PropertyValuesHolder scale_y = PropertyValuesHolder.ofFloat("scaleY", 0.01f, 1f);
    final ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(target, scale_x, scale_y);
    objectAnimator.addListener(mAnimatorListener);
    if (BuildCheck.isJellyBeanMR2())
        objectAnimator.setAutoCancel(true); // API >= 18 ??????Animator????
    objectAnimator.setDuration(duration > 0 ? duration : 500); // 0.5???
    objectAnimator.setStartDelay(startDelay > 0 ? startDelay : 0); // ???
    objectAnimator.start(); // 
}

From source file:com.serenegiant.aceparrot.BaseFragment.java

/**
 * 10??(View)??/*from w w  w.  j a  v a2  s  .  c  o m*/
 * @param target
 * @param startDelay
 */
@SuppressLint("NewApi")
protected final void zoomOut(final View target, final long duration, final long startDelay) {
    //      if (DEBUG) Log.v(TAG, "zoomIn:target=" + target);
    if (target == null)
        return;
    target.clearAnimation();
    target.setVisibility(View.VISIBLE);
    target.setTag(R.id.anim_type, ANIM_ZOOM_OUT); // ???
    target.setScaleX(1.0f);
    target.setScaleY(1.0f);
    target.setAlpha(1.0f);
    final PropertyValuesHolder scale_x = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f);
    final PropertyValuesHolder scale_y = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f);
    final ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(target, scale_x, scale_y);
    objectAnimator.addListener(mAnimatorListener);
    if (BuildCheck.isJellyBeanMR2())
        objectAnimator.setAutoCancel(true); // API >= 18 ??????Animator????
    objectAnimator.setDuration(duration > 0 ? duration : 500); // 0.5???
    objectAnimator.setStartDelay(startDelay > 0 ? startDelay : 0); // ???
    objectAnimator.start(); // 
}

From source file:com.serenegiant.aceparrot.BaseFragment.java

/**
 * 10??(View)??//from ww w  .j a  v a2  s .c o m
 * @param target
 * @param startDelay
 */
@SuppressLint("NewApi")
protected final void fadeOut(final View target, final long duration, final long startDelay) {
    //      if (DEBUG) Log.v(TAG, "fadeOut,target=" + target);
    if (target == null)
        return;
    target.clearAnimation();
    if (target.getVisibility() == View.VISIBLE) {
        target.setTag(R.id.anim_type, ANIM_FADE_OUT); // ??
        target.setScaleX(1.0f);
        target.setScaleY(1.0f);
        target.setAlpha(1.0f);
        final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(target, "alpha", 1f, 0f);
        objectAnimator.addListener(mAnimatorListener);
        if (BuildCheck.isAndroid4_3())
            objectAnimator.setAutoCancel(true); // API >= 18 ??????Animator????
        objectAnimator.setDuration(duration > 0 ? duration : 500); // 0.5???
        objectAnimator.setStartDelay(startDelay > 0 ? startDelay : 0); // ???
        objectAnimator.start(); // 
    }
}

From source file:com.serenegiant.aceparrot.BaseFragment.java

/**
 * start?stop????/*  w ww . jav a 2s .  c o  m*/
 * @param target
 * @param type ???????
 * @param start [0.0f-1.0f]
 * @param stop  [0.0f-1.0f]
 * @param duration []
 * @param startDelay []
 */
@SuppressLint("NewApi")
protected final void alphaAnimation(final View target, final int type, final float start, final float stop,
        final long duration, final long startDelay, final AnimationCallback callback) {
    //      if (DEBUG) Log.v(TAG, "fadeOut,target=" + target);
    if (target == null)
        return;
    target.clearAnimation();
    if (target.getVisibility() == View.VISIBLE) {
        target.setTag(R.id.anim_type, type);
        target.setTag(R.id.anim_callback, callback);
        target.setScaleX(1.0f);
        target.setScaleY(1.0f);
        target.setAlpha(start);
        final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(target, "alpha", start, stop);
        objectAnimator.addListener(mAnimatorListener);
        if (BuildCheck.isAndroid4_3())
            objectAnimator.setAutoCancel(true); // API >= 18 ??????Animator????
        objectAnimator.setDuration(duration > 0 ? duration : 500); // 0.5???
        objectAnimator.setStartDelay(startDelay > 0 ? startDelay : 0); // ???
        objectAnimator.start(); // 
    }
}

From source file:com.yekertech.tvbarsetting.dialog.DialogFragment.java

private void performEntryTransition() {
    final View dialogView = getView();
    final View contentView = (View) dialogView.getTag(R.id.content_fragment);
    final View actionContainerView = dialogView.findViewById(R.id.action_fragment);

    mIntroAnimationInProgress = true;/*from w  w w  .j av a  2s. c o  m*/

    // Fade out the old activity.
    getActivity().overridePendingTransition(0, R.anim.lb_dialog_fade_out);

    int bgColor = contentView.getContext().getResources().getColor(R.color.lb_dialog_activity_background);
    final ColorDrawable bgDrawable = new ColorDrawable();
    bgDrawable.setColor(bgColor);
    bgDrawable.setAlpha(0);
    dialogView.setBackground(bgDrawable);
    dialogView.setVisibility(View.INVISIBLE);

    runDelayedAnim(new Runnable() {
        @Override
        public void run() {
            if (!isAdded()) {
                // We have been detached before this could run,
                // so just bail
                return;
            }

            dialogView.setVisibility(View.VISIBLE);

            // Fade in the activity background protection
            ObjectAnimator oa = ObjectAnimator.ofInt(bgDrawable, "alpha", 255);
            oa.setDuration(ANIMATE_IN_DURATION);
            oa.setStartDelay(SECONDARY_ANIMATE_DELAY);
            oa.setInterpolator(new DecelerateInterpolator(1.0f));
            oa.start();

            boolean isRtl = ViewCompat.getLayoutDirection(contentView) == ViewCompat.LAYOUT_DIRECTION_RTL;
            int startDist = isRtl ? SLIDE_IN_DISTANCE : -SLIDE_IN_DISTANCE;
            int endDist = isRtl ? -actionContainerView.getMeasuredWidth()
                    : actionContainerView.getMeasuredWidth();

            // Fade in and slide in the ContentFragment
            // TextViews from the start.
            prepareAndAnimateView((View) contentView.getTag(R.id.title), startDist, false);
            prepareAndAnimateView((View) contentView.getTag(R.id.breadcrumb), startDist, false);
            prepareAndAnimateView((View) contentView.getTag(R.id.description), startDist, false);

            // Fade in and slide in the ActionFragment from the
            // end.
            prepareAndAnimateView(actionContainerView, endDist, false);
            prepareAndAnimateView((View) contentView.getTag(R.id.icon), startDist, true);

            // Fade in the selector.
            if (mSelectorAnimator != null) {
                mSelectorAnimator.fadeIn();
            }
        }
    });
}

From source file:co.ceryle.radiorealbutton.library.RadioRealButtonGroup.java

private ObjectAnimator createAnimator(View view, String property, float value, boolean hasDelay,
        boolean hasDuration) {
    ObjectAnimator animator = ObjectAnimator.ofFloat(view, property, value);
    animator.setInterpolator(interpolatorSelector);
    if (hasDuration)
        animator.setDuration(animateSelectorDuration);
    else/*  w w  w. j  a  va2 s .  c  o m*/
        animator.setDuration(0);
    if (hasDelay)
        animator.setStartDelay(animateSelectorDelay);
    return animator;
}

From source file:com.android.tv.settings.dialog.DialogFragment.java

private void performEntryTransition() {
    final View dialogView = getView();
    final View contentView = (View) dialogView.getTag(R.id.content_fragment);
    final View actionContainerView = dialogView.findViewById(R.id.action_fragment);

    mIntroAnimationInProgress = true;// w w w.ja  v  a 2 s . c o m

    // Fade out the old activity.
    getActivity().overridePendingTransition(0, R.anim.lb_dialog_fade_out);

    int bgColor = contentView.getContext().getResources().getColor(R.color.lb_dialog_activity_background);
    final ColorDrawable bgDrawable = new ColorDrawable();
    bgDrawable.setColor(bgColor);
    bgDrawable.setAlpha(0);
    dialogView.setBackground(bgDrawable);
    dialogView.setVisibility(View.INVISIBLE);

    runDelayedAnim(new Runnable() {
        @Override
        public void run() {
            if (!isAdded()) {
                // We have been detached before this could run,
                // so just bail
                return;
            }

            dialogView.setVisibility(View.VISIBLE);

            // Fade in the activity background protection
            ObjectAnimator oa = ObjectAnimator.ofInt(bgDrawable, "alpha", 255);
            oa.setDuration(ANIMATE_IN_DURATION);
            oa.setStartDelay(SECONDARY_ANIMATE_DELAY);
            oa.setInterpolator(new DecelerateInterpolator(1.0f));
            oa.start();

            boolean isRtl = ViewCompat.getLayoutDirection(contentView) == View.LAYOUT_DIRECTION_RTL;
            int startDist = isRtl ? SLIDE_IN_DISTANCE : -SLIDE_IN_DISTANCE;
            int endDist = isRtl ? -actionContainerView.getMeasuredWidth()
                    : actionContainerView.getMeasuredWidth();

            // Fade in and slide in the ContentFragment
            // TextViews from the start.
            prepareAndAnimateView((View) contentView.getTag(R.id.title), startDist, false);
            prepareAndAnimateView((View) contentView.getTag(R.id.breadcrumb), startDist, false);
            prepareAndAnimateView((View) contentView.getTag(R.id.description), startDist, false);

            // Fade in and slide in the ActionFragment from the
            // end.
            prepareAndAnimateView(actionContainerView, endDist, false);
            prepareAndAnimateView((View) contentView.getTag(R.id.icon), startDist, true);

            // Fade in the selector.
            if (mSelectorAnimator != null) {
                mSelectorAnimator.fadeIn();
            }
        }
    });
}

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

private void setCurrentItemShowing(int index, boolean animateCircle, boolean delayLabelAnimate,
        boolean announce) {
    if (tabHost.getCurrentTab() == 0) {
        mTimePicker.setCurrentItemShowing(index, animateCircle);

        TextView labelToAnimate;//from   w w w. j  a  v a  2 s  .c  om
        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();
    } else {
        mTimePickerEnd.setCurrentItemShowing(index, animateCircle);

        TextView labelToAnimate;
        if (index == HOUR_INDEX) {
            int hours = mTimePickerEnd.getHours();
            if (!mIs24HourMode) {
                hours = hours % 12;
            }
            mTimePickerEnd.setContentDescription(mHourPickerDescription + ": " + hours);
            if (announce) {
                Utils.tryAccessibilityAnnounce(mTimePickerEnd, mSelectHours);
            }
            labelToAnimate = mHourViewEnd;
        } else {
            int minutes = mTimePickerEnd.getMinutes();
            mTimePickerEnd.setContentDescription(mMinutePickerDescription + ": " + minutes);
            if (announce) {
                Utils.tryAccessibilityAnnounce(mTimePickerEnd, mSelectMinutes);
            }
            labelToAnimate = mMinuteViewEnd;
        }

        int hourColor = (index == HOUR_INDEX) ? mSelectedColor : mUnselectedColor;
        int minuteColor = (index == MINUTE_INDEX) ? mSelectedColor : mUnselectedColor;
        mHourViewEnd.setTextColor(hourColor);
        mMinuteViewEnd.setTextColor(minuteColor);

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

}