Example usage for android.animation ObjectAnimator setRepeatMode

List of usage examples for android.animation ObjectAnimator setRepeatMode

Introduction

In this page you can find the example usage for android.animation ObjectAnimator setRepeatMode.

Prototype

public void setRepeatMode(@RepeatMode int value) 

Source Link

Document

Defines what this animation should do when it reaches the end.

Usage

From source file:Main.java

public static void spinForever(View view, int cameraDistance, int duration) {
    view.setCameraDistance(cameraDistance);

    ObjectAnimator animator = ObjectAnimator.ofFloat(view, "rotationY", 0.0f, 360.0f);
    animator.setRepeatMode(ObjectAnimator.REVERSE);
    animator.setRepeatCount(ObjectAnimator.INFINITE);
    animator.setDuration(duration);//from  ww w.  j a v a2s  .com
    animator.start();
}

From source file:Main.java

public static void spinOnceX(View view, int cameraDistance, int duration, boolean forward) {
    view.setCameraDistance(cameraDistance);

    ObjectAnimator animator = ObjectAnimator.ofFloat(view, "rotationX", 0.0f, forward ? 360.0f : -360.0f);
    animator.setRepeatMode(ObjectAnimator.REVERSE);
    animator.setDuration(duration);//from w ww  . j a v  a2 s  .co m
    animator.start();
}

From source file:Main.java

public static void shake(View v) {
    final float distance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4.0f,
            v.getResources().getDisplayMetrics());
    final ObjectAnimator animator = ObjectAnimator.ofFloat(v, "translationX", 0, distance, 0, -distance, 0);
    animator.setRepeatMode(ObjectAnimator.RESTART);
    animator.setInterpolator(new LinearInterpolator());
    animator.setRepeatCount(4);/*  www . ja  va 2 s.  c o  m*/
    animator.setDuration(150);
    animator.start();
}

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);/* www.  ja  v a 2  s . com*/
    animator.setRepeatMode(ValueAnimator.REVERSE);
    animator.setRepeatCount(ValueAnimator.INFINITE);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.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  w  w. j a  v  a2  s.  c  om*/
    animator.setDuration(FOLD_ANIMATION_DURATION);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.start();
}

From source file:com.gigigo.vuforiaimplementation.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  a  v  a2  s .c  o  m
        oay.setRepeatMode(Animation.REVERSE);

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

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

    //scanAnimation.

}

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   ww w . j a v a2s .co  m
        oay.setRepeatMode(ValueAnimator.REVERSE);

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

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

    //scanAnimation.

}

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  www. j  av a 2  s  . c  o m
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:me.lizheng.deckview.views.DeckChildViewHeader.java

/**
 * Notifies the associated TaskView has been focused.
 */// w  w w.ja va 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:de.baumann.thema.RequestActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.request_grid);
    switcherLoad = (ViewSwitcher) findViewById(R.id.viewSwitcherLoadingMain);
    context = this;

    android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }/*from   www  .  j  ava  2s . c o  m*/

    if (savedInstanceState == null) {

        //Loading Logo Animation
        ImageView logo = (ImageView) findViewById(R.id.imageViewLogo);
        ObjectAnimator logoAni = (ObjectAnimator) AnimatorInflater.loadAnimator(context,
                R.animator.request_flip);
        logoAni.setRepeatCount(Animation.INFINITE);
        logoAni.setRepeatMode(Animation.RESTART);
        logoAni.setTarget(logo);
        logoAni.setDuration(2000);
        logoAni.start();

        taskList.execute();
    } else {
        populateView(list_activities_final);
        switcherLoad.showNext();
    }
}