com.nineoldandroids.animation.AnimatorListenerAdapter Java Examples
The following examples show how to use
com.nineoldandroids.animation.AnimatorListenerAdapter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SwipeDismissListViewTouchListener.java From example with Apache License 2.0 | 6 votes |
private void dismiss(final View view, final int position, final boolean dismissRight) { ++mDismissAnimationRefCount; if (view == null) { // No view, shortcut to calling onDismiss to let it deal with adapter // updates and all that. mCallbacks.onDismiss(mListView, new int[] { position }, dismissRight); return; } animate(view) .translationX(dismissRight ? mViewWidth : -mViewWidth) .alpha(0) .setDuration(mAnimationTime) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { performDismiss(view, position, dismissRight); } }); }
Example #2
Source File: AnimUtils.java From PaymentKit-Droid with Apache License 2.0 | 6 votes |
/** * @param shouldResetTextColor if true make sure you end the previous animation before starting this one. */ public static ObjectAnimator getShakeAnimation(final TextView textView, final boolean shouldResetTextColor) { final int textColor = textView.getCurrentTextColor(); textView.setTextColor(Color.RED); ObjectAnimator shakeAnim = ObjectAnimator.ofFloat(textView, "translationX", -16); shakeAnim.setDuration(SHAKE_DURATION); shakeAnim.setInterpolator(new CycleInterpolator(2.0f)); shakeAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator anim) { if (shouldResetTextColor) { textView.setTextColor(textColor); } } }); return shakeAnim; }
Example #3
Source File: SwipeDismissListViewTouchListener.java From android-open-project-demo with Apache License 2.0 | 6 votes |
protected void performDismiss(final PendingDismissData data) { // Animate the dismissed list item to zero-height and fire the // dismiss callback when all dismissed list item animations have // completed. final ViewGroup.LayoutParams lp = data.view.getLayoutParams(); final int originalHeight = data.view.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(final ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); data.view.setLayoutParams(lp); } }); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(final Animator animation) { finalizeDismiss(); } }); animator.start(); }
Example #4
Source File: TestFragment.java From CardView with MIT License | 6 votes |
public void show(final View view,Bundle bundle){ view.setEnabled(false); this.view = view; String text = bundle.getString("text"); tv.setText(text); ViewHelper.setRotationY(view, 0); ViewHelper.setRotationY(root, -90); root.setVisibility(View.VISIBLE); ViewPropertyAnimator.animate(view).rotationY(90) .setDuration(300).setListener(null) .setInterpolator(new AccelerateInterpolator()); ViewPropertyAnimator.animate(root) .rotationY(0).setDuration(200).setStartDelay(300) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { ViewHelper.setRotationY(view, 0); } }); }
Example #5
Source File: EnhancedListView.java From UltimateAndroid with Apache License 2.0 | 6 votes |
/** * Slide out a view to the right or left of the list. After the animation has finished, the * view will be dismissed by calling {@link #performDismiss(android.view.View, android.view.View, int)}. * * @param view The view, that should be slided out. * @param childView The whole view of the list item. * @param position The item position of the item. * @param toRightSide Whether it should slide out to the right side. */ private void slideOutView(final View view, final View childView, final int position, boolean toRightSide) { // Only start new animation, if this view isn't already animated (too fast swiping bug) synchronized (mAnimationLock) { if (mAnimatedViews.contains(view)) { return; } ++mDismissAnimationRefCount; mAnimatedViews.add(view); } ViewPropertyAnimator.animate(view) .translationX(toRightSide ? mViewWidth : -mViewWidth) //.alpha(0) .setDuration(mAnimationTime) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { performDismiss(view, childView, position); } }); }
Example #6
Source File: SwipeDismissListViewTouchListener.java From UltimateAndroid with Apache License 2.0 | 6 votes |
protected void performDismiss(final PendingDismissData data) { // Animate the dismissed list item to zero-height and fire the // dismiss callback when all dismissed list item animations have // completed. final ViewGroup.LayoutParams lp = data.view.getLayoutParams(); final int originalHeight = data.view.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(final ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); data.view.setLayoutParams(lp); } }); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(final Animator animation) { finalizeDismiss(); } }); animator.start(); }
Example #7
Source File: CardView.java From example with Apache License 2.0 | 6 votes |
/** * Expanding animator. */ private void animateExpanding() { if (getOnExpandListAnimatorListener()!=null){ //List Animator getOnExpandListAnimatorListener().onExpandStart(mCard.getCardView(), mContentParent); }else{ //Std animator mContentParent.setVisibility(View.VISIBLE); mExpandAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCard.setExpanded(true); //Callback if (mCard.getOnExpandAnimatorEndListener()!=null) mCard.getOnExpandAnimatorEndListener().onExpandEnd(mCard); } }); mExpandAnimator.start(); } }
Example #8
Source File: UndoBarController.java From example with Apache License 2.0 | 6 votes |
public void hideUndoBar(boolean immediate) { mHideHandler.removeCallbacks(mHideRunnable); if (immediate) { mBarView.setVisibility(View.GONE); ViewHelper.setAlpha(mBarView, 0); mUndoMessage = null; mUndoToken = null; } else { mBarAnimator.cancel(); mBarAnimator .alpha(0) .setDuration(mBarView.getResources() .getInteger(android.R.integer.config_shortAnimTime)) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mBarView.setVisibility(View.GONE); mUndoMessage = null; mUndoToken = null; } }); } }
Example #9
Source File: FloatingLabelLayout.java From FloatingLabelLayout with Apache License 2.0 | 6 votes |
/** * Hide the label using an animation */ private void hideLabel() { ViewHelper.setAlpha(mLabel, 1f); ViewHelper.setTranslationY(mLabel, 0f); ViewPropertyAnimator.animate(mLabel) .alpha(0f) .translationY(mLabel.getHeight()) .setDuration(ANIMATION_DURATION) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mLabel.setVisibility(View.GONE); } }).start(); }
Example #10
Source File: FloatingLabelEditText.java From FloatingLabelLayout with Apache License 2.0 | 6 votes |
/** * Hide the label using an animation */ private void hideLabel() { ViewHelper.setAlpha(mLabel, 1f); ViewHelper.setTranslationY(mLabel, 0f); ViewPropertyAnimator.animate(mLabel) .alpha(0f) .translationY(mLabel.getHeight()) .setDuration(ANIMATION_DURATION) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mLabel.setVisibility(View.GONE); } }).start(); }
Example #11
Source File: HeaderHolder.java From HollyViewPager with Apache License 2.0 | 6 votes |
public void animateEnabled(boolean enabled) { if(animator != null) { animator.cancel(); animator = null; } if (enabled) { animator = ObjectAnimator.ofFloat(view, "alpha", 1f); } else animator = ObjectAnimator.ofFloat(view, "alpha", 0.5f); animator.setDuration(300); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); animator = null; } }); animator.start(); }
Example #12
Source File: BaseRippleDrawable.java From android-base-mvp with Apache License 2.0 | 6 votes |
void onFingerUp() { if (mCurrentAnimator != null) { mCurrentAnimator.end(); mCurrentAnimator = null; createTouchRipple(END_RIPPLE_TOUCH_RADIUS); } mCurrentAnimator = ObjectAnimator.ofFloat(this, DESTROY_TOUCH_RIPPLE, 0f, 1f); mCurrentAnimator.setDuration(DEFAULT_ANIM_DURATION); mCurrentAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mCurrentAnimator = null; } }); mCurrentAnimator.start(); }
Example #13
Source File: SwipeListViewTouchListener.java From browser with GNU General Public License v2.0 | 5 votes |
/** * Create dismiss animation * * @param view affected view * @param swap If will change state. If is "false" returns to the original position * @param swapRight If swap is true, this parameter tells if move is to the right or left * @param position Position of list */ private void generateDismissAnimate(final View view, final boolean swap, final boolean swapRight, final int position) { int moveTo = 0; if (opened.get(position)) { if (!swap) { moveTo = openedRight.get(position) ? (int) (viewWidth - rightOffset) : (int) (-viewWidth + leftOffset); } } else { if (swap) { moveTo = swapRight ? (int) (viewWidth - rightOffset) : (int) (-viewWidth + leftOffset); } } int alpha = 1; if (swap) { ++dismissAnimationRefCount; alpha = 0; } animate(view) .translationX(moveTo) .alpha(alpha) .setDuration(animationTime) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (swap) { closeOpenedItems(); performDismiss(view, position, true); } resetCell(); } }); }
Example #14
Source File: SwipeListViewTouchListener.java From browser with GNU General Public License v2.0 | 5 votes |
/** * Perform dismiss action * * @param dismissView View * @param dismissPosition Position of list */ protected void performDismiss(final View dismissView, final int dismissPosition, boolean doPendingDismiss) { final ViewGroup.LayoutParams lp = dismissView.getLayoutParams(); final int originalHeight = dismissView.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(animationTime); if (doPendingDismiss) { animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { --dismissAnimationRefCount; if (dismissAnimationRefCount == 0) { removePendingDismisses(originalHeight); } } }); } animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); dismissView.setLayoutParams(lp); } }); pendingDismisses.add(new PendingDismissData(dismissPosition, dismissView)); animator.start(); }
Example #15
Source File: SwipeListViewTouchListener.java From browser with GNU General Public License v2.0 | 5 votes |
/** * Create reveal animation * * @param view affected view * @param swap If will change state. If "false" returns to the original position * @param swapRight If swap is true, this parameter tells if movement is toward right or left * @param position list position */ private void generateRevealAnimate(final View view, final boolean swap, final boolean swapRight, final int position) { int moveTo = 0; if (opened.get(position)) { if (!swap) { moveTo = openedRight.get(position) ? (int) (viewWidth - rightOffset) : (int) (-viewWidth + leftOffset); } } else { if (swap) { moveTo = swapRight ? (int) (viewWidth - rightOffset) : (int) (-viewWidth + leftOffset); } } animate(view) .translationX(moveTo) .setDuration(animationTime) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { swipeListView.resetScrolling(); if (swap) { boolean aux = !opened.get(position); opened.set(position, aux); if (aux) { swipeListView.onOpened(position, swapRight); openedRight.set(position, swapRight); } else { swipeListView.onClosed(position, openedRight.get(position)); } } resetCell(); } }); }
Example #16
Source File: AnimateDismissAdapter.java From android-open-project-demo with Apache License 2.0 | 5 votes |
/** * Animate dismissal of the items at given positions. */ public void animateDismiss(final Collection<Integer> positions) { final List<Integer> positionsCopy = new ArrayList<Integer>(positions); if (getAbsListView() == null) { throw new IllegalStateException("Call setAbsListView() on this AnimateDismissAdapter before calling setAdapter()!"); } List<View> views = getVisibleViewsForPositions(positionsCopy); if (!views.isEmpty()) { List<Animator> animators = new ArrayList<Animator>(); for (final View view : views) { animators.add(createAnimatorForView(view)); } AnimatorSet animatorSet = new AnimatorSet(); Animator[] animatorsArray = new Animator[animators.size()]; for (int i = 0; i < animatorsArray.length; i++) { animatorsArray[i] = animators.get(i); } animatorSet.playTogether(animatorsArray); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(final Animator animator) { invokeCallback(positionsCopy); } }); animatorSet.start(); } else { invokeCallback(positionsCopy); } }
Example #17
Source File: SwipeListViewTouchListener.java From android-stickyheaderswipelistview with Apache License 2.0 | 5 votes |
/** * Create dismiss animation * @param view affected view * @param swap If will change state. If is "false" returns to the original position * @param swapRight If swap is true, this parameter tells if move is to the right or left * @param position Position of list */ private void generateDismissAnimate(final View view, final boolean swap, final boolean swapRight, final int position) { int moveTo = 0; if (opened.get(position)) { if (!swap) { moveTo = openedRight.get(position) ? (int) (viewWidth - rightOffset) : (int) (-viewWidth + leftOffset); } } else { if (swap) { moveTo = swapRight ? (int) (viewWidth - rightOffset) : (int) (-viewWidth + leftOffset); } } int alpha = 1; if (swap) { ++dismissAnimationRefCount; alpha = 0; } animate(view) .translationX(moveTo) .alpha(alpha) .setDuration(animationTime) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (swap) { performDismiss(view, position); } } }); }
Example #18
Source File: AnimateDismissAdapter.java From UltimateAndroid with Apache License 2.0 | 5 votes |
/** * Animate dismissal of the items at given positions. */ public void animateDismiss(final Collection<Integer> positions) { final List<Integer> positionsCopy = new ArrayList<Integer>(positions); if (getAbsListView() == null) { throw new IllegalStateException("Call setAbsListView() on this AnimateDismissAdapter before calling setAdapter()!"); } List<View> views = getVisibleViewsForPositions(positionsCopy); if (!views.isEmpty()) { List<Animator> animators = new ArrayList<Animator>(); for (final View view : views) { animators.add(createAnimatorForView(view)); } AnimatorSet animatorSet = new AnimatorSet(); Animator[] animatorsArray = new Animator[animators.size()]; for (int i = 0; i < animatorsArray.length; i++) { animatorsArray[i] = animators.get(i); } animatorSet.playTogether(animatorsArray); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(final Animator animator) { invokeCallback(positionsCopy); } }); animatorSet.start(); } else { invokeCallback(positionsCopy); } }
Example #19
Source File: SwipeDismissList.java From sms-ticket with Apache License 2.0 | 5 votes |
private void performDismiss(final View dismissView, final int dismissPosition) { // Animate the dismissed list item to zero-height and notifyTicket the dismiss callback when // all dismissed list item animations have completed. This triggers layout on each animation // frame; in the future we may want to do something smarter and more performant. mPendingDismisses.add(new PendingDismissData(dismissPosition, dismissView)); if (dismissView != null) { final ViewGroup.LayoutParams lp = dismissView.getLayoutParams(); final int originalHeight = dismissView.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { finishDismiss(originalHeight); } }); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); dismissView.setLayoutParams(lp); } }); animator.start(); } else { finishDismiss(0); } }
Example #20
Source File: SwipeListViewTouchListener.java From android-stickyheaderswipelistview with Apache License 2.0 | 5 votes |
/** * Create reveal animation * @param view affected view * @param swap If will change state. If "false" returns to the original position * @param swapRight If swap is true, this parameter tells if movement is toward right or left * @param position list position */ private void generateRevealAnimate(final View view, final boolean swap, final boolean swapRight, final int position) { int moveTo = 0; if (opened.get(position)) { if (!swap) { moveTo = openedRight.get(position) ? (int) (viewWidth - rightOffset) : (int) (-viewWidth + leftOffset); } } else { if (swap) { moveTo = swapRight ? (int) (viewWidth - rightOffset) : (int) (-viewWidth + leftOffset); } } animate(view) .translationX(moveTo) .setDuration(animationTime) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { swipeListView.resetScrolling(); if (swap) { boolean aux = !opened.get(position); opened.set(position, aux); if (aux) { swipeListView.onOpened(position, swapRight); openedRight.set(position, swapRight); } else { swipeListView.onClosed(position, openedRight.get(position)); } } } }); }
Example #21
Source File: ViewCompatImpl.java From Android-UndoBar with MIT License | 5 votes |
@Override void animateOut(long duration, final AnimatorListener animatorListener) { mViewPropertyAnimator.cancel(); mViewPropertyAnimator.alpha(0)// .setDuration(duration)// .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { animatorListener.onAnimationEnd(); } }); }
Example #22
Source File: CellViewHolder.java From MaterialLeanBack with Apache License 2.0 | 5 votes |
public void enlarge(boolean withAnimation) { if (!enlarged && settings.animateCards) { if (currentAnimator != null) { currentAnimator.cancel(); currentAnimator = null; } int duration = withAnimation ? 300 : 0; adapter.itemPosition = getAdapterPosition(); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.setDuration(duration); List<Animator> animatorList = new ArrayList<>(); animatorList.add(ObjectAnimator.ofFloat(cardView, "scaleX", scaleEnlarged)); animatorList.add(ObjectAnimator.ofFloat(cardView, "scaleY", scaleEnlarged)); if (settings.overlapCards) { //animatorList.add(ObjectAnimator.ofFloat(cardView, "translationX", translationX)); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { cardView.setCardElevation(settings.elevationEnlarged); currentAnimator = null; } }); } animatorSet.playTogether(animatorList); currentAnimator = animatorSet; animatorSet.start(); enlarged = true; } }
Example #23
Source File: CellViewHolder.java From MaterialLeanBack with Apache License 2.0 | 5 votes |
public void reduce(boolean withAnimation) { if (enlarged && settings.animateCards) { if (currentAnimator != null) { currentAnimator.cancel(); currentAnimator = null; } int duration = withAnimation ? 300 : 0; AnimatorSet animatorSet = new AnimatorSet(); animatorSet.setDuration(duration); List<Animator> animatorList = new ArrayList<>(); animatorList.add(ObjectAnimator.ofFloat(cardView, "scaleX", scaleReduced)); animatorList.add(ObjectAnimator.ofFloat(cardView, "scaleY", scaleReduced)); if (settings.overlapCards) { //animatorList.add(ObjectAnimator.ofFloat(cardView, "translationX", translationX)); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { cardView.setCardElevation(settings.elevationReduced); currentAnimator = null; } }); } animatorSet.playTogether(animatorList); currentAnimator = animatorSet; animatorSet.start(); enlarged = false; } }
Example #24
Source File: SwipeListViewTouchListener.java From browser with GNU General Public License v2.0 | 5 votes |
/** * Create choice animation * * @param view affected view * @param position list position */ private void generateChoiceAnimate(final View view, final int position) { animate(view) .translationX(0) .setDuration(animationTime) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { swipeListView.resetScrolling(); resetCell(); } }); }
Example #25
Source File: SwipeDismissViewTouchListener.java From example with Apache License 2.0 | 5 votes |
private void performDismiss(final boolean dismissRight) { // Animate the dismissed view to zero-height and then fire the dismiss callback. // This triggers layout on each animation frame; in the future we may want to do something // smarter and more performant. final ViewGroup.LayoutParams lp = mCardView.getLayoutParams(); final int originalHeight = mCardView.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1) .setDuration(mAnimationTime); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCallbacks.onDismiss(mCardView,mToken, dismissRight); // Reset view presentation ViewHelper.setAlpha(mCardView,1f); ViewHelper.setTranslationX(mCardView, 0); //ViewGroup.LayoutParams lp = mCardView.getLayoutParams(); lp.height = originalHeight; mCardView.setLayoutParams(lp); } }); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); mCardView.setLayoutParams(lp); } }); animator.start(); }
Example #26
Source File: SwipeDismissListViewTouchListener.java From ALLGO with Apache License 2.0 | 5 votes |
protected void performDismiss(final PendingDismissData data) { // Animate the dismissed list item to zero-height and fire the // dismiss callback when all dismissed list item animations have // completed. Log.d("SwipeDismissListViewTouchListener", "performDismiss"); final ViewGroup.LayoutParams lp = data.view.getLayoutParams(); final int originalHeight = data.view.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); data.view.setLayoutParams(lp); } }); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { finalizeDismiss(); } }); animator.start(); }
Example #27
Source File: ExpandableListItemAdapter.java From ListViewAnimations with Apache License 2.0 | 5 votes |
public static void animateCollapsing(final View view) { int origHeight = view.getHeight(); ValueAnimator animator = createHeightAnimator(view, origHeight, 0); animator.addListener( new AnimatorListenerAdapter() { @Override public void onAnimationEnd(final Animator animation) { view.setVisibility(View.GONE); } } ); animator.start(); }
Example #28
Source File: AnimateDismissAdapter.java From ALLGO with Apache License 2.0 | 5 votes |
/** * Animate dismissal of the items at given positions. */ public void animateDismiss(Collection<Integer> positions) { final List<Integer> positionsCopy = new ArrayList<Integer>(positions); if (getAbsListView() == null) { throw new IllegalStateException("Call setAbsListView() on this AnimateDismissAdapter before calling setAdapter()!"); } List<View> views = getVisibleViewsForPositions(positionsCopy); if (!views.isEmpty()) { List<Animator> animators = new ArrayList<Animator>(); for (final View view : views) { animators.add(createAnimatorForView(view)); } AnimatorSet animatorSet = new AnimatorSet(); Animator[] animatorsArray = new Animator[animators.size()]; for (int i = 0; i < animatorsArray.length; i++) { animatorsArray[i] = animators.get(i); } animatorSet.playTogether(animatorsArray); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { invokeCallback(positionsCopy); } }); animatorSet.start(); } else { invokeCallback(positionsCopy); } }
Example #29
Source File: SwipeDismissTouchListener.java From Pimp_my_Z1 with GNU General Public License v2.0 | 5 votes |
private void performDismiss() { // Animate the dismissed view to zero-height and then fire the dismiss // callback. // This triggers layout on each animation frame; in the future we may // want to do something // smarter and more performant. final ViewGroup.LayoutParams lp = mView.getLayoutParams(); final int originalHeight = mView.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1) .setDuration(mAnimationTime); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCallback.onDismiss(mView, mToken); // Reset view presentation setAlpha(mView, 1f); ViewHelper.setTranslationX(mView, 0); // mView.setAlpha(1f); // mView.setTranslationX(0); lp.height = originalHeight; mView.setLayoutParams(lp); } }); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); mView.setLayoutParams(lp); } }); animator.start(); }
Example #30
Source File: MaterialRippleLayoutNineOld.java From AdvancedMaterialDrawer with Apache License 2.0 | 5 votes |
private void startRipple(final Runnable animationEndRunnable) { if (eventCancelled) return; float endRadius = getEndRadius(); cancelAnimations(); rippleAnimator = new AnimatorSet(); rippleAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (!ripplePersistent) { setRadius(0); setRippleAlpha(rippleAlpha); } if (animationEndRunnable != null && rippleDelayClick) { animationEndRunnable.run(); } childView.setPressed(false); } }); ObjectAnimator ripple = ObjectAnimator.ofFloat(this, radiusProperty, radius, endRadius); ripple.setDuration(rippleDuration); ripple.setInterpolator(new DecelerateInterpolator()); ObjectAnimator fade = ObjectAnimator.ofInt(this, circleAlphaProperty, rippleAlpha, 0); fade.setDuration(rippleFadeDuration); fade.setInterpolator(new AccelerateInterpolator()); fade.setStartDelay(rippleDuration - rippleFadeDuration - FADE_EXTRA_DELAY); if (ripplePersistent) { rippleAnimator.play(ripple); } else if (getRadius() > endRadius) { fade.setStartDelay(0); rippleAnimator.play(fade); } else { rippleAnimator.playTogether(ripple, fade); } rippleAnimator.start(); }