Example usage for android.animation ValueAnimator REVERSE

List of usage examples for android.animation ValueAnimator REVERSE

Introduction

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

Prototype

int REVERSE

To view the source code for android.animation ValueAnimator REVERSE.

Click Source Link

Document

When the animation reaches the end and repeatCount is INFINITE or a positive value, the animation reverses direction on every iteration.

Usage

From source file:Main.java

public static void reverse(ValueAnimator... animators) {
    for (ValueAnimator animator : animators) {
        final float fraction = animator.getAnimatedFraction();
        if (fraction > 0.0f) {
            animator.reverse();
        }/*  w w w .  j a  v  a2  s  . c  om*/
    }
}

From source file:com.android.clear.reminder.AnimatorUtils.java

public static void reverse(ValueAnimator... animators) {
    for (ValueAnimator animator : animators) {
        final float fraction = animator.getAnimatedFraction();
        if (fraction > 0.0f) {
            animator.reverse();
            setAnimatedFraction(animator, 1.0f - fraction);
        }/*from w w w  .  ja v a  2 s  .  c om*/
    }
}

From source file:Main.java

public static void breath(View v, float fromRange, float toRange, long duration) {
    ObjectAnimator animator = ObjectAnimator.ofFloat(v, View.ALPHA, fromRange, toRange);
    animator.setDuration(duration);/* w  ww  . j  ava2s. c  om*/
    animator.setRepeatMode(ValueAnimator.REVERSE);
    animator.setRepeatCount(ValueAnimator.INFINITE);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.start();
}

From source file:android.support.v17.leanback.app.PlaybackSupportFragment.java

/**
 * if first animator is still running, reverse it; otherwise start second animator.
 *///from   w  w w  .  j a v a 2 s  . c o m
static void reverseFirstOrStartSecond(ValueAnimator first, ValueAnimator second, boolean runAnimation) {
    if (first.isStarted()) {
        first.reverse();
        if (!runAnimation) {
            first.end();
        }
    } else {
        second.start();
        if (!runAnimation) {
            second.end();
        }
    }
}

From source file:org.catrobat.paintroid.ui.BottomBar.java

private void delayedAnimateSelectedTool(int startDelay) {
    ImageButton button = getToolButtonByToolType(mCurrentToolType);
    int color = ContextCompat.getColor(button.getContext(), R.color.bottom_bar_button_activated);
    int fadedColor = color & 0x00ffffff;
    ValueAnimator valueAnimator = ObjectAnimator.ofInt(button, "backgroundColor", color, fadedColor);
    valueAnimator.setEvaluator(new ArgbEvaluator());
    valueAnimator.setInterpolator(new LinearInterpolator());
    valueAnimator.setDuration(500);//from   w  ww. j  a v  a2s.com
    valueAnimator.setRepeatCount(5);
    valueAnimator.setRepeatMode(ValueAnimator.REVERSE);
    valueAnimator.setStartDelay(startDelay);
    valueAnimator.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (PaintroidApplication.currentTool != null) {
                setActivatedToolButton(PaintroidApplication.currentTool.getToolType());
            }
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });
    valueAnimator.start();
}

From source file:com.example.google.maps.folding_map.MainActivity.java

public void animateFold() {
    ObjectAnimator animator = ObjectAnimator.ofFloat(mFoldingLayout, "foldFactor",
            mFoldingLayout.getFoldFactor(), 1);
    animator.setRepeatMode(ValueAnimator.REVERSE);
    animator.setRepeatCount(1);/*from  w ww  . j  ava 2  s  .c o m*/
    animator.setDuration(FOLD_ANIMATION_DURATION);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.start();
}

From source file:com.gigigo.imagerecognition.vuforia.VuforiaActivity.java

private void startBoringAnimation() {
    scanLine.setVisibility(View.VISIBLE);
    // Create animators for y axe
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        int yMax = 0;
        yMax = getResources().getDisplayMetrics().heightPixels; //mVuforiaView.getDisplay().getHeight();
        yMax = (int) (yMax * 0.9);// 174;

        ObjectAnimator oay = ObjectAnimator.ofFloat(scanLine, "translationY", 0, yMax);
        oay.setRepeatCount(Animation.INFINITE);
        oay.setDuration(ANIM_DURATION);//from w ww  . j av  a  2s . c  o  m
        oay.setRepeatMode(ValueAnimator.REVERSE);

        oay.setInterpolator(new LinearInterpolator());
        oay.start();

        //for draw points near ir_scanline
        markFakeFeaturePoint.setObjectAnimator(oay);
    }

    //scanAnimation.

}

From source file:arun.com.chromer.shared.views.TabView.java

private Animator getIconSelectionAnimator() {
    Animator animator = null;/* w ww  .  j  a v a  2 s. c o m*/
    switch (mTabType) {
    case TAB_TYPE_OPTIONS:
        animator = ObjectAnimator.ofFloat(tabIcon, "rotation", 180);
        break;
    case TAB_TYPE_WEB_HEADS:
        animator = ObjectAnimator.ofFloat(tabIcon, "rotation", 125);
        break;
    case TAB_TYPE_CUSTOMIZE:
        animator = ObjectAnimator.ofFloat(tabIcon, "scaleY", 1.2f);
        ((ObjectAnimator) animator).setRepeatMode(ValueAnimator.REVERSE);
        ((ObjectAnimator) animator).setRepeatCount(3);
        animator.setInterpolator(new LinearInterpolator());
        break;
    }
    if (animator != null)
        animator.setDuration(250);
    return animator;
}

From source file:me.lizheng.deckview.views.DeckChildViewHeader.java

/**
 * Notifies the associated TaskView has been focused.
 *///from   w w  w.  jav a  2 s .  c o  m
void onTaskViewFocusChanged(boolean focused, boolean animateFocusedState) {
    // If we are not animating the visible state, just return
    if (!animateFocusedState)
        return;

    boolean isRunning = false;
    if (mFocusAnimator != null) {
        isRunning = mFocusAnimator.isRunning();
        DVUtils.cancelAnimationWithoutCallbacks(mFocusAnimator);
    }

    if (focused) {
        // Pulse the background color
        int currentColor = mBackgroundColor;
        int lightPrimaryColor = getSecondaryColor(mCurrentPrimaryColor, mCurrentPrimaryColorIsDark);
        ValueAnimator backgroundColor = ValueAnimator.ofObject(new ArgbEvaluator(), currentColor,
                lightPrimaryColor);

        backgroundColor.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                int color = (int) animation.getAnimatedValue();
                mBackgroundColorDrawable.setColor(color);
                mBackgroundColor = color;
            }
        });

        backgroundColor.setRepeatCount(ValueAnimator.INFINITE);
        backgroundColor.setRepeatMode(ValueAnimator.REVERSE);

        // Pulse the translation
        ObjectAnimator translation = ObjectAnimator.ofFloat(this, "translationZ", 15f);
        translation.setRepeatCount(ValueAnimator.INFINITE);
        translation.setRepeatMode(ValueAnimator.REVERSE);

        mFocusAnimator = new AnimatorSet();
        mFocusAnimator.playTogether(backgroundColor, translation);
        mFocusAnimator.setStartDelay(750);
        mFocusAnimator.setDuration(750);
        mFocusAnimator.start();
    } else if (isRunning) {
        // Restore the background color
        int currentColor = mBackgroundColor;
        ValueAnimator backgroundColor = ValueAnimator.ofObject(new ArgbEvaluator(), currentColor,
                mCurrentPrimaryColor);
        backgroundColor.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                int color = (int) animation.getAnimatedValue();
                mBackgroundColorDrawable.setColor(color);
                mBackgroundColor = color;
            }
        });

        // Restore the translation
        ObjectAnimator translation = ObjectAnimator.ofFloat(this, "translationZ", 0f);

        mFocusAnimator = new AnimatorSet();
        mFocusAnimator.playTogether(backgroundColor, translation);
        mFocusAnimator.setDuration(150);
        mFocusAnimator.start();
    }
}

From source file:com.geecko.QuickLyric.adapter.IntroScreenSlidePagerAdapter.java

public IntroScreenSlidePagerAdapter(FragmentManager fm, final Activity activity) {
    super(fm);//from ww  w  .j  a v  a  2 s  .  c o m
    this.mActivity = activity;
    mPager = ((ViewPager) mActivity.findViewById(R.id.pager));
    mPager.setOnTouchListener(exitTouchListener);
    if (Build.VERSION.SDK_INT >= 17)
        rightToLeft = TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == 1;
    if (rightToLeft) {
        List<Integer> list = Arrays.asList(colors);
        Collections.reverse(list);
        colors = (Integer[]) list.toArray();
    }
    ImageButton pagerArrow = ((ImageButton) mActivity.findViewById(R.id.pager_arrow));
    Button okButton = ((Button) mActivity.findViewById(R.id.pager_ok));
    okButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && !Tutorial_5.nlEnabled) {
                final ViewGroup nlFrame = (ViewGroup) activity.findViewById(R.id.NL_frame);
                final ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(),
                        Color.parseColor("#30000000"), Color.parseColor("#80FFFFFF"));
                colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    @Override
                    public void onAnimationUpdate(ValueAnimator animation) {
                        nlFrame.setBackgroundColor((int) animation.getAnimatedValue());
                    }
                });
                colorAnimation.setInterpolator(new LinearOutSlowInInterpolator());
                colorAnimation.setRepeatCount(3);
                colorAnimation.setRepeatMode(ValueAnimator.REVERSE);
                colorAnimation.setDuration(650L);
                colorAnimation.start();
            } else if (!hasClicked) {
                exitAction();
                hasClicked = true;
            }
        }
    });
    pagerArrow.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            nextAction();
        }
    });
}