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: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);/* w  w w  . j  a v a  2s . c  om*/
    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.geecko.QuickLyric.adapter.IntroScreenSlidePagerAdapter.java

public IntroScreenSlidePagerAdapter(FragmentManager fm, final Activity activity) {
    super(fm);/*from  ww  w . j a  v  a  2s .com*/
    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();
        }
    });
}

From source file:com.ymt.demo1.plates.eduPlane.myStudy.MyStudyFragment.java

private void animateToolbar(final float toY) {
    float layoutTranslationY = ViewHelper.getTranslationY(mInterceptionLayout);
    if (layoutTranslationY != toY) {
        ValueAnimator animator = ValueAnimator.ofFloat(ViewHelper.getTranslationY(mInterceptionLayout), toY)
                .setDuration(200);//from  w w  w .j a v  a  2  s .c  o  m
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                float translationY = (float) animation.getAnimatedValue();
                View infoView = getActivity().findViewById(R.id.personal_info_layout);
                ViewHelper.setTranslationY(mInterceptionLayout, translationY);
                ViewHelper.setTranslationY(infoView, translationY);
                if (translationY < 0) {
                    FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mInterceptionLayout
                            .getLayoutParams();
                    lp.height = (int) (-translationY + getScreenHeight());
                    mInterceptionLayout.requestLayout();
                }
            }
        });
        animator.start();
    }
}

From source file:com.justplay1.shoppist.features.search.widget.FloatingSearchView.java

private void fadeIn(boolean enter) {
    ValueAnimator backgroundAnim;

    if (Build.VERSION.SDK_INT >= 19) {
        backgroundAnim = ObjectAnimator.ofInt(backgroundDrawable, "alpha", enter ? 255 : 0);
    } else {/*w ww. j  a  va 2s  .  c o  m*/
        backgroundAnim = ValueAnimator.ofInt(enter ? 0 : 255, enter ? 255 : 0);
        backgroundAnim.addUpdateListener(animation -> {
            int value = (Integer) animation.getAnimatedValue();
            backgroundDrawable.setAlpha(value);
        });
    }

    backgroundAnim.setDuration(enter ? DEFAULT_DURATION_ENTER : DEFAULT_DURATION_EXIT);
    backgroundAnim.setInterpolator(enter ? DECELERATE : ACCELERATE);
    backgroundAnim.start();

    Drawable icon = unwrap(getIcon());

    if (icon != null) {
        ObjectAnimator iconAnim = ObjectAnimator.ofFloat(icon, "progress", enter ? 1 : 0);
        iconAnim.setDuration(backgroundAnim.getDuration());
        iconAnim.setInterpolator(backgroundAnim.getInterpolator());
        iconAnim.start();
    }
}

From source file:com.quanliren.quan_one.pull.swipe.SwipeRefreshLayout.java

private ValueAnimator startAlphaAnimation(final int startingAlpha, final int endingAlpha) {
    // Pre API 11, alpha is used in place of scale. Don't also use it to
    // show the trigger point.
    if (mScale && isAlphaUsedForScale()) {
        return null;
    }/*from ww w  .j a va 2 s  . c  om*/
    ValueAnimator alpha = new ObjectAnimator().ofFloat(0f, 1f);
    alpha.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mProgress.setAlpha((int) (startingAlpha + ((endingAlpha - startingAlpha)
                    * Float.valueOf(animation.getAnimatedValue().toString()))));
        }
    });
    alpha.setDuration(ALPHA_ANIMATION_DURATION);
    alpha.start();
    return alpha;
}

From source file:com.velli.passwordmanager.ActivityMain.java

public boolean lockDrawer(final boolean lock, boolean animate) {
    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    boolean locked = isDrawerLocked();

    if (drawer != null && lock != locked) {
        if (lock) {
            drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
        } else {/* www  . j a  v a2  s .  co  m*/
            drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
            if (!animate) {
                initDrawer();
            }
        }

        if (animate) {
            final ValueAnimator anim = ValueAnimator.ofFloat(lock ? 0 : 1, lock ? 1 : 0);
            anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    float slideOffset = (Float) valueAnimator.getAnimatedValue();
                    mToolbarDrawerToggle.onDrawerSlide(drawer, slideOffset);
                }
            });
            anim.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    anim.removeAllUpdateListeners();
                    if (!lock) {
                        initDrawer();
                    }
                    animation.removeAllListeners();
                }
            });
            anim.setInterpolator(new DecelerateInterpolator());
            anim.setDuration(500);
            anim.start();
        } else {
            mToolbarDrawerToggle.onDrawerSlide(drawer, lock ? 1 : 0);

        }
        return true;
    }
    return false;
}

From source file:Steps.StepsFragment.java

public void animateTextView(int initialValue, int finalValue, final TextView textview) {

    ValueAnimator valueAnimator = null;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        valueAnimator = ValueAnimator.ofInt((int) initialValue, (int) finalValue);

        valueAnimator.setDuration(1500);

        valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @TargetApi(Build.VERSION_CODES.HONEYCOMB)
            @Override/*from w  w  w.  ja v  a2s  .c  o  m*/
            public void onAnimationUpdate(ValueAnimator valueAnimator) {

                textview.setText(valueAnimator.getAnimatedValue().toString());

            }
        });
        valueAnimator.start();

    }
}

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

/**
 * perform alpha animation associated with closing or opening a node
 *
 * @param startIndex start index of child views to be animated
 * @param endIndex   end index of child views to be animated
 * @param destAlpha  final alpha of child views to be animated
 *///w  ww. ja  v  a  2 s .  c o  m
private void animateDrillAlpha(final int startIndex, final int endIndex, final int destAlpha) {
    ValueAnimator animator = ValueAnimator.ofFloat(1 - destAlpha, destAlpha);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            for (int i = startIndex; i < endIndex; ++i) {
                getChildAt(i).setAlpha(((Float) animation.getAnimatedValue()));
            }
        }
    });
    animator.addListener(new CustomAnimationListener() {
        @Override
        public void onAnimationStart(Animator animator) {
            for (int i = startIndex; i < getChildCount(); ++i) {
                getChildAt(i).setAlpha(1 - destAlpha);
            }
        }
    });
    animator.setDuration(duration);
    if (destAlpha == 1)
        animator.setInterpolator(new AccelerateInterpolator());
    else
        animator.setInterpolator(new DecelerateInterpolator(2));
    animator.start();
}

From source file:com.dmallcott.progressfloatingactionbutton.ProgressView.java

public void setCurrentProgress(int currentProgress, boolean animate) {
    // If the view is animating no further actions are allowed
    if (isAnimating)
        return;// w w  w.  j  a va  2 s  .co m

    if (this.mTargetProgress >= mTotalProgress)
        this.mTargetProgress = mTotalProgress;
    else
        this.mTargetProgress = currentProgress;

    if (animate && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // Animations are only available from API 11 and forth
        ValueAnimator va = ValueAnimator.ofInt(mCurrentProgress, mTargetProgress);
        va.setInterpolator(new AccelerateDecelerateInterpolator());
        va.setDuration(mAnimationDuration);
        va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @TargetApi(Build.VERSION_CODES.HONEYCOMB)
            public void onAnimationUpdate(ValueAnimator animation) {
                mCurrentProgress = (Integer) animation.getAnimatedValue();
                ProgressView.this.invalidate();
            }
        });
        va.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {
                isAnimating = true;
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                isAnimating = false;
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                isAnimating = false;
            }

            @Override
            public void onAnimationRepeat(Animator animation) {
                isAnimating = true;
            }
        });
        va.start();
    } else {
        mCurrentProgress = mTargetProgress;
        invalidate();
    }

    if (this.mTargetProgress == mTotalProgress)
        mListener.onProgressCompleted();
}

From source file:co.ceryle.segmentedbutton.SegmentedButtonGroup.java

private void expand(final View v, Interpolator interpolator, int duration, int targetWidth) {

    int prevWidth = v.getWidth();

    ValueAnimator valueAnimator = ValueAnimator.ofInt(prevWidth, targetWidth);
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override//  w  w  w.  ja v a  2  s.  c  o  m
        public void onAnimationUpdate(ValueAnimator animation) {
            v.getLayoutParams().width = (int) animation.getAnimatedValue();
            v.requestLayout();
        }
    });
    valueAnimator.setInterpolator(interpolator);
    valueAnimator.setDuration(duration);
    valueAnimator.start();
}