Example usage for android.animation AnimatorSet setInterpolator

List of usage examples for android.animation AnimatorSet setInterpolator

Introduction

In this page you can find the example usage for android.animation AnimatorSet setInterpolator.

Prototype

@Override
public void setInterpolator(TimeInterpolator interpolator) 

Source Link

Document

Sets the TimeInterpolator for all current #getChildAnimations() child animations of this AnimatorSet.

Usage

From source file:com.josecalles.porridge.transitions.MorphFabToDialog.java

@Override
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues,
        final TransitionValues endValues) {
    Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (startValues == null || endValues == null || changeBounds == null) {
        return null;
    }//from  w  w  w .jav  a2  s.  c o m

    Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR);
    Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS);
    Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR);
    Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS);

    if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) {
        return null;
    }

    MorphDrawable background = new MorphDrawable(startColor, startCornerRadius);
    endValues.view.setBackground(background);

    Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor);
    Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius);

    // ease in the dialog's child views (slide up & fade in)
    if (endValues.view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) endValues.view;
        float offset = vg.getHeight() / 3;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.setTranslationY(offset);
            v.setAlpha(0f);
            v.animate().alpha(1f).translationY(0f).setDuration(150).setStartDelay(150).setInterpolator(
                    AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_slow_in));
            offset *= 1.8f;
        }
    }

    AnimatorSet transition = new AnimatorSet();
    transition.playTogether(changeBounds, corners, color);
    transition.setDuration(300);
    transition.setInterpolator(
            AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in));
    return transition;
}

From source file:io.romain.passport.ui.transitions.MorphFabToDialog.java

@Override
public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues,
        final TransitionValues endValues) {
    Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (startValues == null || endValues == null || changeBounds == null) {
        return null;
    }//from   w w  w  . j  a v  a  2  s. c o  m

    Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR);
    Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS);
    Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR);
    Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS);

    if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) {
        return null;
    }

    MorphDrawable background = new MorphDrawable(startColor, startCornerRadius);
    endValues.view.setBackground(background);

    Animator color = ObjectAnimator.ofArgb(background, MorphDrawable.COLOR, endColor);
    Animator corners = ObjectAnimator.ofFloat(background, MorphDrawable.CORNER_RADIUS, endCornerRadius);

    // ease in the dialog's child views (slide up & fade in)
    if (endValues.view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) endValues.view;
        float offset = vg.getHeight() / 3;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.setTranslationY(offset);
            v.setAlpha(0f);
            v.animate().alpha(1f).translationY(0f).setDuration(150).setStartDelay(150)
                    .setInterpolator(AnimUtils.getFastOutSlowInInterpolator(vg.getContext()));
            offset *= 1.8f;
        }
    }

    AnimatorSet transition = new AnimatorSet();
    transition.playTogether(changeBounds, corners, color);
    transition.setDuration(300);
    transition.setInterpolator(AnimUtils.getFastOutSlowInInterpolator(sceneRoot.getContext()));
    return transition;
}

From source file:im.ene.ribbon.FixedActionTabView.java

@Override
protected void onStatusChanged(final boolean expanded, final int size, final boolean animate) {
    if (!animate) {
        updateLayoutOnAnimation(1, expanded);
        setIconTranslation(expanded ? 0 : (paddingTopInactive - paddingTopActive));
        return;//from   ww  w .  j  a  v a 2 s  .c  o m
    }

    final AnimatorSet set = new AnimatorSet();
    set.setDuration(animationDuration);
    set.setInterpolator(interpolator);

    final ValueAnimator textScaleAnimator = ObjectAnimator.ofFloat(this, "textScale",
            expanded ? TEXT_SCALE_ACTIVE : 1);

    textScaleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(final ValueAnimator animation) {
            final float fraction = animation.getAnimatedFraction();
            updateLayoutOnAnimation(fraction, expanded);
        }
    });

    final ValueAnimator iconTranslationAnimator = ObjectAnimator.ofFloat(this, "iconTranslation",
            expanded ? 0 : (paddingTopInactive - paddingTopActive));

    set.playTogether(textScaleAnimator, iconTranslationAnimator);
    set.start();
}

From source file:com.angelatech.yeyelive.view.PeriscopeLayout.java

private Animator getAnimator(View target) {
    AnimatorSet set = getEnterAnimtor(target);
    ValueAnimator bezierValueAnimator = getBezierValueAnimator(target);
    AnimatorSet finalSet = new AnimatorSet();
    finalSet.playSequentially(set);//from   www .ja v  a 2 s  .  com
    finalSet.playSequentially(set, bezierValueAnimator);
    finalSet.setInterpolator(interpolators[random.nextInt(4)]);
    finalSet.setTarget(target);
    return finalSet;
}

From source file:com.ofalvai.bpinfo.ui.alert.AlertDetailFragment.java

public void updateAlert(final Alert alert) {
    mAlert = alert;/*from ww  w. ja  va2 s  . c  o m*/
    mDisplayedRoutes.clear();
    mRouteIconsLayout.removeAllViews();

    // Updating views
    displayAlert(alert);

    // View animations
    // For some reason, ObjectAnimator doesn't work here (skips animation states, just shows the
    // last frame), we need to use ValueAnimators.
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(300);
    animatorSet.setInterpolator(new FastOutSlowInInterpolator());

    // We can't measure the TextView's height before a layout happens because of the setText() call
    // Note: even though displayAlert() was called earlier, the TextView's height is still 0.
    int heightEstimate = mDescriptionTextView.getLineHeight() * mDescriptionTextView.getLineCount() + 10;

    ValueAnimator descriptionHeight = ValueAnimator.ofInt(mDescriptionTextView.getHeight(), heightEstimate);
    descriptionHeight.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mDescriptionTextView.getLayoutParams().height = (int) animation.getAnimatedValue();
            mDescriptionTextView.requestLayout();
        }
    });
    descriptionHeight.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mDescriptionTextView.setAlpha(1.0f);
            mDescriptionTextView.setVisibility(View.VISIBLE);
        }
    });

    ValueAnimator descriptionAlpha = ValueAnimator.ofFloat(0, 1.0f);
    descriptionAlpha.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mDescriptionTextView.setAlpha((float) animation.getAnimatedValue());
        }
    });

    ValueAnimator progressHeight = ValueAnimator.ofInt(mProgressBar.getHeight(), 0);
    progressHeight.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mProgressBar.getLayoutParams().height = (int) animation.getAnimatedValue();
            mProgressBar.requestLayout();
        }
    });
    progressHeight.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mProgressBar.hide();
        }
    });

    animatorSet.playTogether(progressHeight, descriptionHeight, descriptionAlpha);
    animatorSet.start();
}

From source file:com.artemchep.horario.ui.widgets.ContainersLayout.java

private void animateInFrameDetails() {
    frameDetails.setVisibility(View.VISIBLE);
    ViewUtils.onLaidOut(frameDetails, new Runnable() {
        @Override// ww  w  .j a  v  a2  s  . com
        public void run() {
            ObjectAnimator alpha = ofFloat(frameDetails, View.ALPHA, 0.4f, 1f);
            ObjectAnimator translate = ofFloat(frameDetails, View.TRANSLATION_Y,
                    frameDetails.getHeight() * 0.3f, 0f);

            AnimatorSet set = new AnimatorSet();
            set.playTogether(alpha, translate);
            set.setDuration(ANIM_DURATION);
            set.setInterpolator(new LinearOutSlowInInterpolator());
            set.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    frameMaster.setVisibility(View.GONE);
                }
            });
            set.start();
        }
    });
}

From source file:com.artemchep.horario.ui.widgets.ContainersLayout.java

private void animateOutFrameDetails() {
    ViewUtils.onLaidOut(frameDetails, new Runnable() {
        @Override/*from  www . ja va  2 s  . c  o  m*/
        public void run() {
            if (!frameDetails.isShown()) {
                return;
            }
            ObjectAnimator alpha = ObjectAnimator.ofFloat(frameDetails, View.ALPHA, 1f, 0f);
            ObjectAnimator translate = ofFloat(frameDetails, View.TRANSLATION_Y, 0f,
                    frameDetails.getHeight() * 0.3f);

            AnimatorSet set = new AnimatorSet();
            set.playTogether(alpha, translate);
            set.setDuration(ANIM_DURATION);
            set.setInterpolator(new FastOutLinearInInterpolator());
            set.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    frameDetails.setAlpha(1f);
                    frameDetails.setTranslationY(0);
                    frameDetails.setVisibility(View.GONE);
                }
            });
            set.start();
        }
    });
}

From source file:com.myhexaville.iconanimations.gooey_fab.GooeyFab.java

void onElevationsChanged(final float elevation, final float pressedTranslationZ) {
    final StateListAnimator stateListAnimator = new StateListAnimator();

    // Animate elevation and translationZ to our values when pressed
    AnimatorSet set = new AnimatorSet();
    set.play(ObjectAnimator.ofFloat(this, "elevation", elevation).setDuration(0)).with(ObjectAnimator
            .ofFloat(this, View.TRANSLATION_Z, pressedTranslationZ).setDuration(PRESSED_ANIM_DURATION));
    set.setInterpolator(ANIM_INTERPOLATOR);
    stateListAnimator.addState(PRESSED_ENABLED_STATE_SET, set);

    // Same deal for when we're focused
    set = new AnimatorSet();
    set.play(ObjectAnimator.ofFloat(this, "elevation", elevation).setDuration(0)).with(ObjectAnimator
            .ofFloat(this, View.TRANSLATION_Z, pressedTranslationZ).setDuration(PRESSED_ANIM_DURATION));
    set.setInterpolator(ANIM_INTERPOLATOR);
    stateListAnimator.addState(FOCUSED_ENABLED_STATE_SET, set);

    // Animate translationZ to 0 if not pressed
    set = new AnimatorSet();
    // Use an AnimatorSet to set a start delay since there is a bug with ValueAnimator that
    // prevents it from being cancelled properly when used with a StateListAnimator.
    AnimatorSet anim = new AnimatorSet();
    anim.play(ObjectAnimator.ofFloat(this, View.TRANSLATION_Z, 0f).setDuration(PRESSED_ANIM_DURATION))
            .after(PRESSED_ANIM_DURATION);
    set.play(ObjectAnimator.ofFloat(this, "elevation", elevation).setDuration(0)).with(anim);
    set.setInterpolator(ANIM_INTERPOLATOR);
    stateListAnimator.addState(ENABLED_STATE_SET, set);

    // Animate everything to 0 when disabled
    set = new AnimatorSet();
    set.play(ObjectAnimator.ofFloat(this, "elevation", 0f).setDuration(0))
            .with(ObjectAnimator.ofFloat(this, View.TRANSLATION_Z, 0f).setDuration(0));
    set.setInterpolator(ANIM_INTERPOLATOR);
    stateListAnimator.addState(EMPTY_STATE_SET, set);

    setStateListAnimator(stateListAnimator);
}

From source file:org.cyanogenmod.designertools.ui.CreditsActivity.java

private void animateContent() {
    View avatar1 = findViewById(R.id.avatar1);
    avatar1.setScaleX(0);/*from   w  ww .ja  v  a  2  s  . c o m*/
    avatar1.setScaleY(0);
    avatar1.setVisibility(View.VISIBLE);
    View text1 = findViewById(R.id.text1);
    text1.setAlpha(0);
    text1.setVisibility(View.VISIBLE);
    View avatar2 = findViewById(R.id.avatar2);
    avatar2.setScaleX(0);
    avatar2.setScaleY(0);
    avatar2.setVisibility(View.VISIBLE);
    View text2 = findViewById(R.id.text2);
    text2.setAlpha(0);
    text2.setVisibility(View.VISIBLE);
    View avatar3 = findViewById(R.id.avatar3);
    avatar3.setScaleX(0);
    avatar3.setScaleY(0);
    avatar3.setVisibility(View.VISIBLE);
    View text3 = findViewById(R.id.text3);
    text3.setAlpha(0);
    text3.setVisibility(View.VISIBLE);
    View avatar4 = findViewById(R.id.avatar4);
    avatar4.setScaleX(0);
    avatar4.setScaleY(0);
    avatar4.setVisibility(View.VISIBLE);
    View text4 = findViewById(R.id.text4);
    text4.setAlpha(0);
    text4.setVisibility(View.VISIBLE);

    Interpolator interpolator = new FastOutSlowInInterpolator();
    long duration = 375L;
    long delay = duration / 3;

    AnimatorSet anim1 = new AnimatorSet();
    anim1.play(ObjectAnimator.ofFloat(avatar1, "scaleX", 1f))
            .with(ObjectAnimator.ofFloat(avatar1, "scaleY", 1f))
            .with(ObjectAnimator.ofFloat(text1, "alpha", 1f));
    anim1.setDuration(duration);
    anim1.setInterpolator(interpolator);
    AnimatorSet anim2 = new AnimatorSet();
    anim2.play(ObjectAnimator.ofFloat(avatar2, "scaleX", 1f))
            .with(ObjectAnimator.ofFloat(avatar2, "scaleY", 1f))
            .with(ObjectAnimator.ofFloat(text2, "alpha", 1f));
    anim2.setDuration(duration);
    anim2.setInterpolator(interpolator);
    anim2.setStartDelay(delay);
    AnimatorSet anim3 = new AnimatorSet();
    anim3.play(ObjectAnimator.ofFloat(avatar3, "scaleX", 1f))
            .with(ObjectAnimator.ofFloat(avatar3, "scaleY", 1f))
            .with(ObjectAnimator.ofFloat(text3, "alpha", 1f));
    anim3.setDuration(duration);
    anim3.setInterpolator(interpolator);
    anim3.setStartDelay(delay * 2);
    AnimatorSet anim4 = new AnimatorSet();
    anim4.play(ObjectAnimator.ofFloat(avatar4, "scaleX", 1f))
            .with(ObjectAnimator.ofFloat(avatar4, "scaleY", 1f))
            .with(ObjectAnimator.ofFloat(text4, "alpha", 1f));
    anim4.setDuration(duration);
    anim4.setInterpolator(interpolator);
    anim4.setStartDelay(delay * 3);
    AnimatorSet set = new AnimatorSet();
    set.play(anim1).with(anim2);
    set.play(anim2).with(anim3);
    set.play(anim3).with(anim4);
    set.start();
}

From source file:com.google.android.apps.gutenberg.ScannerActivity.java

private void showCheckinAnimation(Checkin checkin) {
    if (mLastAnimator != null) {
        mLastAnimator.cancel();/*from   ww w  .j  a v  a2s.c o m*/
    }
    final FrameLayout cover = (FrameLayout) findViewById(R.id.item_cover);
    cover.setVisibility(View.VISIBLE);
    final FrameLayout layer = (FrameLayout) findViewById(R.id.animation_layer);
    final CheckinHolder holder = new CheckinHolder(getLayoutInflater(), layer);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.CENTER_VERTICAL;
    holder.setWillAnimate(true);
    holder.bind(checkin, mImageLoader);
    holder.itemView.setBackgroundColor(Color.rgb(0xf0, 0xf0, 0xf0));
    float elevation = getResources().getDimension(R.dimen.popup_elevation);
    ViewCompat.setTranslationZ(holder.itemView, elevation);
    holder.setLines(false, false);
    layer.addView(holder.itemView, lp);
    // Interpolator for animators
    FastOutSlowInInterpolator interpolator = new FastOutSlowInInterpolator();
    // Pop-up
    Animator popUpAnim = AnimatorInflater.loadAnimator(this, R.animator.pop_up);
    popUpAnim.setTarget(holder.itemView);
    popUpAnim.setInterpolator(interpolator);
    popUpAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            holder.animateCheckin();
        }
    });
    // Wait
    ObjectAnimator waitAnim = new ObjectAnimator();
    waitAnim.setTarget(holder.itemView);
    waitAnim.setPropertyName("translationY");
    waitAnim.setFloatValues(0.f, 0.f);
    waitAnim.setDuration(2000);
    // Slide-down
    ObjectAnimator slideDownAnim = new ObjectAnimator();
    slideDownAnim.setTarget(holder.itemView);
    slideDownAnim.setPropertyName("translationY");
    slideDownAnim.setFloatValues(0.f, calcSlideDistance());
    slideDownAnim.setInterpolator(interpolator);
    // Landing anim
    ObjectAnimator landingAnim = new ObjectAnimator();
    landingAnim.setTarget(holder.itemView);
    landingAnim.setPropertyName("translationZ");
    landingAnim.setFloatValues(elevation, 0.f);
    landingAnim.setInterpolator(interpolator);
    landingAnim.setDuration(500);
    // Play the animators
    AnimatorSet set = new AnimatorSet();
    set.setInterpolator(interpolator);
    set.playSequentially(popUpAnim, waitAnim, slideDownAnim, landingAnim);
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            clean();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            clean();
        }

        private void clean() {
            mLastAnimator = null;
            layer.removeAllViews();
            cover.setVisibility(View.INVISIBLE);
        }
    });
    mLastAnimator = set;
    set.start();
}