Java Code Examples for com.nineoldandroids.animation.ObjectAnimator#setStartDelay()

The following examples show how to use com.nineoldandroids.animation.ObjectAnimator#setStartDelay() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnimUtil.java    From PullRefreshView with Apache License 2.0 5 votes vote down vote up
public static Animator startRotation(View view, float toRotation, long duration, long startDelay, int times) {
    ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "rotation", ViewHelper.getRotation(view), toRotation).setDuration(duration);
    objectAnimator.setStartDelay(startDelay);
    objectAnimator.setRepeatCount(times);
    objectAnimator.setInterpolator(new LinearInterpolator());
    objectAnimator.start();
    return objectAnimator;
}
 
Example 2
Source File: AnimUtil.java    From PullRefreshView with Apache License 2.0 5 votes vote down vote up
public static Animator startShow(View view, float fromAlpha, long duration, long startDelay) {
    ViewHelper.setAlpha(view, fromAlpha);
    view.setVisibility(View.VISIBLE);
    ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "alpha", fromAlpha, 1f).setDuration(duration);
    objectAnimator.setStartDelay(startDelay);
    objectAnimator.start();
    return objectAnimator;
}
 
Example 3
Source File: AnimUtil.java    From PullRefreshView with Apache License 2.0 5 votes vote down vote up
public static Animator startHide(final View view, long duration, long startDelay) {
    view.setVisibility(View.VISIBLE);
    ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "alpha", ViewHelper.getAlpha(view), 0f).setDuration(duration);
    objectAnimator.setStartDelay(startDelay);
    objectAnimator.start();
    return objectAnimator;
}
 
Example 4
Source File: AnimUtil.java    From PullRefreshView with Apache License 2.0 5 votes vote down vote up
public static Animator startScale(final View view, float toScale, long duration, long startDelay, Interpolator setInterpolator) {
    ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "scaleX", ViewHelper.getScaleX(view), toScale).setDuration(duration);
    objectAnimator.setStartDelay(startDelay);
    objectAnimator.setInterpolator(setInterpolator);
    objectAnimator.start();
    objectAnimator = ObjectAnimator.ofFloat(view, "scaleY", ViewHelper.getScaleY(view), toScale).setDuration(duration);
    objectAnimator.setStartDelay(startDelay);
    objectAnimator.setInterpolator(setInterpolator);
    objectAnimator.start();
    return objectAnimator;
}
 
Example 5
Source File: AnimUtil.java    From PullRefreshView with Apache License 2.0 5 votes vote down vote up
public static Animator startScale(final View view, float fromScale, float toScale, long duration, long startDelay, Interpolator setInterpolator) {
    ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "scaleX", fromScale, toScale).setDuration(duration);
    objectAnimator.setStartDelay(startDelay);
    objectAnimator.setInterpolator(setInterpolator);
    objectAnimator.start();
    objectAnimator = ObjectAnimator.ofFloat(view, "scaleY", fromScale, toScale).setDuration(duration);
    objectAnimator.setStartDelay(startDelay);
    objectAnimator.setInterpolator(setInterpolator);
    objectAnimator.start();
    return objectAnimator;
}
 
Example 6
Source File: Ripple.java    From Mover with Apache License 2.0 5 votes vote down vote up
/**
 * Starts the enter animation.
 */
public void enter() {
    cancel();

    final int radiusDuration = (int)
            (1000 * Math.sqrt(mOuterRadius / WAVE_TOUCH_DOWN_ACCELERATION * mDensity) + 0.5);

    final ObjectAnimator radius = ObjectAnimator.ofFloat(this, "radiusGravity", 1);
    radius.setAutoCancel(true);
    radius.setDuration(radiusDuration);
    radius.setInterpolator(LINEAR_INTERPOLATOR);
    radius.setStartDelay(RIPPLE_ENTER_DELAY);

    final ObjectAnimator cX = ObjectAnimator.ofFloat(this, "xGravity", 1);
    cX.setAutoCancel(true);
    cX.setDuration(radiusDuration);
    cX.setInterpolator(LINEAR_INTERPOLATOR);
    cX.setStartDelay(RIPPLE_ENTER_DELAY);

    final ObjectAnimator cY = ObjectAnimator.ofFloat(this, "yGravity", 1);
    cY.setAutoCancel(true);
    cY.setDuration(radiusDuration);
    cY.setInterpolator(LINEAR_INTERPOLATOR);
    cY.setStartDelay(RIPPLE_ENTER_DELAY);

    mAnimRadius = radius;
    mAnimX = cX;
    mAnimY = cY;

    // Enter animations always run on the UI thread, since it's unlikely
    // that anything interesting is happening until the user lifts their
    // finger.
    radius.start();
    cX.start();
    cY.start();
}
 
Example 7
Source File: RippleLayout.java    From ripplelayout with MIT License 5 votes vote down vote up
/**
 * 为每个RippleView添加动画效果,并且设置动画延时,每个视图启动动画的时间不同,就会产生波纹
 * 
 * @param rippleView
 * @param i 视图所在的索引
 */
private void addAnimToRippleView(RippleView rippleView, int i) {

    // x轴的缩放动画
    final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(rippleView, "scaleX",
            1.0f, mRippleScale);
    scaleXAnimator.setRepeatCount(ObjectAnimator.INFINITE);
    scaleXAnimator.setRepeatMode(ObjectAnimator.RESTART);
    scaleXAnimator.setStartDelay(i * mAnimDelay);
    scaleXAnimator.setDuration(mAnimDuration);
    mAnimatorList.add(scaleXAnimator);

    // y轴的缩放动画
    final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(rippleView, "scaleY",
            1.0f, mRippleScale);
    scaleYAnimator.setRepeatMode(ObjectAnimator.RESTART);
    scaleYAnimator.setRepeatCount(ObjectAnimator.INFINITE);
    scaleYAnimator.setStartDelay(i * mAnimDelay);
    scaleYAnimator.setDuration(mAnimDuration);
    mAnimatorList.add(scaleYAnimator);

    // 颜色的alpha渐变动画
    final ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(rippleView, "alpha", 1.0f,
            0f);
    alphaAnimator.setRepeatMode(ObjectAnimator.RESTART);
    alphaAnimator.setRepeatCount(ObjectAnimator.INFINITE);
    alphaAnimator.setDuration(mAnimDuration);
    alphaAnimator.setStartDelay(i * mAnimDelay);
    mAnimatorList.add(alphaAnimator);
}
 
Example 8
Source File: MaterialRippleLayoutNineOld.java    From AdvancedMaterialDrawer with Apache License 2.0 5 votes vote down vote up
private void startRipple(final Runnable animationEndRunnable) {
    if (eventCancelled) return;

    float endRadius = getEndRadius();

    cancelAnimations();

    rippleAnimator = new AnimatorSet();
    rippleAnimator.addListener(new AnimatorListenerAdapter() {
        @Override public void onAnimationEnd(Animator animation) {
            if (!ripplePersistent) {
                setRadius(0);
                setRippleAlpha(rippleAlpha);
            }
            if (animationEndRunnable != null && rippleDelayClick) {
                animationEndRunnable.run();
            }
            childView.setPressed(false);
        }
    });

    ObjectAnimator ripple = ObjectAnimator.ofFloat(this, radiusProperty, radius, endRadius);
    ripple.setDuration(rippleDuration);
    ripple.setInterpolator(new DecelerateInterpolator());
    ObjectAnimator fade = ObjectAnimator.ofInt(this, circleAlphaProperty, rippleAlpha, 0);
    fade.setDuration(rippleFadeDuration);
    fade.setInterpolator(new AccelerateInterpolator());
    fade.setStartDelay(rippleDuration - rippleFadeDuration - FADE_EXTRA_DELAY);

    if (ripplePersistent) {
        rippleAnimator.play(ripple);
    } else if (getRadius() > endRadius) {
        fade.setStartDelay(0);
        rippleAnimator.play(fade);
    } else {
        rippleAnimator.playTogether(ripple, fade);
    }
    rippleAnimator.start();
}
 
Example 9
Source File: AnimatedPathView.java    From google-io-2014-compat with Apache License 2.0 5 votes vote down vote up
public void reveal() {
    ObjectAnimator svgAnimator = ObjectAnimator.ofFloat(this, "phase", 1.0f, 0.0f);
    svgAnimator.setDuration(mDuration);
    svgAnimator.start();

    setFillAlpha(0.0f);

    ObjectAnimator fillAnimator = ObjectAnimator.ofFloat(this, "fillAlpha", 0.0f, 1.0f);
    fillAnimator.setDuration(mFillDuration);
    fillAnimator.setStartDelay(mFillOffset);
    fillAnimator.start();
}
 
Example 10
Source File: SwitchAnimationUtil.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void runAlphaAnimation(View view, long delay) {
	view.setAlpha(0);
	ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "alpha",
			0, 1);
	objectAnimator.setStartDelay(delay);
	objectAnimator.setDuration(mDuration);
	objectAnimator.setInterpolator(new LinearInterpolator());
	objectAnimator.start();
}
 
Example 11
Source File: TimePickerDialog.java    From DateTimepicker with Apache License 2.0 5 votes vote down vote up
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)? mBlue : mBlack;
    int minuteColor = (index == MINUTE_INDEX)? mBlue : mBlack;
    mHourView.setTextColor(hourColor);
    mMinuteView.setTextColor(minuteColor);

    ObjectAnimator pulseAnimator = Utils.getPulseAnimator(labelToAnimate, 0.85f, 1.1f);
    if (delayLabelAnimate) {
        pulseAnimator.setStartDelay(PULSE_ANIMATOR_DELAY);
    }
    pulseAnimator.start();
}
 
Example 12
Source File: DatePickerDialog.java    From DateTimepicker with Apache License 2.0 5 votes vote down vote up
private void setCurrentView(int currentView, boolean forceRefresh) {
	long timeInMillis = this.mCalendar.getTimeInMillis();
	switch (currentView) {
	case VIEW_DATE_PICKER_MONTH_DAY:
		ObjectAnimator monthDayAnim = Utils.getPulseAnimator(this.mMonthAndDayView, 0.9F, 1.05F);
		if (this.mDelayAnimation) {
			monthDayAnim.setStartDelay(500L);
			this.mDelayAnimation = false;
		}
		this.mDayPickerView.onDateChanged();
		if (this.mCurrentView != currentView || forceRefresh) {
			this.mMonthAndDayView.setSelected(true);
			this.mYearView.setSelected(false);
			this.mAnimator.setDisplayedChild(VIEW_DATE_PICKER_MONTH_DAY);
			this.mCurrentView = currentView;
		}
		monthDayAnim.start();
		String monthDayDesc = DateUtils.formatDateTime(getActivity(), timeInMillis, DateUtils.FORMAT_SHOW_DATE);
		this.mAnimator.setContentDescription(this.mDayPickerDescription + ": " + monthDayDesc);
		return;
	case VIEW_DATE_PICKER_YEAR:
		ObjectAnimator yearAnim = Utils.getPulseAnimator(this.mYearView, 0.85F, 1.1F);
		if (this.mDelayAnimation) {
			yearAnim.setStartDelay(500L);
			this.mDelayAnimation = false;
		}
		this.mYearPickerView.onDateChanged();
		if (this.mCurrentView != currentView  || forceRefresh) {
			this.mMonthAndDayView.setSelected(false);
			this.mYearView.setSelected(true);
			this.mAnimator.setDisplayedChild(VIEW_DATE_PICKER_YEAR);
			this.mCurrentView = currentView;
		}
		yearAnim.start();
		String dayDesc = YEAR_FORMAT.format(Long.valueOf(timeInMillis));
		this.mAnimator.setContentDescription(this.mYearPickerDescription + ": " + dayDesc);
	}

}
 
Example 13
Source File: DatePickerDialog.java    From Conquer with Apache License 2.0 4 votes vote down vote up
private void setCurrentView(int currentView, boolean forceRefresh) {
	long timeInMillis = mCalendar.getTimeInMillis();
	switch (currentView) {
	case MONTH_AND_DAY_VIEW:
		ObjectAnimator monthDayAnim = Utils.getPulseAnimator(mMonthAndDayView, 0.9F, 1.05F);
		if (mDelayAnimation) {
			monthDayAnim.setStartDelay(ANIMATION_DELAY);
			mDelayAnimation = false;
		}
		mDayPickerView.onDateChanged();
		if (mCurrentView != currentView || forceRefresh) {
			mMonthAndDayView.setSelected(true);
			mYearView.setSelected(false);
			mAnimator.setDisplayedChild(MONTH_AND_DAY_VIEW);
			mCurrentView = currentView;
		}
		monthDayAnim.start();
		String monthDayDesc = DateUtils.formatDateTime(getActivity(), timeInMillis, DateUtils.FORMAT_SHOW_DATE);
		mAnimator.setContentDescription(mDayPickerDescription + ": " + monthDayDesc);
           Utils.tryAccessibilityAnnounce(mAnimator, mSelectDay);
           break;
	case YEAR_VIEW:
		ObjectAnimator yearAnim = Utils.getPulseAnimator(mYearView, 0.85F, 1.1F);
		if (mDelayAnimation) {
			yearAnim.setStartDelay(ANIMATION_DELAY);
			mDelayAnimation = false;
		}
		mYearPickerView.onDateChanged();
		if (mCurrentView != currentView  || forceRefresh) {
			mMonthAndDayView.setSelected(false);
			mYearView.setSelected(true);
			mAnimator.setDisplayedChild(YEAR_VIEW);
			mCurrentView = currentView;
		}
		yearAnim.start();
		String dayDesc = YEAR_FORMAT.format(timeInMillis);
		mAnimator.setContentDescription(mYearPickerDescription + ": " + dayDesc);
           Utils.tryAccessibilityAnnounce(mAnimator, mSelectYear);
           break;
	}
}
 
Example 14
Source File: AnimUtil.java    From PullRefreshView with Apache License 2.0 4 votes vote down vote up
public static Animator startRotation(View view, float toRotation, long duration, long startDelay) {
    ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "rotation", ViewHelper.getRotation(view), toRotation).setDuration(duration);
    objectAnimator.setStartDelay(startDelay);
    objectAnimator.start();
    return objectAnimator;
}