List of usage examples for android.animation ObjectAnimator ofFloat
public static <T> ObjectAnimator ofFloat(T target, Property<T, Float> property, float... values)
From source file:fr.paug.droidcon.util.LPreviewUtilsBase.java
public void setOrAnimatePlusCheckIcon(final ImageView imageView, boolean isCheck, boolean allowAnimate, int resIdChecked) { final int imageResId = isCheck ? resIdChecked : R.drawable.add_schedule_button_icon_unchecked; if (imageView.getTag() != null) { if (imageView.getTag() instanceof Animator) { Animator anim = (Animator) imageView.getTag(); anim.end();/*from w ww .j a va 2s . c o m*/ imageView.setAlpha(1f); } } if (allowAnimate && isCheck) { int duration = mActivity.getResources().getInteger(android.R.integer.config_shortAnimTime); Animator outAnimator = ObjectAnimator.ofFloat(imageView, View.ALPHA, 0f); outAnimator.setDuration(duration / 2); outAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { imageView.setImageResource(imageResId); } }); AnimatorSet inAnimator = new AnimatorSet(); outAnimator.setDuration(duration); inAnimator.playTogether(ObjectAnimator.ofFloat(imageView, View.ALPHA, 1f), ObjectAnimator.ofFloat(imageView, View.SCALE_X, 0f, 1f), ObjectAnimator.ofFloat(imageView, View.SCALE_Y, 0f, 1f)); AnimatorSet set = new AnimatorSet(); set.playSequentially(outAnimator, inAnimator); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { imageView.setTag(null); } }); imageView.setTag(set); set.start(); } else { mHandler.post(new Runnable() { @Override public void run() { imageView.setImageResource(imageResId); } }); } }
From source file:com.google.samples.apps.iosched.util.LPreviewUtilsBase.java
public void setOrAnimatePlusCheckIcon(final ImageView imageView, boolean isCheck, boolean allowAnimate) { final int imageResId = isCheck ? R.drawable.add_schedule_button_icon_checked : R.drawable.add_schedule_button_icon_unchecked; if (imageView.getTag() != null) { if (imageView.getTag() instanceof Animator) { Animator anim = (Animator) imageView.getTag(); anim.end();//from w ww .j ava2 s.c o m imageView.setAlpha(1f); } } if (allowAnimate && isCheck) { int duration = mActivity.getResources().getInteger(android.R.integer.config_shortAnimTime); Animator outAnimator = ObjectAnimator.ofFloat(imageView, View.ALPHA, 0f); outAnimator.setDuration(duration / 2); outAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { imageView.setImageResource(imageResId); } }); AnimatorSet inAnimator = new AnimatorSet(); outAnimator.setDuration(duration); inAnimator.playTogether(ObjectAnimator.ofFloat(imageView, View.ALPHA, 1f), ObjectAnimator.ofFloat(imageView, View.SCALE_X, 0f, 1f), ObjectAnimator.ofFloat(imageView, View.SCALE_Y, 0f, 1f)); AnimatorSet set = new AnimatorSet(); set.playSequentially(outAnimator, inAnimator); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { imageView.setTag(null); } }); imageView.setTag(set); set.start(); } else { mHandler.post(new Runnable() { @Override public void run() { imageView.setImageResource(imageResId); } }); } }
From source file:arun.com.chromer.shared.views.TabView.java
private void unSelectedAnimation() { clearAnimations();// w w w . j a va2s. c om final AnimatorSet transformAnimator = new AnimatorSet(); transformAnimator.playTogether(ObjectAnimator.ofFloat(tabIcon, "translationX", initialIconX), ObjectAnimator.ofFloat(tabIcon, "scaleX", 0.75f), ObjectAnimator.ofFloat(tabIcon, "scaleY", 0.75f), ObjectAnimator.ofFloat(text, "scaleX", 1f), ObjectAnimator.ofFloat(text, "scaleY", 1f), ObjectAnimator.ofFloat(text, "alpha", 1f)); transformAnimator.setDuration(275); transformAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); final AnimatorSet sequentialAnimator = new AnimatorSet(); sequentialAnimator.playTogether(transformAnimator, getIconUnSelectionAnimator()); sequentialAnimator.start(); }
From source file:com.myhexaville.iconanimations.gooey_fab.GooeyFab.java
void onElevationsChanged(final float elevation, final float pressedTranslationZ) { final StateListAnimator stateListAnimator = new StateListAnimator(); // Animate elevation and translationZ to our values when pressed AnimatorSet set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(this, "elevation", elevation).setDuration(0)).with(ObjectAnimator .ofFloat(this, View.TRANSLATION_Z, pressedTranslationZ).setDuration(PRESSED_ANIM_DURATION)); set.setInterpolator(ANIM_INTERPOLATOR); stateListAnimator.addState(PRESSED_ENABLED_STATE_SET, set); // Same deal for when we're focused set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(this, "elevation", elevation).setDuration(0)).with(ObjectAnimator .ofFloat(this, View.TRANSLATION_Z, pressedTranslationZ).setDuration(PRESSED_ANIM_DURATION)); set.setInterpolator(ANIM_INTERPOLATOR); stateListAnimator.addState(FOCUSED_ENABLED_STATE_SET, set); // Animate translationZ to 0 if not pressed set = new AnimatorSet(); // Use an AnimatorSet to set a start delay since there is a bug with ValueAnimator that // prevents it from being cancelled properly when used with a StateListAnimator. AnimatorSet anim = new AnimatorSet(); anim.play(ObjectAnimator.ofFloat(this, View.TRANSLATION_Z, 0f).setDuration(PRESSED_ANIM_DURATION)) .after(PRESSED_ANIM_DURATION); set.play(ObjectAnimator.ofFloat(this, "elevation", elevation).setDuration(0)).with(anim); set.setInterpolator(ANIM_INTERPOLATOR); stateListAnimator.addState(ENABLED_STATE_SET, set); // Animate everything to 0 when disabled set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(this, "elevation", 0f).setDuration(0)) .with(ObjectAnimator.ofFloat(this, View.TRANSLATION_Z, 0f).setDuration(0)); set.setInterpolator(ANIM_INTERPOLATOR); stateListAnimator.addState(EMPTY_STATE_SET, set); setStateListAnimator(stateListAnimator); }
From source file:com.github.shareme.gwsmaterialuikit.library.viewanimator.AnimationBuilder.java
/** * Rotation x animation builder.//from ww w .jav a 2 s. com * * @param pivotX the rotation x * @return the animation builder */ public AnimationBuilder pivotX(float... pivotX) { ObjectAnimator.ofFloat(getView(), "pivotX", getValues(pivotX)); return this; }
From source file:com.github.shareme.gwsmaterialuikit.library.viewanimator.AnimationBuilder.java
public AnimationBuilder pivotY(float... pivotY) { ObjectAnimator.ofFloat(getView(), "pivotY", getValues(pivotY)); return this; }
From source file:arun.com.chromer.shared.views.TabView.java
private void selectedAnimation() { clearAnimations();/*ww w . j a v a2s.c om*/ final AnimatorSet transformAnimator = new AnimatorSet(); transformAnimator.playTogether(ObjectAnimator.ofFloat(tabIcon, "translationX", getIconCentreInLayout()), ObjectAnimator.ofFloat(tabIcon, "scaleX", 1f), ObjectAnimator.ofFloat(tabIcon, "scaleY", 1f), ObjectAnimator.ofFloat(text, "scaleX", 0f), ObjectAnimator.ofFloat(text, "scaleY", 0f), ObjectAnimator.ofFloat(text, "alpha", 0f)); transformAnimator.setDuration(275); transformAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); final AnimatorSet togetherAnimator = new AnimatorSet(); togetherAnimator.playSequentially(transformAnimator, getIconSelectionAnimator()); togetherAnimator.start(); }
From source file:com.tmall.wireless.tangram.ext.SwipeItemTouchListener.java
private void resetViews(RecyclerView recyclerView, final int swipingType, final boolean reachActionEdge, final int direction) { int contentWidth = recyclerView.getWidth(); AnimatorSet animatorSet = new AnimatorSet(); List<Animator> list = new ArrayList<>(); String translation = "translationX"; if (swipingType == SWIPING_VER) { translation = "translationY"; }//from ww w. j av a2 s .c o m for (View view : mChildList) { ObjectAnimator animator; if (reachActionEdge) { animator = ObjectAnimator.ofFloat(view, translation, contentWidth * direction) .setDuration(ANIMATE_DURATION); animator.setInterpolator(new AccelerateInterpolator()); } else { animator = ObjectAnimator.ofFloat(view, translation, 0).setDuration(ANIMATE_DURATION); animator.setInterpolator(new DecelerateInterpolator()); } list.add(animator); } animatorSet.playTogether(list); animatorSet.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { if (swipingType == SWIPING_HOR && reachActionEdge) { if (mSwipeCardRef != null && mSwipeCardRef.get() != null) { SwipeCard swipeCard = mSwipeCardRef.get(); swipeCard.switchTo(swipeCard.getCurrentIndex() - direction); } } mChildList.clear(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); animatorSet.start(); if (swipingType == SWIPING_VER) { if (pullFromEndListener != null) { if (mDistanceY < 0 && (mDistanceY < -pullFromEndListener.getPullEdge())) { pullFromEndListener.onAction(); } else { pullFromEndListener.onReset(); } } } swipeType = SWIPING_NONE; }
From source file:com.tmall.wireless.tangram3.ext.SwipeItemTouchListener.java
private void resetViews(RecyclerView recyclerView, final int swipingType, final boolean reachActionEdge, final int direction) { if (enableAnim) { int contentWidth = recyclerView.getWidth(); AnimatorSet animatorSet = new AnimatorSet(); List<Animator> list = new ArrayList<>(); String translation = "translationX"; if (swipingType == SWIPING_VER) { translation = "translationY"; }//from w ww. j av a2 s . co m for (View view : mChildList) { ObjectAnimator animator; if (reachActionEdge) { animator = ObjectAnimator.ofFloat(view, translation, contentWidth * direction) .setDuration(ANIMATE_DURATION); animator.setInterpolator(new AccelerateInterpolator()); } else { animator = ObjectAnimator.ofFloat(view, translation, 0).setDuration(ANIMATE_DURATION); animator.setInterpolator(new DecelerateInterpolator()); } list.add(animator); } animatorSet.playTogether(list); animatorSet.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { if (swipingType == SWIPING_HOR && reachActionEdge) { if (mSwipeCardRef != null && mSwipeCardRef.get() != null) { SwipeCard swipeCard = mSwipeCardRef.get(); swipeCard.switchTo(swipeCard.getCurrentIndex() - direction); } } mChildList.clear(); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); animatorSet.start(); } else { if (swipingType == SWIPING_HOR && reachActionEdge) { if (mSwipeCardRef != null && mSwipeCardRef.get() != null) { SwipeCard swipeCard = mSwipeCardRef.get(); swipeCard.switchTo(swipeCard.getCurrentIndex() - direction); } } mChildList.clear(); } if (swipingType == SWIPING_VER) { if (pullFromEndListener != null) { if (mDistanceY < 0 && (mDistanceY < -pullFromEndListener.getPullEdge())) { pullFromEndListener.onAction(); } else { pullFromEndListener.onReset(); } } } swipeType = SWIPING_NONE; }
From source file:com.telenav.expandablepager.SlidingContainer.java
/** * Animate translationY to the next stopValue * @param amount translationY amount/*from w w w . j ava 2 s .c om*/ * @param duration animation duration * @param interpolator animation interpolator */ private void animate(final float amount, int duration, Interpolator interpolator) { ObjectAnimator oa = ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, amount).setDuration(duration); oa.setInterpolator(interpolator); oa.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { notifySlideEvent(Math.round(((Float) animation.getAnimatedValue()))); } }); oa.addListener(new CustomAnimationListener() { @Override public void onAnimationEnd(Animator animator) { onSettled(stopValueIndex); } }); oa.start(); }