Search in sources :

Example 31 with AnimatorSet

use of android.animation.AnimatorSet 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)

Example 32 with AnimatorSet

use of android.animation.AnimatorSet in project TransitionPlayer by linfaxin.

the class ChangeRotate method createAnimator.

@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
    if (startValues == null || endValues == null) {
        return null;
    }
    final View view = endValues.view;
    float startValue = (Float) startValues.values.get(PROPNAME_NAME);
    float startValueX = (Float) startValues.values.get(PROPNAME_NAME_X);
    float startValueY = (Float) startValues.values.get(PROPNAME_NAME_Y);
    float endValue = (Float) endValues.values.get(PROPNAME_NAME);
    float endValueX = (Float) endValues.values.get(PROPNAME_NAME_X);
    float endValueY = (Float) endValues.values.get(PROPNAME_NAME_Y);
    AnimatorSet animatorSet = new AnimatorSet();
    if (startValue != endValue) {
        view.setRotation(startValue);
        animatorSet.playTogether(ObjectAnimator.ofFloat(view, FIELD_NAME, startValue, endValue));
    }
    if (startValueX != endValueX) {
        view.setRotationX(startValueX);
        animatorSet.playTogether(ObjectAnimator.ofFloat(view, FIELD_NAME_X, startValueX, endValueX));
    }
    if (startValueY != endValueY) {
        view.setRotationY(startValueY);
        animatorSet.playTogether(ObjectAnimator.ofFloat(view, FIELD_NAME_Y, startValueY, endValueY));
    }
    if (animatorSet.getChildAnimations() != null && animatorSet.getChildAnimations().size() > 0) {
        return animatorSet;
    }
    return null;
}
Also used : AnimatorSet(android.animation.AnimatorSet) View(android.view.View)

Example 33 with AnimatorSet

use of android.animation.AnimatorSet in project TransitionPlayer by linfaxin.

the class ChangeScale method createAnimator.

@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
    if (startValues == null || endValues == null) {
        return null;
    }
    final View view = endValues.view;
    float startValueX = (Float) startValues.values.get(PROPNAME_NAME1);
    float startValueY = (Float) startValues.values.get(PROPNAME_NAME2);
    float endValueX = (Float) endValues.values.get(PROPNAME_NAME1);
    float endValueY = (Float) endValues.values.get(PROPNAME_NAME2);
    AnimatorSet animatorSet = new AnimatorSet();
    if (startValueX != endValueX) {
        view.setScaleX(startValueX);
        animatorSet.playTogether(ObjectAnimator.ofFloat(view, FIELD_NAME1, startValueX, endValueX));
    }
    if (startValueY != endValueY) {
        view.setScaleY(startValueY);
        animatorSet.playTogether(ObjectAnimator.ofFloat(view, FIELD_NAME2, startValueY, endValueY));
    }
    if (animatorSet.getChildAnimations() != null && animatorSet.getChildAnimations().size() > 0) {
        return animatorSet;
    }
    return null;
}
Also used : AnimatorSet(android.animation.AnimatorSet) View(android.view.View)

Example 34 with AnimatorSet

use of android.animation.AnimatorSet in project android-topeka by googlesamples.

the class QuizActivity method revealFragmentContainerLollipop.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void revealFragmentContainerLollipop(final View clickedView, final FrameLayout fragmentContainer) {
    prepareCircularReveal(clickedView, fragmentContainer);
    ViewCompat.animate(clickedView).scaleX(0).scaleY(0).alpha(0).setInterpolator(mInterpolator).setListener(new ViewPropertyAnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(View view) {
            fragmentContainer.setVisibility(View.VISIBLE);
            clickedView.setVisibility(View.GONE);
        }
    }).start();
    fragmentContainer.setVisibility(View.VISIBLE);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(mCircularReveal).with(mColorChange);
    animatorSet.start();
}
Also used : AnimatorSet(android.animation.AnimatorSet) ViewPropertyAnimatorListenerAdapter(android.support.v4.view.ViewPropertyAnimatorListenerAdapter) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) TargetApi(android.annotation.TargetApi)

Example 35 with AnimatorSet

use of android.animation.AnimatorSet in project InstaMaterial by frogermcs.

the class TakePhotoActivity method animateShutter.

private void animateShutter() {
    vShutter.setVisibility(View.VISIBLE);
    vShutter.setAlpha(0.f);
    ObjectAnimator alphaInAnim = ObjectAnimator.ofFloat(vShutter, "alpha", 0f, 0.8f);
    alphaInAnim.setDuration(100);
    alphaInAnim.setStartDelay(100);
    alphaInAnim.setInterpolator(ACCELERATE_INTERPOLATOR);
    ObjectAnimator alphaOutAnim = ObjectAnimator.ofFloat(vShutter, "alpha", 0.8f, 0f);
    alphaOutAnim.setDuration(200);
    alphaOutAnim.setInterpolator(DECELERATE_INTERPOLATOR);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playSequentially(alphaInAnim, alphaOutAnim);
    animatorSet.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            vShutter.setVisibility(View.GONE);
        }
    });
    animatorSet.start();
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) AnimatorSet(android.animation.AnimatorSet)

Aggregations

AnimatorSet (android.animation.AnimatorSet)491 ObjectAnimator (android.animation.ObjectAnimator)343 Animator (android.animation.Animator)285 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)144 View (android.view.View)109 ValueAnimator (android.animation.ValueAnimator)103 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)52 ArrayList (java.util.ArrayList)50 Rect (android.graphics.Rect)43 ViewGroup (android.view.ViewGroup)42 ImageView (android.widget.ImageView)36 TextView (android.widget.TextView)32 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)26 PropertyValuesHolder (android.animation.PropertyValuesHolder)25 Paint (android.graphics.Paint)25 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)25 Bitmap (android.graphics.Bitmap)17 Point (android.graphics.Point)15 OvershootInterpolator (android.view.animation.OvershootInterpolator)15 BitmapDrawable (android.graphics.drawable.BitmapDrawable)14