List of usage examples for android.animation ObjectAnimator addListener
public void addListener(AnimatorListener listener)
From source file:com.itsronald.widget.IndicatorDotPathView.java
/** * Animation: fill out the connecting center dot path to form a straight path between the two * dots./*from w w w. j a v a2s .c om*/ * * @return An animator that grows pathCenter to the appropriate height. */ @NonNull private Animator centerSegmentGrowAnimator() { final float fromScale = 0f, toScale = 1f; final ObjectAnimator growAnimator; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { final PropertyValuesHolder scaleYProperty = PropertyValuesHolder.ofFloat(View.SCALE_Y, fromScale, toScale); growAnimator = ObjectAnimator.ofPropertyValuesHolder(centerSegment, scaleYProperty); } else { growAnimator = ObjectAnimator.ofFloat(centerSegment, "scaleY", fromScale, toScale); } // Start growing when the two ends of the path meet in the middle. final long animationDuration = PATH_STRETCH_ANIM_DURATION / 4; growAnimator.setStartDelay(animationDuration); growAnimator.setDuration(animationDuration); growAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); centerSegment.setVisibility(VISIBLE); } }); return growAnimator; }
From source file:cc.flydev.launcher.Folder.java
public void animateClosed() { if (!(getParent() instanceof DragLayer)) return;/*from ww w.j a v a2s. co m*/ PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0.9f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0.9f); final ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY); oa.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { onCloseComplete(); setLayerType(LAYER_TYPE_NONE, null); mState = STATE_SMALL; } @Override public void onAnimationStart(Animator animation) { sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, getContext().getString(R.string.folder_closed)); mState = STATE_ANIMATING; } }); oa.setDuration(mExpandDuration); setLayerType(LAYER_TYPE_HARDWARE, null); oa.start(); }
From source file:com.sysdata.widget.accordion.ItemAnimator.java
@Override public boolean animateMove(final ViewHolder holder, int fromX, int fromY, int toX, int toY) { endAnimation(holder);/*from ww w .j av a 2 s . com*/ final int deltaX = toX - fromX; final int deltaY = toY - fromY; final long moveDuration = getMoveDuration(); if (deltaX == 0 && deltaY == 0) { dispatchMoveFinished(holder); return false; } final View view = holder.itemView; final float prevTranslationX = view.getTranslationX(); final float prevTranslationY = view.getTranslationY(); view.setTranslationX(-deltaX); view.setTranslationY(-deltaY); final ObjectAnimator moveAnimator; if (deltaX != 0 && deltaY != 0) { final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f); final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX, moveY); } else if (deltaX != 0) { final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX); } else { final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveY); } moveAnimator.setDuration(moveDuration); moveAnimator.setInterpolator(new FastOutSlowInInterpolator()); moveAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchMoveStarting(holder); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(holder); view.setTranslationX(prevTranslationX); view.setTranslationY(prevTranslationY); dispatchMoveFinished(holder); } }); mMoveAnimatorsList.add(moveAnimator); mAnimators.put(holder, moveAnimator); return true; }
From source file:cc.flydev.launcher.Folder.java
public void animateOpen() { positionAndSizeAsIcon();/*from w w w . j a va2 s. c om*/ if (!(getParent() instanceof DragLayer)) return; centerAboutIcon(); PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f); final ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY); oa.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, String.format(getContext().getString(R.string.folder_opened), mContent.getCountX(), mContent.getCountY())); mState = STATE_ANIMATING; } @Override public void onAnimationEnd(Animator animation) { mState = STATE_OPEN; setLayerType(LAYER_TYPE_NONE, null); Cling cling = mLauncher.showFirstRunFoldersCling(); if (cling != null) { cling.bringScrimToFront(); bringToFront(); cling.bringToFront(); } setFocusOnFirstChild(); } }); oa.setDuration(mExpandDuration); setLayerType(LAYER_TYPE_HARDWARE, null); oa.start(); }
From source file:com.android.clear.reminder.ItemAnimator.java
@Override public boolean animateMove(final ViewHolder holder, int fromX, int fromY, int toX, int toY) { endAnimation(holder);//w ww.jav a2 s .c om final int deltaX = toX - fromX; final int deltaY = toY - fromY; final long moveDuration = getMoveDuration(); if (deltaX == 0 && deltaY == 0) { dispatchMoveFinished(holder); return false; } final View view = holder.itemView; final float prevTranslationX = view.getTranslationX(); final float prevTranslationY = view.getTranslationY(); view.setTranslationX(-deltaX); view.setTranslationY(-deltaY); final ObjectAnimator moveAnimator; if (deltaX != 0 && deltaY != 0) { final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f); final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX, moveY); } else if (deltaX != 0) { final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX); } else { final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveY); } moveAnimator.setDuration(moveDuration); moveAnimator.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN); moveAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchMoveStarting(holder); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(holder); view.setTranslationX(prevTranslationX); view.setTranslationY(prevTranslationY); dispatchMoveFinished(holder); } }); mMoveAnimatorsList.add(moveAnimator); mAnimators.put(holder, moveAnimator); return true; }
From source file:com.lichen.teacher.apps.ActivityLive.java
private void startEditContainViewAnim() { if (!mEditContainViewVisibility) return;//from w ww. j a v a 2s . c o m mEditContainView.setVisibility(View.VISIBLE); ObjectAnimator mEditContainViewAnim = ObjectAnimator.ofFloat(mEditContainView, "alpha", 1, 0) .setDuration(300); mEditContainViewAnim.addListener(mEditContainViewAnimListener); mEditContainViewAnim.start(); mEditContainViewVisibility = false; }
From source file:com.lichen.teacher.apps.ActivityLive.java
private void startHideControlBtnContainViewAnim() { mControlBtnContainView.setVisibility(View.VISIBLE); ObjectAnimator mmControlBtnContainViewAnim = ObjectAnimator.ofFloat(mControlBtnContainView, "alpha", 1, 0) .setDuration(300);/*from w ww . j a va 2s . c o m*/ mmControlBtnContainViewAnim.addListener(mHideControlBtnContainViewAnimListener); mmControlBtnContainViewAnim.start(); }
From source file:com.example.launcher3.Folder.java
public void animateOpen() { positionAndSizeAsIcon();//from w w w . j a va2 s . com if (!(getParent() instanceof DragLayer)) return; centerAboutIcon(); PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f); final ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY); oa.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, String.format(getContext().getString(R.string.folder_opened), mContent.getCountX(), mContent.getCountY())); mState = STATE_ANIMATING; } @Override public void onAnimationEnd(Animator animation) { mState = STATE_OPEN; setLayerType(LAYER_TYPE_NONE, null); /* * Cling cling = mLauncher.showFirstRunFoldersCling(); if (cling * != null) { cling.bringScrimToFront(); bringToFront(); * cling.bringToFront(); } */ setFocusOnFirstChild(); } }); oa.setDuration(mExpandDuration); setLayerType(LAYER_TYPE_HARDWARE, null); oa.start(); }
From source file:com.gitstudy.rili.liarbry.CalendarLayout.java
/** * /*from ww w .j a v a 2 s . c o m*/ * * @return ?? */ public boolean expand() { if (isAnimating || mCalendarShowMode == CALENDAR_SHOW_MODE_ONLY_WEEK_VIEW || mContentView == null) return false; if (mMonthView.getVisibility() != VISIBLE) { mWeekPager.setVisibility(GONE); onShowMonthView(); mMonthView.setVisibility(VISIBLE); } ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mContentView, "translationY", mContentView.getTranslationY(), 0f); objectAnimator.setDuration(240); objectAnimator.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float currentValue = (Float) animation.getAnimatedValue(); float percent = currentValue * 1.0f / mContentViewTranslateY; mMonthView.setTranslationY(mViewPagerTranslateY * percent); isAnimating = true; } }); objectAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); isAnimating = false; hideWeek(); } }); objectAnimator.start(); return true; }
From source file:com.gitstudy.rili.liarbry.CalendarLayout.java
/** * /*from w w w . ja v a 2 s . c om*/ * * @return ? */ public boolean shrink() { if (isAnimating || mContentView == null) { return false; } ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mContentView, "translationY", mContentView.getTranslationY(), -mContentViewTranslateY); objectAnimator.setDuration(240); objectAnimator.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float currentValue = (Float) animation.getAnimatedValue(); float percent = currentValue * 1.0f / mContentViewTranslateY; mMonthView.setTranslationY(mViewPagerTranslateY * percent); isAnimating = true; } }); objectAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); isAnimating = false; showWeek(); } }); objectAnimator.start(); return true; }