Search in sources :

Example 51 with ObjectAnimator

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();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) ArgbEvaluator(android.animation.ArgbEvaluator)

Example 52 with ObjectAnimator

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();
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener) ValueAnimator(android.animation.ValueAnimator) View(android.view.View)

Example 53 with ObjectAnimator

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();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) TargetApi(android.annotation.TargetApi)

Example 54 with ObjectAnimator

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);
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Test(org.junit.Test)

Example 55 with ObjectAnimator

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;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) View(android.view.View)

Aggregations

ObjectAnimator (android.animation.ObjectAnimator)791 Animator (android.animation.Animator)313 AnimatorSet (android.animation.AnimatorSet)214 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)208 PropertyValuesHolder (android.animation.PropertyValuesHolder)128 ValueAnimator (android.animation.ValueAnimator)111 View (android.view.View)102 Paint (android.graphics.Paint)68 TextView (android.widget.TextView)49 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)48 ViewGroup (android.view.ViewGroup)45 Rect (android.graphics.Rect)35 LinearInterpolator (android.view.animation.LinearInterpolator)35 ImageView (android.widget.ImageView)31 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)30 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)29 OvershootInterpolator (android.view.animation.OvershootInterpolator)29 ArrayList (java.util.ArrayList)22 TargetApi (android.annotation.TargetApi)21 Interpolator (android.view.animation.Interpolator)20