Example usage for android.animation ValueAnimator start

List of usage examples for android.animation ValueAnimator start

Introduction

In this page you can find the example usage for android.animation ValueAnimator start.

Prototype

@Override
    public void start() 

Source Link

Usage

From source file:com.insalyon.les24heures.view.DrawerArrowDrawable.java

public void animateToArrow() {
    final DrawerArrowDrawable self = this;
    ValueAnimator animation = ValueAnimator.ofFloat(0f, 1f);
    animation.setDuration(500);/*from   www  . ja  va 2s  .c o m*/
    animation.start();
    animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            self.setParameter((Float) animation.getAnimatedValue());
        }
    });

    this.setFlip(true);
}

From source file:com.wytiger.common.widget.SlideSwitch.java

private void moveToDest(final boolean toRight) {
    ValueAnimator toDestAnim = ValueAnimator.ofInt(frontRect_left, toRight ? max_left : min_left);
    toDestAnim.setDuration(500);//from w  w  w .  j av  a 2s . c  om
    toDestAnim.setInterpolator(new AccelerateDecelerateInterpolator());
    toDestAnim.start();
    toDestAnim.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            frontRect_left = (Integer) animation.getAnimatedValue();
            alpha = (int) (255 * (float) frontRect_left / (float) max_left);
            invalidateView();
        }
    });
    toDestAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (toRight) {
                isOpen = true;
                if (listener != null)
                    listener.open();
                frontRect_left_begin = max_left;
            } else {
                isOpen = false;
                if (listener != null)
                    listener.close();
                frontRect_left_begin = min_left;
            }
        }
    });
}

From source file:com.example.administrator.iclub21.view.SlideSwitch.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void moveToDest(final boolean toRight) {
    ValueAnimator toDestAnim = ValueAnimator.ofInt(frontRect_left, toRight ? max_left : min_left);
    toDestAnim.setDuration(500);/*from  w w w  . ja  va  2s.  c o m*/
    toDestAnim.setInterpolator(new AccelerateDecelerateInterpolator());
    toDestAnim.start();
    toDestAnim.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            frontRect_left = (Integer) animation.getAnimatedValue();
            alpha = (int) (255 * (float) frontRect_left / (float) max_left);
            invalidateView();
        }
    });
    toDestAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (toRight) {
                isOpen = true;
                if (listener != null)
                    listener.open();
                frontRect_left_begin = max_left;
            } else {
                isOpen = false;
                if (listener != null)
                    listener.close();
                frontRect_left_begin = min_left;
            }
        }
    });
}

From source file:com.fruit.widget.SlideSwitch.java

public void moveToDest(final boolean toRight) {
    ValueAnimator toDestAnim = ValueAnimator.ofInt(frontRect_left, toRight ? max_left : min_left);
    toDestAnim.setDuration(duration);/*from  ww w . ja  v  a  2  s  .  co m*/
    toDestAnim.setInterpolator(new AccelerateDecelerateInterpolator());
    toDestAnim.start();
    toDestAnim.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            frontRect_left = (Integer) animation.getAnimatedValue();
            alpha = (int) (255 * (float) frontRect_left / (float) max_left);
            invalidateView();
        }
    });
    toDestAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (toRight) {
                isOpen = true;
                if (listener != null)
                    listener.open();
                frontRect_left_begin = max_left;
            } else {
                isOpen = false;
                if (listener != null)
                    listener.close();
                frontRect_left_begin = min_left;
            }
        }
    });
}

From source file:com.android.argb.edhlc.Utils.java

public static void collapse(Context context, final CardView card, TextView title, ImageView selector,
        int minHeight, int maxHeight) {
    title.setTextColor(ContextCompat.getColor(context, R.color.secondary_text));

    Animation rotation = AnimationUtils.loadAnimation(context, R.anim.rotate_180_clockwise);
    selector.startAnimation(rotation);//w  w  w  .ja v  a2s  .  co m
    selector.setColorFilter(ContextCompat.getColor(context, R.color.secondary_text));

    ValueAnimator anim = ValueAnimator.ofInt(maxHeight, minHeight);
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int val = (Integer) valueAnimator.getAnimatedValue();
            ViewGroup.LayoutParams layoutParams = card.getLayoutParams();
            layoutParams.height = val;
            card.setLayoutParams(layoutParams);
        }
    });
    anim.start();
}

From source file:com.dean.phonesafe.ui.SlideSwitch.java

public void moveToDest(final boolean toRight) {
    ValueAnimator toDestAnim = ValueAnimator.ofInt(frontRect_left, toRight ? max_left : min_left);
    toDestAnim.setDuration(500);/*from w  w w .  j a  va  2  s  .  co  m*/
    toDestAnim.setInterpolator(new AccelerateDecelerateInterpolator());
    toDestAnim.start();
    toDestAnim.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            frontRect_left = (Integer) animation.getAnimatedValue();
            alpha = (int) (255 * (float) frontRect_left / (float) max_left);
            invalidateView();
        }
    });
    toDestAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (toRight) {
                isOpen = true;
                if (listener != null)
                    listener.open();
                frontRect_left_begin = max_left;
            } else {
                isOpen = false;
                if (listener != null)
                    listener.close();
                frontRect_left_begin = min_left;
            }
        }
    });
}

From source file:com.audionote.widget.SlideSwitch.java

public void moveToDest(final boolean toRight) {
    ValueAnimator toDestAnim = ValueAnimator.ofInt(frontRect_left, toRight ? max_left : min_left);
    toDestAnim.setDuration(200);/*from   www .  j  a  va2s.  c  o  m*/
    toDestAnim.setInterpolator(new AccelerateDecelerateInterpolator());
    toDestAnim.start();
    toDestAnim.addUpdateListener(new AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            frontRect_left = (Integer) animation.getAnimatedValue();
            alpha = (int) (255 * (float) frontRect_left / (float) max_left);
            invalidateView();
        }
    });
    toDestAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (toRight) {
                isOpen = true;
                if (listener != null)
                    listener.open();
                frontRect_left_begin = max_left;
            } else {
                isOpen = false;
                if (listener != null)
                    listener.close();
                frontRect_left_begin = min_left;
            }
        }
    });
}

From source file:org.hawkular.client.android.util.ViewTransformer.java

@UiThread
public void collapse() {
    ValueAnimator animator = ValueAnimator.ofInt(Views.measureHeight(view), 0);
    animator.setInterpolator(new LinearOutSlowInInterpolator());
    animator.setDuration(Durations.MEDIUM);

    animator.addUpdateListener(this);
    animator.addListener(new AnimatorListenerAdapter() {
        @Override/*  w ww.ja  v a 2 s  .c o  m*/
        public void onAnimationEnd(Animator animation) {
            view.setVisibility(View.GONE);
        }
    });

    animator.start();
}

From source file:com.android.argb.edhlc.Utils.java

public static void expand(Context context, final CardView card, TextView title, ImageView selector,
        int minHeight, int maxHeight) {
    title.setTextColor(ContextCompat.getColor(context, R.color.accent_color_dark));

    Animation rotation = AnimationUtils.loadAnimation(context, R.anim.rotate_180_anticlockwise);
    selector.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.arrow_up));
    selector.setRotation(0);//w w  w  .j  av  a2 s.  c  om
    selector.startAnimation(rotation);
    selector.setColorFilter(ContextCompat.getColor(context, R.color.accent_color_dark));

    ValueAnimator anim = ValueAnimator.ofInt(minHeight, maxHeight);
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int val = (Integer) valueAnimator.getAnimatedValue();
            ViewGroup.LayoutParams layoutParams = card.getLayoutParams();
            layoutParams.height = val;
            card.setLayoutParams(layoutParams);
            Utils.makeViewVisible(card);
        }
    });
    anim.start();
}

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

@Override
protected void onStatusChanged(final boolean expanded, final int size, final boolean animate) {
    if (!animate) {
        updateLayoutOnAnimation(1, expanded);
        return;//from  w  w  w . j a  v a  2  s.c  om
    }

    final ValueAnimator animator = ObjectAnimator.ofFloat(0, 1);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(final ValueAnimator animation) {
            updateLayoutOnAnimation(animation.getAnimatedFraction(), expanded);
        }
    });
    animator.setDuration(animationDuration);
    animator.setInterpolator(interpolator);
    animator.start();
}