Example usage for android.animation AnimatorSet setDuration

List of usage examples for android.animation AnimatorSet setDuration

Introduction

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

Prototype

@Override
public AnimatorSet setDuration(long duration) 

Source Link

Document

Sets the length of each of the current child animations of this AnimatorSet.

Usage

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

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

    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);

    // hide child views (offset down & fade out)
    if (endValues.view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) endValues.view;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.animate().alpha(0f).translationY(v.getHeight() / 3).setStartDelay(0L).setDuration(50L)
                    .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(),
                            android.R.interpolator.fast_out_linear_in))
                    .start();
        }
    }

    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:com.dante.girl.lib.MorphFabToDialog.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override/*from   w  w w. j  a va  2 s . co m*/
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;
    }

    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_fast 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:com.caij.codehub.ui.transitions.MorphFabToDialog.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override/*  www  .  ja  va2  s  . co  m*/
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;
    }

    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: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 ww w.j a va  2s.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 av a2s  .c om

    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:com.example.linhdq.test.install.InstallActivity.java

private void startInstallAnimation() {
    mTip1.setAlpha(0);//from   ww w .  j  a  v a 2  s. c o  m
    mTip2.setAlpha(0);
    mTip3.setAlpha(0);
    mYoutube.setAlpha(0);

    ObjectAnimator anim1 = ObjectAnimator.ofFloat(mTip1, "alpha", 1);
    ObjectAnimator anim2 = ObjectAnimator.ofFloat(mTip2, "alpha", 1);
    ObjectAnimator anim3 = ObjectAnimator.ofFloat(mTip3, "alpha", 1);
    ObjectAnimator anim4 = ObjectAnimator.ofFloat(mYoutube, "alpha", 1);
    AnimatorSet set = new AnimatorSet();
    set.setStartDelay(300);
    set.setDuration(600);
    set.playTogether(anim1, anim2, anim3, anim4);
    set.start();
    mFairyAnimation.start();

}

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 w ww. j  a va2  s .c om*/
    }

    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.metinkale.prayerapp.compass._2D.Frag2D.java

public void show() {
    mHidden = false;//  w w  w. j  a v  a  2 s .  co m
    mCompassView.post(new Runnable() {
        @Override
        public void run() {
            ObjectAnimator scaleX = ObjectAnimator.ofFloat(mCompassView, "scaleX", 0, 1);
            ObjectAnimator scaleY = ObjectAnimator.ofFloat(mCompassView, "scaleY", 0, 1);

            ObjectAnimator scaleX2 = ObjectAnimator.ofFloat(mInfo, "scaleX", 0, 1);
            ObjectAnimator scaleY2 = ObjectAnimator.ofFloat(mInfo, "scaleY", 0, 1);
            AnimatorSet animSetXY = new AnimatorSet();
            animSetXY.playTogether(scaleX, scaleY, scaleX2, scaleY2);
            animSetXY.setInterpolator(overshootInterpolator);
            animSetXY.setDuration(300);
            animSetXY.start();
        }
    });

}

From source file:com.metinkale.prayerapp.compass._2D.Frag2D.java

public void hide() {
    mHidden = true;/*  www  .  j a  va2 s  . c  om*/
    mCompassView.post(new Runnable() {
        @Override
        public void run() {
            ObjectAnimator scaleX = ObjectAnimator.ofFloat(mCompassView, "scaleX", 1, 0);
            ObjectAnimator scaleY = ObjectAnimator.ofFloat(mCompassView, "scaleY", 1, 0);

            ObjectAnimator scaleX2 = ObjectAnimator.ofFloat(mInfo, "scaleX", 1, 0);
            ObjectAnimator scaleY2 = ObjectAnimator.ofFloat(mInfo, "scaleY", 1, 0);

            AnimatorSet animSetXY = new AnimatorSet();
            animSetXY.playTogether(scaleX, scaleY, scaleX2, scaleY2);
            animSetXY.setInterpolator(accelerateInterpolator);
            animSetXY.setDuration(300);
            animSetXY.start();
        }
    });

}

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

public void updateAlert(final Alert alert) {
    mAlert = alert;//w  w  w  .  j  av a2  s .  c om
    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();
}