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:bottombar.BottomBarTab.java

private void setTopPaddingAnimated(int start, int end) {
    if (type == Type.TABLET) {
        return;//from ww  w  .  ja  v  a  2s  . c  om
    }

    ValueAnimator paddingAnimator = ValueAnimator.ofInt(start, end);
    paddingAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            iconView.setPadding(iconView.getPaddingLeft(), (Integer) animation.getAnimatedValue(),
                    iconView.getPaddingRight(), iconView.getPaddingBottom());
        }
    });

    paddingAnimator.setDuration(ANIMATION_DURATION);
    paddingAnimator.start();
}

From source file:com.arsy.maps_library.MapRipple.java

private void startAnimation(final int numberOfRipple) {
    ValueAnimator animator = ValueAnimator.ofInt(0, (int) mDistance);
    animator.setRepeatCount(ValueAnimator.INFINITE);
    animator.setRepeatMode(ValueAnimator.RESTART);
    animator.setDuration(mRippleDuration);
    animator.setEvaluator(new IntEvaluator());
    animator.setInterpolator(new LinearInterpolator());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override//  w  w w. j a va2s  . c  o m
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int animated = (int) valueAnimator.getAnimatedValue();
            mGroundOverlays[numberOfRipple].setDimensions(animated);
            if (mDistance - animated <= 10) {
                if (mLatLng != mPrevLatLng) {
                    mGroundOverlays[numberOfRipple].setPosition(mLatLng);
                }
            }
        }
    });
    animator.start();
    mAnimators[numberOfRipple] = animator;
}

From source file:ca.zadrox.dota2esportticker.ui.TeamDetailActivity.java

private void createCompatReveal() {
    mHeaderTeamLogo.setVisibility(View.VISIBLE);
    mHeaderTeamLogo.setImageBitmap(mTeam.logo);

    mHeaderTeamLogo.setTranslationY(-UIUtils.calculateActionBarSize(this) - mHeaderTeamLogo.getHeight());

    mHeaderTeamLogo.animate().translationY(0).setDuration(100)
            .setInterpolator(new AccelerateDecelerateInterpolator())
            .setListener(new Animator.AnimatorListener() {
                @Override//  w  ww.  j  av  a  2 s  .c om
                public void onAnimationStart(Animator animation) {

                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    mHeaderTeamName.animate().alpha(1).setDuration(150)
                            .setInterpolator(new AccelerateDecelerateInterpolator()).start();

                    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(),
                            getResources().getColor(R.color.theme_primary),
                            mTeam.palette.getDarkVibrantColor(getResources().getColor(R.color.theme_primary)));

                    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                        @Override
                        public void onAnimationUpdate(ValueAnimator animator) {
                            mHeaderBox.setBackgroundColor((Integer) animator.getAnimatedValue());
                        }

                    });

                    colorAnimation.setDuration(150);
                    colorAnimation.start();
                }

                @Override
                public void onAnimationCancel(Animator animation) {

                }

                @Override
                public void onAnimationRepeat(Animator animation) {

                }
            }).start();
}

From source file:com.rks.musicx.ui.fragments.PlayingViews.Playing4Fragment.java

@Override
protected void playingView() {
    if (getMusicXService() != null) {
        String title = getMusicXService().getsongTitle();
        String artist = getMusicXService().getsongArtistName();
        songTitle.setText(title);// w  w w  .j  a  va2s .co  m
        songTitle.setSelected(true);
        songTitle.setEllipsize(TextUtils.TruncateAt.MARQUEE);
        songArtist.setText(artist);
        Helper.rotationAnim(albumArtwork);
        Helper.rotationAnim(playpausebutton);
        int dur = getMusicXService().getDuration();
        seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                if (b && getMusicXService() != null
                        && (getMusicXService().isPlaying() || getMusicXService().isPaused())) {
                    getMusicXService().seekto(seekBar.getProgress());
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
            }
        });
        if (dur != -1) {
            seekbar.setMax(dur);
            totalDur.setText(Helper.durationCalculator(dur));
        }
        updateQueuePos(getMusicXService().returnpos());
        LyricsHelper.LoadLyrics(getContext(), title, artist, getMusicXService().getsongAlbumName(),
                getMusicXService().getsongData(), lrcview);
        bitmap = new bitmap() {
            @Override
            public void bitmapwork(Bitmap bitmap) {
                albumArtwork.setImageBitmap(bitmap);
                ArtworkUtils.blurPreferances(getContext(), bitmap, blurArtwork);
                ArtworkUtils.blurPreferances(getContext(), bitmap, blurQArtwork);
            }

            @Override
            public void bitmapfailed(Bitmap bitmap) {
                albumArtwork.setImageBitmap(bitmap);
                ArtworkUtils.blurPreferances(getContext(), bitmap, blurArtwork);
                ArtworkUtils.blurPreferances(getContext(), bitmap, blurQArtwork);
            }
        };
        palette = new palette() {
            @Override
            public void palettework(Palette palette) {
                final int[] colors = Helper.getAvailableColor(getContext(), palette);
                if (Extras.getInstance().artworkColor()) {
                    colorMode(colors[0]);
                } else {
                    colorMode(accentColor);
                }
                ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(),
                        ((ColorDrawable) controlsBg.getBackground()).getColor(), colors[0]);
                colorAnimation.setDuration(250); // milliseconds
                colorAnimation.addUpdateListener(
                        animator -> controlsBg.setBackgroundColor((int) animator.getAnimatedValue()));
                colorAnimation.start();
            }
        };
        if (mVisualizer != null) {
            if (vizualview != null) {
                vizualview.setEnabled(true);
            }
            mVisualizer.setEnabled(true);
        }
    }
}

From source file:com.telenav.nodeflow.NodeFlowLayout.java

/**
 * perform a fade out animation for hiding node content
 *
 * @param node active node//  ww w.ja  v  a 2  s  .co  m
 */
private void fadeOut(final Node<?> node) {
    ValueAnimator animator = ValueAnimator.ofFloat(1, 0);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            for (int i = 1; i < getChildCount(); ++i) {
                getChildAt(i).setAlpha(((Float) animation.getAnimatedValue()));
            }
        }
    });
    animator.addListener(new CustomAnimationListener() {
        @Override
        public void onAnimationEnd(Animator animator) {
            animateDrillOut(node);
        }
    });
    animator.setDuration(duration / 2);
    animator.setInterpolator(new FastOutSlowInInterpolator());
    animator.start();
}

From source file:com.roughike.bottombar.BottomBarTab.java

private void setTopPaddingAnimated(int start, int end) {
    if (type == Type.TABLET || isTitleless) {
        return;// w w w  .j  av  a 2s.  c  om
    }

    ValueAnimator paddingAnimator = ValueAnimator.ofInt(start, end);
    paddingAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            iconView.setPadding(iconView.getPaddingLeft(), (Integer) animation.getAnimatedValue(),
                    iconView.getPaddingRight(), iconView.getPaddingBottom());
        }
    });

    paddingAnimator.setDuration(ANIMATION_DURATION);
    paddingAnimator.start();
}

From source file:com.example.volunteerhandbook.MainActivity.java

void loopNewBox(LinearLayout iBox) {
    if (lastone <= 1) {
        show_what_I_thought();//from w w w. j a v a 2 s .  c o m
        return;
    }
    if (iTh > 3 * thoughts.length + 2) {
        lastone--;
        return;
    }
    float bH = (int) (1.2 * iBox.getHeight());
    iBox.removeAllViews();
    for (int i = 0; i < thoughts.length / 4; i++) {
        iBox.addView(toMove[iTh++ % thoughts.length]);
    }
    //toMove.setTranslationY(600);
    //container.addView(textBox);
    iBox.setX(20);
    iBox.setY(2 * bH);
    //hBox += iBox.getHeight();
    float startY = iBox.getY();
    endY = (-1) * bH;
    int duration = 20000;
    ValueAnimator bounceAnim = ObjectAnimator.ofFloat(iBox, "y", startY, endY);
    bounceAnim.setDuration(duration);
    bounceAnim.setInterpolator(new LinearInterpolator());
    final LinearLayout fBox = iBox;
    bounceAnim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            loopNewBox(fBox);
        }
    });
    bounceAnim.start();
}

From source file:chinanurse.cn.nurse.list.WaveSwipeRefreshLayout.java

private void onDropPhase() {
    mWaveView.animationDropCircle();/*w ww .  j  a va  2s  .  c  o  m*/

    ValueAnimator animator = ValueAnimator.ofFloat(0, 0);
    animator.setDuration(500);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            mCircleView.setTranslationY(mWaveView.getCurrentCircleCenterY() + mCircleView.getHeight() / 2.f);
        }
    });
    animator.start();
    setRefreshing(true, true);
    mIsBeingDropped = true;
    setEventPhase(EVENT_PHASE.DROPPING);
    setEnabled(false);
}

From source file:com.sociablue.nanodegree_p1.MovieListFragment.java

private void initializeFab(View rootView) {
    final RelativeLayout buttonContainer = (RelativeLayout) rootView.findViewById(R.id.menu_button_container);
    final FloatingActionButton Fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
    final ImageView bottomBar = (ImageView) rootView.findViewById(R.id.menu_bottom_bar);
    final ImageView topBar = (ImageView) rootView.findViewById(R.id.menu_top_bar);
    Fab.setOnClickListener(new View.OnClickListener() {
        @TargetApi(Build.VERSION_CODES.LOLLIPOP)
        @Override//  ww  w  . j a  va  2  s  .c  om
        public void onClick(View v) {

            //Menu Button Icon Animation
            //Setting up necessary variables
            long animationDuration = 500;
            float containerHeight = buttonContainer.getHeight();
            float containerCenterY = containerHeight / 2;
            float containerCenterX = buttonContainer.getWidth() / 2;
            float topBarCenter = topBar.getTop() + topBar.getHeight() / 2;
            float widthOfBar = topBar.getWidth();
            float heightOfBar = topBar.getHeight();
            final float distanceBetweenBars = (containerCenterY - topBarCenter);

            /**
             *TODO: Refactor block of code to use Value Property Animator. Should be more efficient to animate multiple properties
             *and objects at the same time. Also, will try to break intialization into smaller functions.
             */

            //Setting up animations of hamburger bars and rotation

            /**
             * Animation For Top Menu Button Icon Bar. Sliding from the top to rest on top of the middle bar.
             * Y Translation is 1/2 the height of the hamburger bar minus the distance.
             * Subtracting the distance from the height because the distance between bars is
             * calculated of the exact center of the button.
             * With out the subtraction the bar would translate slightly below the middle bar.
             */
            float yTranslation = heightOfBar / 2 - distanceBetweenBars;
            float xTranslation = widthOfBar / 2 + heightOfBar / 2;
            TranslateAnimation topBarTranslationAnim = new TranslateAnimation(Animation.ABSOLUTE, 0f,
                    Animation.ABSOLUTE, 0F, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, distanceBetweenBars);
            topBarTranslationAnim.setDuration((long) (animationDuration * 0.8));
            topBarTranslationAnim.setFillAfter(true);

            //Animation for bottom hamburger bar. Translates and Rotates to create 'X'
            AnimationSet bottomBarAnimation = new AnimationSet(true);
            bottomBarAnimation.setFillAfter(true);

            //Rotate to create cross. (The cross becomes the X after the button rotation completes"
            RotateAnimation bottomBarRotationAnimation = new RotateAnimation(0f, 90f,
                    Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 1f);
            bottomBarRotationAnimation.setDuration(animationDuration);
            bottomBarAnimation.addAnimation(bottomBarRotationAnimation);

            //Translate to correct X alignment
            TranslateAnimation bottomBarTranslationAnimation = new TranslateAnimation(Animation.ABSOLUTE, 0f,
                    Animation.ABSOLUTE, -xTranslation, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE,
                    -yTranslation);
            bottomBarTranslationAnimation.setDuration(animationDuration);
            bottomBarAnimation.addAnimation(bottomBarTranslationAnimation);

            //Button Specific Animations
            //Rotate Button Container
            RotateAnimation containerRotationAnimation = new RotateAnimation(0, 135f,
                    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            containerRotationAnimation.setDuration(animationDuration);
            containerRotationAnimation.setFillAfter(true);

            //Animate change of button color between Active and Disabled colors that have been
            //defined in color.xml
            int activeColor = getResources().getColor(R.color.active_button);
            int disabledColor = getResources().getColor(R.color.disabled_button);

            //Need to use ValueAnimator because property animator does not support BackgroundTint
            ValueAnimator buttonColorAnimation = ValueAnimator.ofArgb(activeColor, disabledColor);
            buttonColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    Fab.setBackgroundTintList(ColorStateList.valueOf((int) animation.getAnimatedValue()));
                }
            });
            buttonColorAnimation.setDuration(animationDuration);

            //Start all the animations
            topBar.startAnimation(topBarTranslationAnim);
            bottomBar.startAnimation(bottomBarAnimation);
            buttonContainer.startAnimation(containerRotationAnimation);
            buttonColorAnimation.start();

            //Toogle mMenu open and closed
            if (mMenu.isOpen()) {
                //If mMenu is open, do the reverse of the animation
                containerRotationAnimation
                        .setInterpolator(new ReverseInterpolator(new AccelerateInterpolator()));
                topBarTranslationAnim.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator()));
                bottomBarAnimation.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator()));
                buttonColorAnimation.setInterpolator(new ReverseInterpolator(new LinearInterpolator()));
                mMenu.close();
            } else {
                bottomBarAnimation.setInterpolator(new AccelerateInterpolator());
                mMenu.open();
            }
        }
    });
}

From source file:com.tiancaicc.springfloatingactionmenu.SpringFloatingActionMenu.java

private void fadeIn() {
    int colorFrom = Color.parseColor("#00000000");
    int colorTo = Color.parseColor("#40000000");
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    colorAnimation.setDuration(250); // milliseconds
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override/*ww w .  j  av  a 2s. c  o m*/
        public void onAnimationUpdate(ValueAnimator animator) {
            setBackgroundColor((int) animator.getAnimatedValue());
        }

    });
    colorAnimation.start();
}