use of android.animation.ObjectAnimator in project iosched by google.
the class SessionDetailFragment method returnTransitionStarted.
private void returnTransitionStarted() {
// Fade the header bar for a smoother transition.
final ObjectAnimator color = ObjectAnimator.ofInt(mHeaderBox, UIUtils.BACKGROUND_COLOR, ContextCompat.getColor(getContext(), R.color.background));
color.setEvaluator(new ArgbEvaluator());
color.setDuration(200L);
color.start();
// Also fade out the toolbar and FAB
mToolbar.animate().alpha(0f).setDuration(200L).start();
mAddScheduleFab.hide();
}
use of android.animation.ObjectAnimator in project NotificationPeekPort by lzanita09.
the class SwipeHelper method dismissChild.
/**
* @param view The view to be dismissed
* @param velocity The desired pixels/second speed at which the view should move
*/
public void dismissChild(final View view, float velocity) {
final View animView = mCallback.getChildContentView(view);
final boolean canAnimViewBeDismissed = mCallback.canChildBeDismissed(view);
float newPos;
if (velocity < 0 || (velocity == 0 && getTranslation(animView) < 0) || // if we use the Menu to dismiss an item in landscape, animate up
(velocity == 0 && getTranslation(animView) == 0 && mSwipeDirection == Y)) {
newPos = -getSize(animView);
} else {
newPos = getSize(animView);
}
int duration = MAX_ESCAPE_ANIMATION_DURATION;
if (velocity != 0) {
duration = Math.min(duration, (int) (Math.abs(newPos - getTranslation(animView)) * 1000f / Math.abs(velocity)));
} else {
duration = DEFAULT_ESCAPE_ANIMATION_DURATION;
}
animView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
ObjectAnimator anim = createTranslationAnimation(animView, newPos);
anim.setInterpolator(sLinearInterpolator);
anim.setDuration(duration);
anim.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
mCallback.onChildDismissed(view);
animView.setLayerType(View.LAYER_TYPE_NONE, null);
}
});
anim.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
updateAlphaFromOffset(animView, canAnimViewBeDismissed);
}
});
anim.start();
}
use of android.animation.ObjectAnimator in project AdvancedMaterialDrawer by madcyph3r.
the class MaterialRippleLayout method startRipple.
@TargetApi(14)
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();
}
use of android.animation.ObjectAnimator in project robolectric by robolectric.
the class ShadowObjectAnimatorTest method start_shouldRunAnimation.
@Test
public void start_shouldRunAnimation() {
final ObjectAnimator animator = ObjectAnimator.ofInt(target, "transparency", 0, 1, 2, 3, 4);
Robolectric.getForegroundThreadScheduler().pause();
animator.setDuration(1000);
animator.addListener(listener);
animator.start();
verify(listener).onAnimationStart(animator);
assertThat(target.getTransparency()).isEqualTo(0);
Robolectric.flushForegroundThreadScheduler();
verify(listener).onAnimationEnd(animator);
assertThat(target.getTransparency()).isEqualTo(4);
}
use of android.animation.ObjectAnimator in project TransitionPlayer by linfaxin.
the class AbsChangeValue method createAnimator.
@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
if (startValues == null || endValues == null) {
return null;
}
AnimatorSet animatorSet = new AnimatorSet();
final View view = endValues.view;
for (String valueName : valueNames) {
Object startValue = startValues.values.get(propertyPrefix + valueName);
Object endValue = endValues.values.get(propertyPrefix + valueName);
if (startValue != null && endValue != null && startValue.getClass() != endValue.getClass())
continue;
Class c = null;
if (startValue != null)
c = startValue.getClass();
else if (endValue != null)
c = endValue.getClass();
if (c == null)
continue;
ObjectAnimator animator;
if (c == Float.class || c == float.class) {
animator = ObjectAnimator.ofFloat(view, valueName, (Float) startValue, (Float) endValue);
animatorSet.playTogether(animator);
} else if (c == Integer.class || c == int.class) {
animator = ObjectAnimator.ofInt(view, valueName, (Integer) startValue, (Integer) endValue);
animatorSet.playTogether(animator);
} else {
animator = ObjectAnimator.ofObject(view, valueName, typeEvaluator, startValue, endValue);
animatorSet.playTogether(animator);
}
setPropertyValue(view, valueName, startValue);
if (typeEvaluator != null)
animator.setEvaluator(typeEvaluator);
}
ArrayList<Animator> animators = animatorSet.getChildAnimations();
if (animators != null && animators.size() > 0) {
if (animators.size() == 1)
return animators.get(0);
return animatorSet;
}
return null;
}
Aggregations