Search in sources :

Example 41 with Animator

use of com.nineoldandroids.animation.Animator in project PhotoNoter by yydcdut.

the class DetailActivity method initAnimationView.

@Override
public void initAnimationView() {
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.playTogether(ObjectAnimator.ofFloat(mCardView, "translationY", 0, mTranslateHeight));
            animatorSet.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    mOverlayView.setVisibility(View.GONE);
                    mIsIgnoreClick = true;
                }

                @Override
                public void onAnimationStart(Animator animation) {
                    super.onAnimationStart(animation);
                    mIsIgnoreClick = true;
                }
            });
            animatorSet.setDuration(400);
            animatorSet.setInterpolator(new DecelerateInterpolator());
            animatorSet.start();
            mAnimationHandler.postDelayed(mDownDelayRunnable, 350);
        }
    }, 500);
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) Animator(com.nineoldandroids.animation.Animator) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) Handler(android.os.Handler) AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Example 42 with Animator

use of com.nineoldandroids.animation.Animator in project SuperRecyclerView by Malinskiy.

the class SwipeDismissRecyclerViewTouchListener method performDismiss.

private void performDismiss(final View dismissView, final int dismissPosition) {
    // Animate the dismissed list item to zero-height and fire 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.
    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) {
            --mDismissAnimationRefCount;
            if (mDismissAnimationRefCount == 0) {
                // No active animations, process all pending dismisses.
                // Sort by descending position
                Collections.sort(mPendingDismisses);
                int[] dismissPositions = new int[mPendingDismisses.size()];
                for (int i = mPendingDismisses.size() - 1; i >= 0; i--) {
                    dismissPositions[i] = mPendingDismisses.get(i).position;
                }
                mCallbacks.onDismiss(mRecyclerView, dismissPositions);
                // Reset mDownPosition to avoid MotionEvent.ACTION_UP trying to start a dismiss
                // animation with a stale position
                mDownPosition = INVALID_POSITION;
                ViewGroup.LayoutParams lp;
                for (PendingDismissData pendingDismiss : mPendingDismisses) {
                    // Reset view presentation
                    setAlpha(pendingDismiss.view, 1f);
                    setTranslationX(pendingDismiss.view, 0);
                    lp = pendingDismiss.view.getLayoutParams();
                    lp.height = originalHeight;
                    pendingDismiss.view.setLayoutParams(lp);
                }
                // Send a cancel event
                long time = SystemClock.uptimeMillis();
                MotionEvent cancelEvent = MotionEvent.obtain(time, time, MotionEvent.ACTION_CANCEL, 0, 0, 0);
                mRecyclerView.dispatchTouchEvent(cancelEvent);
                mPendingDismisses.clear();
            }
        }
    });
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            lp.height = (Integer) valueAnimator.getAnimatedValue();
            dismissView.setLayoutParams(lp);
        }
    });
    mPendingDismisses.add(new PendingDismissData(dismissPosition, dismissView));
    animator.start();
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) ViewGroup(android.view.ViewGroup) AnimatorListenerAdapter(com.nineoldandroids.animation.AnimatorListenerAdapter) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent)

Example 43 with Animator

use of com.nineoldandroids.animation.Animator in project android-shapeLoadingView by zzz40500.

the class LoadingView method stopLoading.

private void stopLoading() {
    mStopped = true;
    if (mUpAnimatorSet != null) {
        if (mUpAnimatorSet.isRunning()) {
            mUpAnimatorSet.cancel();
        }
        mUpAnimatorSet.removeAllListeners();
        for (Animator animator : mUpAnimatorSet.getChildAnimations()) {
            animator.removeAllListeners();
        }
        mUpAnimatorSet = null;
    }
    if (mDownAnimatorSet != null) {
        if (mDownAnimatorSet.isRunning()) {
            mDownAnimatorSet.cancel();
        }
        mDownAnimatorSet.removeAllListeners();
        for (Animator animator : mDownAnimatorSet.getChildAnimations()) {
            animator.removeAllListeners();
        }
        mDownAnimatorSet = null;
    }
    this.removeCallbacks(mFreeFallRunnable);
}
Also used : Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator)

Example 44 with Animator

use of com.nineoldandroids.animation.Animator in project android-shapeLoadingView by zzz40500.

the class LoadingView method upThrow.

/**
 * 上抛
 */
public void upThrow() {
    if (mUpAnimatorSet == null) {
        ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mShapeLoadingView, "translationY", mDistance, 0);
        ObjectAnimator scaleIndication = ObjectAnimator.ofFloat(mIndicationIm, "scaleX", 1f, 0.2f);
        ObjectAnimator objectAnimator1 = null;
        switch(mShapeLoadingView.getShape()) {
            case SHAPE_RECT:
                objectAnimator1 = ObjectAnimator.ofFloat(mShapeLoadingView, "rotation", 0, 180);
                break;
            case SHAPE_CIRCLE:
                objectAnimator1 = ObjectAnimator.ofFloat(mShapeLoadingView, "rotation", 0, 180);
                break;
            case SHAPE_TRIANGLE:
                objectAnimator1 = ObjectAnimator.ofFloat(mShapeLoadingView, "rotation", 0, 180);
                break;
        }
        mUpAnimatorSet = new AnimatorSet();
        mUpAnimatorSet.playTogether(objectAnimator, objectAnimator1, scaleIndication);
        mUpAnimatorSet.setDuration(ANIMATION_DURATION);
        mUpAnimatorSet.setInterpolator(new DecelerateInterpolator(FACTOR));
        mUpAnimatorSet.addListener(new Animator.AnimatorListener() {

            @Override
            public void onAnimationStart(Animator animation) {
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                if (!mStopped) {
                    freeFall();
                }
            }

            @Override
            public void onAnimationCancel(Animator animation) {
            }

            @Override
            public void onAnimationRepeat(Animator animation) {
            }
        });
    }
    mUpAnimatorSet.start();
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Example 45 with Animator

use of com.nineoldandroids.animation.Animator in project Signal-Android by signalapp.

the class TransferControlView method display.

private void display(@Nullable final View view) {
    final int sourceWidth = current == downloadDetails ? expandedWidth : contractedWidth;
    final int targetWidth = view == downloadDetails ? expandedWidth : contractedWidth;
    if (current == view || current == null) {
        ViewGroup.LayoutParams layoutParams = getLayoutParams();
        layoutParams.width = targetWidth;
        setLayoutParams(layoutParams);
    } else {
        ViewUtil.fadeOut(current, TRANSITION_MS);
        Animator anim = getWidthAnimator(sourceWidth, targetWidth);
        anim.start();
    }
    if (view == null) {
        ViewUtil.fadeOut(this, TRANSITION_MS);
    } else {
        ViewUtil.fadeIn(this, TRANSITION_MS);
        ViewUtil.fadeIn(view, TRANSITION_MS);
    }
    current = view;
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) ViewGroup(android.view.ViewGroup)

Aggregations

Animator (com.nineoldandroids.animation.Animator)139 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)83 AnimatorListenerAdapter (com.nineoldandroids.animation.AnimatorListenerAdapter)67 ObjectAnimator (com.nineoldandroids.animation.ObjectAnimator)53 AnimatorSet (com.nineoldandroids.animation.AnimatorSet)29 StateAnimator (carbon.animation.StateAnimator)28 View (android.view.View)27 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)13 Interpolator (android.view.animation.Interpolator)11 Reveal (carbon.internal.Reveal)11 RecyclerView (android.support.v7.widget.RecyclerView)6 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)6 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)6 ViewGroup (android.view.ViewGroup)5 SimpleItemAnimator (android.support.v7.widget.SimpleItemAnimator)4 OvershootInterpolator (android.view.animation.OvershootInterpolator)4 ArcAnimator (io.codetail.animation.arcanimator.ArcAnimator)4 Paint (android.graphics.Paint)3 Rect (android.graphics.Rect)3 GestureDetector (android.view.GestureDetector)3