List of usage examples for android.support.v4.view ViewPropertyAnimatorCompat setListener
public ViewPropertyAnimatorCompat setListener(ViewPropertyAnimatorListener viewPropertyAnimatorListener)
From source file:android.support.v7.widget.AbsActionBarView.java
public ViewPropertyAnimatorCompat setupAnimatorToVisibility(int visibility, long duration) { if (mVisibilityAnim != null) { mVisibilityAnim.cancel();// ww w.ja v a2s . c om } if (visibility == VISIBLE) { if (getVisibility() != VISIBLE) { ViewCompat.setAlpha(this, 0f); } ViewPropertyAnimatorCompat anim = ViewCompat.animate(this).alpha(1f); anim.setDuration(duration); anim.setListener(mVisAnimListener.withFinalVisibility(anim, visibility)); return anim; } else { ViewPropertyAnimatorCompat anim = ViewCompat.animate(this).alpha(0f); anim.setDuration(duration); anim.setListener(mVisAnimListener.withFinalVisibility(anim, visibility)); return anim; } }
From source file:android.support.v7.internal.view.ViewPropertyAnimatorCompatSet.java
public void start() { if (mIsStarted) return;// ww w . j a v a2 s . com for (ViewPropertyAnimatorCompat animator : mAnimators) { if (mDuration >= 0) { animator.setDuration(mDuration); } if (mInterpolator != null) { animator.setInterpolator(mInterpolator); } if (mListener != null) { animator.setListener(mProxyListener); } animator.start(); } mIsStarted = true; }
From source file:jp.wasabeef.recyclerview.animators.change.TinyScaleAnimate.java
public void animateChange(final RecyclerView.ViewHolder oldHolder, final RecyclerView.ViewHolder newHolder, int fromX, int fromY, int toX, int toY) { final long duration = (long) (0.5f * mDispatcher.getChangeDuration()); if (oldHolder.itemView != null) { final ViewPropertyAnimatorCompat oldViewAnim = ViewCompat.animate(oldHolder.itemView); oldViewAnim.translationX(toX - fromX); oldViewAnim.translationY(toY - fromY); oldViewAnim.setDuration(duration); oldViewAnim.scaleX(SCALE_VALUE).scaleY(SCALE_VALUE); oldViewAnim.setListener(new ViewPropertyAnimatorListener() { @Override/* w w w.j ava 2 s. co m*/ public void onAnimationStart(View view) { mDispatcher.dispatchChangeStarting(oldHolder, true); } @Override public void onAnimationEnd(View view) { oldViewAnim.setListener(null); ViewCompat.setAlpha(view, 1); ViewCompat.setTranslationX(view, 0); ViewCompat.setTranslationY(view, 0); mDispatcher.dispatchChangeFinished(oldHolder, true); if (newHolder.itemView != null) { ViewCompat.setScaleX(newHolder.itemView, SCALE_VALUE); ViewCompat.setScaleY(newHolder.itemView, SCALE_VALUE); ViewCompat.setAlpha(newHolder.itemView, 1.f); final ViewPropertyAnimatorCompat newViewAnimation = ViewCompat.animate(newHolder.itemView); newViewAnimation.translationX(0).translationY(0); newViewAnimation.scaleX(1.f).scaleY(1.f); newViewAnimation.setDuration(duration); newViewAnimation.setListener(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(View view) { mDispatcher.dispatchChangeStarting(newHolder, false); } @Override public void onAnimationEnd(View view) { newViewAnimation.setListener(null); ViewCompat.setAlpha(view, 1); ViewCompat.setTranslationX(view, 0); ViewCompat.setTranslationY(view, 0); mDispatcher.dispatchChangeFinished(newHolder, false); } @Override public void onAnimationCancel(View view) { ViewHelper.clear(view); } }).start(); } } @Override public void onAnimationCancel(View view) { ViewHelper.clear(view); } }).start(); } }
From source file:com.github.shareme.gwsmaterialuikit.library.advancerv.draggable.BaseDraggableItemDecorator.java
protected void moveToDefaultPosition(View targetView, boolean animate) { final int curTranslationX = (int) (ViewCompat.getTranslationX(targetView)); final int curTranslationY = (int) (ViewCompat.getTranslationY(targetView)); final int halfItemWidth = targetView.getWidth() / 2; final int halfItemHeight = targetView.getHeight() / 2; final float translationProportionX = (halfItemWidth > 0) ? Math.abs((float) curTranslationX / halfItemWidth) : 0;//from w w w . j av a 2 s. c o m final float translationProportionY = (halfItemHeight > 0) ? Math.abs((float) curTranslationY / halfItemHeight) : 0; final float tx = 1.0f - Math.min(translationProportionX, 1.0f); final float ty = 1.0f - Math.min(translationProportionY, 1.0f); final int animDurationX = (int) (mReturnToDefaultPositionDuration * (1.0f - (tx * tx)) + 0.5f); final int animDurationY = (int) (mReturnToDefaultPositionDuration * (1.0f - (ty * ty)) + 0.5f); final int animDuration = Math.max(animDurationX, animDurationY); final int maxAbsTranslation = Math.max(Math.abs(curTranslationX), Math.abs(curTranslationY)); if (supportsViewPropertyAnimation() && animate && (animDuration > RETURN_TO_DEFAULT_POS_ANIMATE_THRESHOLD_MSEC) && (maxAbsTranslation > mReturnToDefaultPositionAnimateThreshold)) { final ViewPropertyAnimatorCompat animator = ViewCompat.animate(targetView); animator.cancel(); animator.setDuration(animDuration); animator.setInterpolator(mReturnToDefaultPositionInterpolator); animator.translationX(0.0f); animator.translationY(0.0f); animator.setListener(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(View view) { } @Override public void onAnimationEnd(View view) { animator.setListener(null); ViewCompat.setTranslationX(view, 0); ViewCompat.setTranslationY(view, 0); // invalidate explicitly to refresh other decorations if (view.getParent() instanceof RecyclerView) { ViewCompat.postInvalidateOnAnimation((RecyclerView) view.getParent()); } } @Override public void onAnimationCancel(View view) { } }); animator.start(); } else { ViewCompat.setTranslationX(targetView, 0); ViewCompat.setTranslationY(targetView, 0); } }
From source file:aloha.shiningstarbase.util.itemanimator.SlideInOutBottomItemAnimator.java
protected void animateRemoveImpl(final RecyclerView.ViewHolder holder) { final View view = holder.itemView; final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view); mRemoveAnimations.add(holder);/* w ww .j ava 2 s . co m*/ animation.setDuration(getRemoveDuration()).alpha(0).translationY(+mDeltaY) .setListener(new VpaListenerAdapter() { @Override public void onAnimationStart(View view) { dispatchRemoveStarting(holder); } @Override public void onAnimationEnd(View view) { animation.setListener(null); ViewCompat.setAlpha(view, 1); ViewCompat.setTranslationY(view, +mDeltaY); dispatchRemoveFinished(holder); mRemoveAnimations.remove(holder); dispatchFinishedWhenDone(); } }).start(); }
From source file:aloha.shiningstarbase.util.itemanimator.SlideInOutTopItemAnimator.java
protected void animateRemoveImpl(final RecyclerView.ViewHolder holder) { final View view = holder.itemView; retrieveItemHeight(holder);//from w ww . j av a 2 s .com final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view); mRemoveAnimations.add(holder); animation.setDuration(getRemoveDuration()).alpha(0).translationY(-mOriginalY) .setListener(new VpaListenerAdapter() { @Override public void onAnimationStart(View view) { dispatchRemoveStarting(holder); } @Override public void onAnimationEnd(View view) { animation.setListener(null); ViewCompat.setAlpha(view, 1); ViewCompat.setTranslationY(view, -mOriginalY); dispatchRemoveFinished(holder); mRemoveAnimations.remove(holder); dispatchFinishedWhenDone(); } }).start(); }
From source file:aloha.shiningstarbase.util.itemanimator.ScaleInOutItemAnimator.java
protected void animateRemoveImpl(final RecyclerView.ViewHolder holder) { final View view = holder.itemView; final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view); mRemoveAnimations.add(holder);//w ww .j a v a2 s . co m animation.setDuration(getRemoveDuration()).alpha(0).scaleX(0).scaleY(0) .setListener(new VpaListenerAdapter() { @Override public void onAnimationStart(View view) { dispatchRemoveStarting(holder); } @Override public void onAnimationEnd(View view) { animation.setListener(null); ViewCompat.setAlpha(view, 1); ViewCompat.setScaleX(view, 0); ViewCompat.setScaleY(view, 0); dispatchRemoveFinished(holder); mRemoveAnimations.remove(holder); dispatchFinishedWhenDone(); } }).start(); }
From source file:com.kozhevin.example.carousel.CarouselItemAnimator.java
private void animateRemoveImpl(final ViewHolder pHolder) { final View view = pHolder.itemView; ViewCompat.animate(view).cancel();// ww w . jav a 2 s . c o m if (getTranslationValueY() != 0 && mIsUseTranslationAnimation) { ViewPropertyAnimatorCompat lViewPropertyAnimatorCompat = ViewCompat.animate(view); lViewPropertyAnimatorCompat.setDuration(350); lViewPropertyAnimatorCompat.translationY(getTranslationValueY()); lViewPropertyAnimatorCompat.setListener(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(View arg0) { } @Override public void onAnimationEnd(View arg0) { animateAlhaRemove(view, pHolder); } @Override public void onAnimationCancel(View arg0) { } }); ViewCompat.animate(view).start(); } else { if (mIsUseTranslationAnimation) { view.setAlpha(0f); mIsUseTranslationAnimation = true; } animateAlhaRemove(view, pHolder); } mRemoveAnimations.add(pHolder); }
From source file:io.apptik.multiview.animators.FlexiItemAnimator.java
@Override protected void animateChangeImpl(final BaseItemAnimator.ChangeInfo changeInfo) { final RecyclerView.ViewHolder holder = changeInfo.oldHolder; final View view = holder == null ? null : holder.itemView; final RecyclerView.ViewHolder newHolder = changeInfo.newHolder; final View newView = newHolder != null ? newHolder.itemView : null; if (view != null && vpaChnageOld != null) { mChangeAnimations.add(changeInfo.oldHolder); Runnable beforeAction = vpaChnageOld.getBeforeAction(holder, changeInfo); if (beforeAction != null) { beforeAction.run();/* ww w .j a v a2 s .co m*/ } final ViewPropertyAnimatorCompat oldViewAnim = vpaChnageOld.getAnim(changeInfo.oldHolder, changeInfo) .setDuration(getChangeDuration()); if (ipChangeOld != null) { oldViewAnim.setInterpolator(ipChangeOld); } oldViewAnim.setListener(new VoidVpaListener() { @Override public void onAnimationStart(View view) { Log.v("start change old anim: " + view); dispatchChangeStarting(changeInfo.oldHolder, true); } @Override public void onAnimationCancel(View view) { Log.v("cancel change old anim: " + view); resetView(view); } @Override public void onAnimationEnd(View view) { Log.v("end change old anim: " + view); oldViewAnim.setListener(null); Log.v("end change old anim before: " + view); resetView(view); Log.v("end change old anim after: " + view); dispatchChangeFinished(changeInfo.oldHolder, true); mChangeAnimations.remove(changeInfo.oldHolder); dispatchFinishedWhenDone(); } }).start(); } else { dispatchChangeFinished(changeInfo.oldHolder, true); dispatchFinishedWhenDone(); } if (newView != null && vpaChangeNew != null) { mChangeAnimations.add(changeInfo.newHolder); Runnable beforeAction = vpaChangeNew.getBeforeAction(holder, changeInfo); if (beforeAction != null) { beforeAction.run(); } final ViewPropertyAnimatorCompat newViewAnimation = vpaChangeNew.getAnim(changeInfo.newHolder, changeInfo); if (ipChangeNew != null) { newViewAnimation.setInterpolator(ipChangeNew); } newViewAnimation.setDuration(getChangeDuration()).setListener(new VoidVpaListener() { @Override public void onAnimationStart(View view) { Log.v("start change new anim: " + view); dispatchChangeStarting(changeInfo.newHolder, false); } @Override public void onAnimationCancel(View view) { Log.v("cancel change new anim: " + view); resetView(view); } @Override public void onAnimationEnd(View view) { Log.v("end change new anim: " + view); newViewAnimation.setListener(null); resetView(view); dispatchChangeFinished(changeInfo.newHolder, false); mChangeAnimations.remove(changeInfo.newHolder); dispatchFinishedWhenDone(); } }).start(); } else { // dispatchChangeFinished(changeInfo.newHolder, false); dispatchFinishedWhenDone(); } }
From source file:aloha.shiningstarbase.util.itemanimator.SlideInOutRightItemAnimator.java
protected void animateRemoveImpl(final RecyclerView.ViewHolder holder) { final View view = holder.itemView; final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view); mRemoveAnimations.add(holder);/* w w w. ja va 2s. c o m*/ animation.setDuration(getRemoveDuration()).alpha(0) .translationX(+mRecyclerView.getLayoutManager().getWidth()).setListener(new VpaListenerAdapter() { @Override public void onAnimationStart(View view) { dispatchRemoveStarting(holder); } @Override public void onAnimationEnd(View view) { animation.setListener(null); ViewCompat.setAlpha(view, 1); ViewCompat.setTranslationX(view, +mRecyclerView.getLayoutManager().getWidth()); dispatchRemoveFinished(holder); mRemoveAnimations.remove(holder); dispatchFinishedWhenDone(); } }).start(); }