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:com.bar.foldinglayout.sample.FoldingLayoutActivity.java

/**
 * Animates the folding view inwards (to a completely folded state) from its
 * current state and then back out to its original state.
 *///from  w  w w .  j a  va 2 s .  com
public void animateFold() {
    float foldFactor = mFoldLayout.getFoldFactor();

    ObjectAnimator animator = ObjectAnimator.ofFloat(mFoldLayout, "foldFactor", foldFactor, 1);
    animator.setRepeatMode(ValueAnimator.REVERSE);
    animator.setRepeatCount(1);
    animator.setDuration(FOLD_ANIMATION_DURATION);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.start();
}

From source file:com.mahhaus.scanloto.ScannerActivity.java

private void showHighlightErrorMessageUiAnimated(String message) {
    lastErrorRecieved = System.currentTimeMillis();
    errorMessageLayout.setVisibility(View.VISIBLE);
    errorMessage.setBackgroundColor(ContextCompat.getColor(this, R.color.anyline_red));
    errorMessage.setAlpha(0f);//from w ww.ja v a  2s  .co  m
    errorMessage.setText(message);

    if (errorMessageAnimator != null && errorMessageAnimator.isRunning()) {
        errorMessageAnimator.cancel();
    }

    errorMessageAnimator = ObjectAnimator.ofFloat(errorMessage, "alpha", 0f, 1f);
    errorMessageAnimator.setDuration(getResources().getInteger(R.integer.error_message_delay));
    errorMessageAnimator.setInterpolator(new DecelerateInterpolator());
    errorMessageAnimator.setRepeatMode(ValueAnimator.REVERSE);
    errorMessageAnimator.setRepeatCount(1);
    errorMessageAnimator.start();
}

From source file:cs.umass.edu.prepare.view.activities.CalendarActivity.java

private void transition() {
    int transitionColor = ContextCompat.getColor(this, R.color.color_transition_details_swipe);
    ValueAnimator colorAnim = ObjectAnimator.ofInt(detailsView, "backgroundColor", transitionColor,
            Color.TRANSPARENT);/*from   ww  w.  ja  v  a  2s  . c om*/
    colorAnim.setDuration(250);
    colorAnim.setEvaluator(new ArgbEvaluator());
    colorAnim.setRepeatCount(0);
    colorAnim.setRepeatMode(ValueAnimator.REVERSE);
    colorAnim.start();
}

From source file:org.sufficientlysecure.keychain.ui.BackupCodeFragment.java

private static void animateFlashText(final TextView[] textViews, int color1, int color2,
        boolean staySecondColor) {

    ValueAnimator anim = ValueAnimator.ofObject(new ArgbEvaluator(), color1, color2);
    anim.addUpdateListener(new AnimatorUpdateListener() {
        @Override//from  w  ww. j  a v a 2 s. com
        public void onAnimationUpdate(ValueAnimator animator) {
            for (TextView textView : textViews) {
                textView.setTextColor((Integer) animator.getAnimatedValue());
            }
        }
    });
    anim.setRepeatMode(ValueAnimator.REVERSE);
    anim.setRepeatCount(staySecondColor ? 4 : 5);
    anim.setDuration(180);
    anim.setInterpolator(new AccelerateInterpolator());
    anim.start();

}

From source file:com.anyline.reactnative.DocumentActivity.java

private void showHighlightErrorMessageUiAnimated(String message) {
    lastErrorRecieved = System.currentTimeMillis();
    errorMessageLayout.setVisibility(View.VISIBLE);
    errorMessage.setBackgroundColor(ContextCompat.getColor(this,
            getResources().getIdentifier("anyline_red", "color", getPackageName())));
    errorMessage.setAlpha(0f);/*from   w ww.ja v  a2s. co m*/
    errorMessage.setText(message);

    if (errorMessageAnimator != null && errorMessageAnimator.isRunning()) {
        errorMessageAnimator.cancel();
    }

    errorMessageAnimator = ObjectAnimator.ofFloat(errorMessage, "alpha", 0f, 1f);
    errorMessageAnimator.setDuration(getResources()
            .getInteger(getResources().getIdentifier("error_message_delay", "integer", getPackageName())));
    errorMessageAnimator.setInterpolator(new DecelerateInterpolator());
    errorMessageAnimator.setRepeatMode(ValueAnimator.REVERSE);
    errorMessageAnimator.setRepeatCount(1);
    errorMessageAnimator.start();
}

From source file:com.waz.zclient.ui.audiomessage.AudioMessageRecordingView.java

private void startRecordingIndicator() {
    if (recordingIndicatorDotAnimator == null) {
        recordingIndicatorDotAnimator = ObjectAnimator.ofFloat(recordingIndicatorDotView, View.ALPHA, 0f);
        recordingIndicatorDotAnimator.setRepeatCount(ValueAnimator.INFINITE);
        recordingIndicatorDotAnimator.setRepeatMode(ValueAnimator.REVERSE);
        recordingIndicatorDotAnimator.setDuration(RECORDING_INDICATOR_HIDDEN_INTERVAL);
        recordingIndicatorDotAnimator.setStartDelay(RECORDING_INDICATOR_VISIBLE_INTERVAL);
    }//from   ww w.  jav a 2  s. c  o  m
    recordingIndicatorDotAnimator.start();
}

From source file:com.anyline.reactnative.Document4Activity.java

private void showHighlightErrorMessageUiAnimated(String message) {
    lastErrorRecieved = System.currentTimeMillis();
    errorMessageLayout.setVisibility(View.VISIBLE);
    errorMessage.setBackgroundColor(ContextCompat.getColor(this,
            getResources().getIdentifier("anyline_red", "color", getPackageName())));
    errorMessage.setAlpha(0f);/*from   w  ww  .  ja v a 2 s .  c o m*/
    errorMessage.setText(message);

    if (errorMessageAnimator != null && errorMessageAnimator.isRunning()) {
        errorMessageAnimator.cancel();
    }

    errorMessageAnimator = ObjectAnimator.ofFloat(errorMessage, "alpha", 0f, 1f);
    errorMessageAnimator.setDuration(ERROR_MESSAGE_DELAY);
    errorMessageAnimator.setInterpolator(new DecelerateInterpolator());
    errorMessageAnimator.setRepeatMode(ValueAnimator.REVERSE);
    errorMessageAnimator.setRepeatCount(1);
    errorMessageAnimator.start();
}

From source file:com.nihaskalam.progressbuttonlibrary.CircularProgressButton.java

private void animateIdleStateButtonAfterClick() {
    int textColorChangeDuration = 10;
    ObjectAnimator colorAnim = ObjectAnimator.ofInt(this, "textColor", getNormalColor(this.getTextColors()),
            mIdleStateTextColorAfterClick);
    colorAnim.setDuration(textColorChangeDuration);
    colorAnim.setEvaluator(new ArgbEvaluator());
    colorAnim.start();/* w w w.  j ava2  s. co  m*/

    ObjectAnimator colorAnim1 = ObjectAnimator.ofInt(this, "textColor", mIdleStateTextColorAfterClick,
            getNormalColor(this.getTextColors()));
    colorAnim1.setDuration(0);
    colorAnim1.setStartDelay(IDLE_STATE_ANIMATION_DURATION_AFTER_CLICK - textColorChangeDuration);
    colorAnim1.setEvaluator(new ArgbEvaluator());
    colorAnim1.setInterpolator(new BounceInterpolator());
    colorAnim1.start();

    ObjectAnimator bgAnim = ObjectAnimator.ofInt(this, "backgroundColor", getNormalColor(mIdleColorState),
            mIdleStateBackgroundColorAfterClick);
    bgAnim.setDuration(0);
    bgAnim.setEvaluator(new ArgbEvaluator());
    bgAnim.start();

    int textSizeAnimationDuration = 150;
    ValueAnimator animator = ValueAnimator.ofFloat(textSize, textSize - textSize / 4);
    animator.setDuration(textSizeAnimationDuration);
    animator.setRepeatCount(1);
    animator.setRepeatMode(ValueAnimator.REVERSE);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float animatedValue = (float) valueAnimator.getAnimatedValue();
            setTextSize(animatedValue);
        }
    });

    animator.start();
}