use of com.nineoldandroids.animation.ObjectAnimator in project android-betterpickers by code-troopers.
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;
}
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 {
int hourAlpha = (index == HOUR_INDEX) ? 255 : 0;
int minuteAlpha = (index == MINUTE_INDEX) ? 255 : 0;
ViewHelper.setAlpha(mHourRadialTextsView, hourAlpha);
ViewHelper.setAlpha(mHourRadialSelectorView, hourAlpha);
ViewHelper.setAlpha(mMinuteRadialTextsView, minuteAlpha);
ViewHelper.setAlpha(mMinuteRadialSelectorView, minuteAlpha);
}
}
use of com.nineoldandroids.animation.ObjectAnimator in project android-betterpickers by code-troopers.
the class Utils method getPulseAnimator.
/**
* Render an animator to pulsate a view in place.
* @param labelToAnimate the view to pulsate.
* @return The animator object. Use .start() to begin.
*/
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(AnimatorProxy.NEEDS_PROXY ? AnimatorProxy.wrap(labelToAnimate) : labelToAnimate, scaleX, scaleY);
pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION);
return pulseAnimator;
}
use of com.nineoldandroids.animation.ObjectAnimator in project PaymentKit-Droid by brendanw.
the class AnimUtils method getShakeAnimation.
/**
* @param shouldResetTextColor if true make sure you end the previous animation before starting this one.
*/
public static ObjectAnimator getShakeAnimation(final TextView textView, final boolean shouldResetTextColor) {
final int textColor = textView.getCurrentTextColor();
textView.setTextColor(Color.RED);
ObjectAnimator shakeAnim = ObjectAnimator.ofFloat(textView, "translationX", -16);
shakeAnim.setDuration(SHAKE_DURATION);
shakeAnim.setInterpolator(new CycleInterpolator(2.0f));
shakeAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator anim) {
if (shouldResetTextColor) {
textView.setTextColor(textColor);
}
}
});
return shakeAnim;
}
use of com.nineoldandroids.animation.ObjectAnimator in project Carbon by ZieIony.
the class RippleForeground method createSoftwareExit.
@Override
protected Animator createSoftwareExit() {
final int radiusDuration;
final int originDuration;
final int opacityDuration;
if (mIsBounded) {
computeBoundedTargetValues();
radiusDuration = BOUNDED_RADIUS_EXIT_DURATION;
originDuration = BOUNDED_ORIGIN_EXIT_DURATION;
opacityDuration = BOUNDED_OPACITY_EXIT_DURATION;
} else {
radiusDuration = getRadiusExitDuration();
originDuration = radiusDuration;
opacityDuration = getOpacityExitDuration();
}
final ObjectAnimator tweenRadius = ObjectAnimator.ofFloat(this, TWEEN_RADIUS, 1);
AnimatorsCompat.setAutoCancel(tweenRadius);
//tweenRadius.setAutoCancel(true);
tweenRadius.setDuration(radiusDuration);
tweenRadius.setInterpolator(DECELERATE_INTERPOLATOR);
final ObjectAnimator tweenOrigin = ObjectAnimator.ofFloat(this, TWEEN_ORIGIN, 1);
AnimatorsCompat.setAutoCancel(tweenOrigin);
//tweenOrigin.setAutoCancel(true);
tweenOrigin.setDuration(originDuration);
tweenOrigin.setInterpolator(DECELERATE_INTERPOLATOR);
final ObjectAnimator opacity = ObjectAnimator.ofFloat(this, OPACITY, 0);
AnimatorsCompat.setAutoCancel(opacity);
//opacity.setAutoCancel(true);
opacity.setDuration(opacityDuration);
opacity.setInterpolator(LINEAR_INTERPOLATOR);
final AnimatorSet set = new AnimatorSet();
set.play(tweenOrigin).with(tweenRadius).with(opacity);
set.addListener(mAnimationListener);
return set;
}
use of com.nineoldandroids.animation.ObjectAnimator in project Carbon by ZieIony.
the class AnimatorsCompat method hasSameTargetAndProperties.
private static boolean hasSameTargetAndProperties(ObjectAnimator self, @Nullable Animator anim) {
if (anim instanceof ObjectAnimator) {
PropertyValuesHolder[] theirValues = ((ObjectAnimator) anim).getValues();
PropertyValuesHolder[] selfValues = self.getValues();
if (((ObjectAnimator) anim).getTarget() == self.getTarget() && selfValues.length == theirValues.length) {
final int length = selfValues.length;
for (int i = 0; i < length; ++i) {
PropertyValuesHolder pvhMine = selfValues[i];
PropertyValuesHolder pvhTheirs = theirValues[i];
if (pvhMine.getPropertyName() == null || !pvhMine.getPropertyName().equals(pvhTheirs.getPropertyName())) {
return false;
}
}
return true;
}
}
return false;
}
Aggregations