Search in sources :

Example 16 with AnimatorSet

use of com.nineoldandroids.animation.AnimatorSet in project Carbon by ZieIony.

the class RippleForeground method createSoftwareEnter.

@Override
protected Animator createSoftwareEnter(boolean fast) {
    // Bounded ripples don't have enter animations.
    if (mIsBounded) {
        return null;
    }
    final int duration = (int) (1000 * Math.sqrt(mTargetRadius / WAVE_TOUCH_DOWN_ACCELERATION * mDensity) + 0.5);
    final ObjectAnimator tweenRadius = ObjectAnimator.ofFloat(this, TWEEN_RADIUS, 1);
    AnimatorsCompat.setAutoCancel(tweenRadius);
    //  tweenRadius.setAutoCancel(true);
    tweenRadius.setDuration(duration);
    tweenRadius.setInterpolator(LINEAR_INTERPOLATOR);
    tweenRadius.setStartDelay(RIPPLE_ENTER_DELAY);
    final ObjectAnimator tweenOrigin = ObjectAnimator.ofFloat(this, TWEEN_ORIGIN, 1);
    AnimatorsCompat.setAutoCancel(tweenOrigin);
    // tweenOrigin.setAutoCancel(true);
    tweenOrigin.setDuration(duration);
    tweenOrigin.setInterpolator(LINEAR_INTERPOLATOR);
    tweenOrigin.setStartDelay(RIPPLE_ENTER_DELAY);
    final ObjectAnimator opacity = ObjectAnimator.ofFloat(this, OPACITY, 1);
    AnimatorsCompat.setAutoCancel(opacity);
    // opacity.setAutoCancel(true);
    opacity.setDuration(OPACITY_ENTER_DURATION_FAST);
    opacity.setInterpolator(LINEAR_INTERPOLATOR);
    final AnimatorSet set = new AnimatorSet();
    set.play(tweenOrigin).with(tweenRadius).with(opacity);
    return set;
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet) Paint(android.graphics.Paint)

Example 17 with AnimatorSet

use of com.nineoldandroids.animation.AnimatorSet in project Carbon by ZieIony.

the class RippleBackground method createSoftwareExit.

@Override
protected Animator createSoftwareExit() {
    final AnimatorSet set = new AnimatorSet();
    // Linear exit after enter is completed.
    final ObjectAnimator exit = ObjectAnimator.ofFloat(this, RippleBackground.OPACITY, 0);
    exit.setInterpolator(LINEAR_INTERPOLATOR);
    exit.setDuration(OPACITY_EXIT_DURATION);
    AnimatorsCompat.setAutoCancel(exit);
    //exit.setAutoCancel(true);
    final AnimatorSet.Builder builder = set.play(exit);
    // Linear "fast" enter based on current opacity.
    final int fastEnterDuration = (int) ((1 - mOpacity) * OPACITY_ENTER_DURATION_FAST);
    if (fastEnterDuration > 0) {
        final ObjectAnimator enter = ObjectAnimator.ofFloat(this, RippleBackground.OPACITY, 1);
        enter.setInterpolator(LINEAR_INTERPOLATOR);
        enter.setDuration(fastEnterDuration);
        AnimatorsCompat.setAutoCancel(enter);
        //enter.setAutoCancel(true);
        builder.after(enter);
    }
    return set;
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet) Paint(android.graphics.Paint)

Example 18 with AnimatorSet

use of com.nineoldandroids.animation.AnimatorSet in project ListViewAnimations by nhaarman.

the class SwipeTouchListener method flingView.

/**
     * Flings given {@link android.view.View} out of sight.
     *
     * @param view         the parent {@link android.view.View}.
     * @param position     the position of the item in the {@link android.widget.ListAdapter} corresponding to the {@code View}.
     * @param flingToRight {@code true} if the {@code View} should be flinged to the right, {@code false} if it should be flinged to the left.
     */
private void flingView(@NonNull final View view, final int position, final boolean flingToRight) {
    if (mViewWidth < 2) {
        mViewWidth = mListViewWrapper.getListView().getWidth();
    }
    View swipeView = getSwipeView(view);
    ObjectAnimator xAnimator = ObjectAnimator.ofFloat(swipeView, TRANSLATION_X, flingToRight ? mViewWidth : -mViewWidth);
    ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(swipeView, ALPHA, 0);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(xAnimator, alphaAnimator);
    animatorSet.setDuration(mAnimationTime);
    animatorSet.addListener(new FlingAnimatorListener(view, position));
    animatorSet.start();
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 19 with AnimatorSet

use of com.nineoldandroids.animation.AnimatorSet in project ListViewAnimations by nhaarman.

the class SwipeUndoTouchListener method undo.

/**
     * Performs the undo animation and restores the original state for given {@link android.view.View}.
     *
     * @param view the parent {@code View} which contains both primary and undo {@code View}s.
     */
public void undo(@NonNull final View view) {
    int position = AdapterViewUtil.getPositionForView(getListViewWrapper(), view);
    mUndoPositions.remove(position);
    View primaryView = mCallback.getPrimaryView(view);
    View undoView = mCallback.getUndoView(view);
    primaryView.setVisibility(View.VISIBLE);
    ObjectAnimator undoAlphaAnimator = ObjectAnimator.ofFloat(undoView, ALPHA, 1f, 0f);
    ObjectAnimator primaryAlphaAnimator = ObjectAnimator.ofFloat(primaryView, ALPHA, 0f, 1f);
    ObjectAnimator primaryXAnimator = ObjectAnimator.ofFloat(primaryView, TRANSLATION_X, primaryView.getWidth(), 0f);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(undoAlphaAnimator, primaryAlphaAnimator, primaryXAnimator);
    animatorSet.addListener(new UndoAnimatorListener(undoView));
    animatorSet.start();
    mCallback.onUndo(view, position);
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet) View(android.view.View)

Example 20 with AnimatorSet

use of com.nineoldandroids.animation.AnimatorSet in project ListViewAnimations by nhaarman.

the class ViewAnimator method animateView.

/**
     * Animates given View.
     *
     * @param view the View that should be animated.
     */
private void animateView(final int position, @NonNull final View view, @NonNull final Animator[] animators) {
    if (mAnimationStartMillis == -1) {
        mAnimationStartMillis = SystemClock.uptimeMillis();
    }
    ViewHelper.setAlpha(view, 0);
    AnimatorSet set = new AnimatorSet();
    set.playTogether(animators);
    set.setStartDelay(calculateAnimationDelay(position));
    set.setDuration(mAnimationDurationMillis);
    set.start();
    mAnimators.put(view.hashCode(), set);
}
Also used : AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Aggregations

AnimatorSet (com.nineoldandroids.animation.AnimatorSet)57 ObjectAnimator (com.nineoldandroids.animation.ObjectAnimator)42 Animator (com.nineoldandroids.animation.Animator)24 AnimatorListenerAdapter (com.nineoldandroids.animation.AnimatorListenerAdapter)11 View (android.view.View)6 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)4 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)4 SuppressLint (android.annotation.SuppressLint)3 Paint (android.graphics.Paint)3 OvershootInterpolator (android.view.animation.OvershootInterpolator)3 Point (android.graphics.Point)2 DisplayMetrics (android.util.DisplayMetrics)2 LinearInterpolator (android.view.animation.LinearInterpolator)2 AdapterView (android.widget.AdapterView)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)2 IDetailView (com.yydcdut.note.views.note.IDetailView)2 FontTextView (com.yydcdut.note.widget.FontTextView)2 RevealView (com.yydcdut.note.widget.RevealView)2