List of usage examples for android.animation ValueAnimator getAnimatedValue
public Object getAnimatedValue()
ValueAnimator
when there is just one property being animated. From source file:com.example.administrator.iclub21.view.SlideSwitch.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public void moveToDest(final boolean toRight) { ValueAnimator toDestAnim = ValueAnimator.ofInt(frontRect_left, toRight ? max_left : min_left); toDestAnim.setDuration(500);/* www. j av a 2s. c o m*/ toDestAnim.setInterpolator(new AccelerateDecelerateInterpolator()); toDestAnim.start(); toDestAnim.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { frontRect_left = (Integer) animation.getAnimatedValue(); alpha = (int) (255 * (float) frontRect_left / (float) max_left); invalidateView(); } }); toDestAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (toRight) { isOpen = true; if (listener != null) listener.open(); frontRect_left_begin = max_left; } else { isOpen = false; if (listener != null) listener.close(); frontRect_left_begin = min_left; } } }); }
From source file:com.liujs.library.view.refresh.BGAStickinessRefreshView.java
public void smoothToIdle() { ValueAnimator animator = ValueAnimator.ofInt(mCurrentBottomHeight, 0); animator.setDuration(mStickinessRefreshViewHolder.getTopAnimDuration()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override//w w w . ja v a2s. c o m public void onAnimationUpdate(ValueAnimator animation) { mCurrentBottomHeight = (int) animation.getAnimatedValue(); postInvalidate(); } }); animator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mIsRotating = false; } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); animator.start(); }
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 ww . j a va 2s .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:me.lizheng.deckview.views.DeckChildViewHeader.java
/** * Notifies the associated TaskView has been focused. */// w ww . j a v a2s .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.liujs.library.view.refresh.BGAStickinessRefreshView.java
public void startRefreshing() { ValueAnimator animator = ValueAnimator.ofInt(mCurrentBottomHeight, 0); animator.setDuration(mStickinessRefreshViewHolder.getTopAnimDuration()); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override//from w w w. j ava2s . co m public void onAnimationUpdate(ValueAnimator animation) { mCurrentBottomHeight = (int) animation.getAnimatedValue(); postInvalidate(); } }); animator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { mIsRefreshing = true; if (mCurrentBottomHeight != 0) { mStickinessRefreshViewHolder.startChangeWholeHeaderViewPaddingTop(mCurrentBottomHeight); } else { mStickinessRefreshViewHolder.startChangeWholeHeaderViewPaddingTop( -(mTopSize + getPaddingTop() + getPaddingBottom())); } } @Override public void onAnimationEnd(Animator animation) { mIsRotating = true; startRotating(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); animator.start(); }
From source file:com.example.google.maps.flyover.MainActivity.java
public void animateRoute() { LinkedList<Animator> animators = new LinkedList<Animator>(); // For each segment of the route, create one heading adjustment animator // and one segment fly-over animator. for (int i = 0; i < ROUTE.length - 1; i++) { // If it the first segment, ensure the camera is rotated properly. float h1; if (i == 0) { h1 = mMap.getCameraPosition().bearing; } else {/*from w w w . j av a2 s. c om*/ h1 = (float) SphericalUtil.computeHeading(ROUTE[i - 1], ROUTE[i]); } float h2 = (float) SphericalUtil.computeHeading(ROUTE[i], ROUTE[i + 1]); ValueAnimator va = ValueAnimator.ofFloat(h1, h2); va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1) @Override public void onAnimationUpdate(ValueAnimator animation) { float bearing = (Float) animation.getAnimatedValue(); CameraPosition pos = CameraPosition.builder(mMap.getCameraPosition()).bearing(bearing).build(); mMap.moveCamera(CameraUpdateFactory.newCameraPosition(pos)); } }); // Use the change in degrees of the heading for the animation // duration. long d = Math.round(Math.abs(h1 - h2)); va.setDuration(d * CAMERA_HEADING_CHANGE_RATE); animators.add(va); ObjectAnimator oa = ObjectAnimator.ofObject(mMarker, "position", new LatLngEvaluator(ROUTE[i], ROUTE[i + 1]), ROUTE[i], ROUTE[i + 1]); oa.setInterpolator(new LinearInterpolator()); oa.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { LatLng target = (LatLng) animation.getAnimatedValue(); mMap.moveCamera(CameraUpdateFactory.newLatLng(target)); } }); // Use the distance of the route segment for the duration. double dist = SphericalUtil.computeDistanceBetween(ROUTE[i], ROUTE[i + 1]); oa.setDuration(Math.round(dist) * 10); animators.add(oa); } mAnimatorSet = new AnimatorSet(); mAnimatorSet.playSequentially(animators); mAnimatorSet.start(); mAnimatorSet.addListener(new Animator.AnimatorListener() { @Override public void onAnimationCancel(Animator animation) { mMenu.findItem(R.id.action_animation).setIcon(R.drawable.ic_action_replay); } @Override public void onAnimationEnd(Animator animation) { mMenu.findItem(R.id.action_animation).setIcon(R.drawable.ic_action_replay); } @Override public void onAnimationRepeat(Animator animation) { } @Override public void onAnimationStart(Animator animation) { mMenu.findItem(R.id.action_animation).setIcon(R.drawable.ic_action_stop); } }); }
From source file:com.dean.phonesafe.ui.SlideSwitch.java
public void moveToDest(final boolean toRight) { ValueAnimator toDestAnim = ValueAnimator.ofInt(frontRect_left, toRight ? max_left : min_left); toDestAnim.setDuration(500);// ww w . j a v a 2 s. c o m toDestAnim.setInterpolator(new AccelerateDecelerateInterpolator()); toDestAnim.start(); toDestAnim.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { frontRect_left = (Integer) animation.getAnimatedValue(); alpha = (int) (255 * (float) frontRect_left / (float) max_left); invalidateView(); } }); toDestAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (toRight) { isOpen = true; if (listener != null) listener.open(); frontRect_left_begin = max_left; } else { isOpen = false; if (listener != null) listener.close(); frontRect_left_begin = min_left; } } }); }
From source file:com.alex.view.tab.TabLayout.java
@Override public void onAnimationUpdate(ValueAnimator valueAnimator) { View currentTabView = getChildAt(mCurrentTab); IndicatorPoint p = (IndicatorPoint) valueAnimator.getAnimatedValue(); mIndicatorAnimOffset = (int) p.left - currentTabView.getLeft(); invalidate();//w w w .j ava 2 s.c om }
From source file:com.android.madpausa.cardnotificationviewer.CardElementHolder.java
private void initAnimator() { scroller = new Scroller(root.getContext()); animator = ValueAnimator.ofFloat(1, 0); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override/*from w w w. j a v a2s . c om*/ public void onAnimationUpdate(ValueAnimator animation) { animateScroll(); if (cancel) root.setAlpha((Float) animation.getAnimatedValue()); } }); animator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { root.setLayerType(View.LAYER_TYPE_HARDWARE, null); } @Override public void onAnimationEnd(Animator animation) { endAnimation(); } @Override public void onAnimationCancel(Animator animation) { endAnimation(); } @Override public void onAnimationRepeat(Animator animation) { } private void endAnimation() { root.setTranslationX(scroller.getFinalX()); root.setLayerType(View.LAYER_TYPE_SOFTWARE, null); if (cancel) nService.cancelNotification(sbn); } }); }
From source file:com.audionote.widget.SlideSwitch.java
public void moveToDest(final boolean toRight) { ValueAnimator toDestAnim = ValueAnimator.ofInt(frontRect_left, toRight ? max_left : min_left); toDestAnim.setDuration(200);/* w ww.j av a 2 s .c o m*/ toDestAnim.setInterpolator(new AccelerateDecelerateInterpolator()); toDestAnim.start(); toDestAnim.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { frontRect_left = (Integer) animation.getAnimatedValue(); alpha = (int) (255 * (float) frontRect_left / (float) max_left); invalidateView(); } }); toDestAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (toRight) { isOpen = true; if (listener != null) listener.open(); frontRect_left_begin = max_left; } else { isOpen = false; if (listener != null) listener.close(); frontRect_left_begin = min_left; } } }); }