Search in sources :

Example 66 with ObjectAnimator

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

the class AnimateAdditionAdapter method getView.

@Override
@NonNull
public View getView(final int position, @Nullable final View convertView, @NonNull final ViewGroup parent) {
    final View view = super.getView(position, convertView, parent);
    if (mInsertQueue.getActiveIndexes().contains(position)) {
        int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(ViewGroup.LayoutParams.MATCH_PARENT, View.MeasureSpec.AT_MOST);
        int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(ViewGroup.LayoutParams.WRAP_CONTENT, View.MeasureSpec.UNSPECIFIED);
        view.measure(widthMeasureSpec, heightMeasureSpec);
        int originalHeight = view.getMeasuredHeight();
        ValueAnimator heightAnimator = ValueAnimator.ofInt(1, originalHeight);
        heightAnimator.addUpdateListener(new HeightUpdater(view));
        Animator[] customAnimators = getAdditionalAnimators(view, parent);
        Animator[] animators = new Animator[customAnimators.length + 1];
        animators[0] = heightAnimator;
        System.arraycopy(customAnimators, 0, animators, 1, customAnimators.length);
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(animators);
        ViewHelper.setAlpha(view, 0);
        ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(view, ALPHA, 0, 1);
        AnimatorSet allAnimatorsSet = new AnimatorSet();
        allAnimatorsSet.playSequentially(animatorSet, alphaAnimator);
        allAnimatorsSet.setDuration(mInsertionAnimationDurationMs);
        allAnimatorsSet.addListener(new ExpandAnimationListener(position));
        allAnimatorsSet.start();
    }
    return view;
}
Also used : ValueAnimator(com.nineoldandroids.animation.ValueAnimator) Animator(com.nineoldandroids.animation.Animator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet) ValueAnimator(com.nineoldandroids.animation.ValueAnimator) AbsListView(android.widget.AbsListView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) NonNull(android.support.annotation.NonNull)

Example 67 with ObjectAnimator

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

the class SwipeTouchListener method restoreCurrentViewTranslation.

/**
     * Animates the pending {@link android.view.View} back to its original position.
     */
private void restoreCurrentViewTranslation() {
    if (mCurrentView == null) {
        return;
    }
    ObjectAnimator xAnimator = ObjectAnimator.ofFloat(mSwipingView, TRANSLATION_X, 0);
    ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(mSwipingView, ALPHA, 1);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(xAnimator, alphaAnimator);
    animatorSet.setDuration(mAnimationTime);
    animatorSet.addListener(new RestoreAnimatorListener(mCurrentView, mCurrentPosition));
    animatorSet.start();
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Example 68 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project ElasticDownload by Tibolte.

the class PathAnimatorInflater method loadObjectAnimator.

private static ObjectAnimator loadObjectAnimator(Context c, Resources res, Resources.Theme theme, AttributeSet attrs, float pathErrorScale) throws Resources.NotFoundException {
    ObjectAnimator anim = new ObjectAnimator();
    loadAnimator(c, res, theme, attrs, anim, pathErrorScale);
    return anim;
}
Also used : ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator)

Example 69 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project ElasticDownload by Tibolte.

the class ProgressDownloadView method drawFail.

public void drawFail() {
    mState = State.STATE_FAILED;
    ObjectAnimator failAnim = ObjectAnimator.ofFloat(this, "failAngle", 0, 180);
    failAnim.setInterpolator(new OvershootInterpolator());
    //This one doesn't do much actually, we just use it to take advantage of associating two different interpolators
    ObjectAnimator anim = ObjectAnimator.ofFloat(this, "progress", getProgress(), mTarget);
    anim.setInterpolator(new AccelerateInterpolator());
    AnimatorSet set = new AnimatorSet();
    set.setDuration((long) (ANIMATION_DURATION_BASE / 1.7f));
    set.playTogether(failAnim, anim);
    set.start();
}
Also used : OvershootInterpolator(android.view.animation.OvershootInterpolator) AccelerateInterpolator(android.view.animation.AccelerateInterpolator) ObjectAnimator(com.nineoldandroids.animation.ObjectAnimator) AnimatorSet(com.nineoldandroids.animation.AnimatorSet)

Example 70 with ObjectAnimator

use of com.nineoldandroids.animation.ObjectAnimator in project ElasticDownload by Tibolte.

the class ProgressDownloadView method drawSuccess.

public void drawSuccess() {
    mTarget = 100;
    final ObjectAnimator successAnim = ObjectAnimator.ofFloat(this, "flip", 1, -1);
    successAnim.setInterpolator(new OvershootInterpolator());
    successAnim.setDuration(ANIMATION_DURATION_BASE);
    ObjectAnimator anim = ObjectAnimator.ofFloat(this, "progress", getProgress(), mTarget);
    anim.setInterpolator(new DecelerateInterpolator());
    anim.setDuration((long) (ANIMATION_DURATION_BASE + Math.abs(mTarget * 10 - getProgress() * 10) / 2));
    anim.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mState = State.STATE_SUCCESS;
            successAnim.start();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

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

Aggregations

ObjectAnimator (com.nineoldandroids.animation.ObjectAnimator)81 AnimatorSet (com.nineoldandroids.animation.AnimatorSet)27 Animator (com.nineoldandroids.animation.Animator)20 View (android.view.View)11 PropertyValuesHolder (com.nineoldandroids.animation.PropertyValuesHolder)10 Keyframe (com.nineoldandroids.animation.Keyframe)9 Paint (android.graphics.Paint)8 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)8 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)6 TextView (android.widget.TextView)5 AdapterView (android.widget.AdapterView)4 AnimatorListenerAdapter (com.nineoldandroids.animation.AnimatorListenerAdapter)4 SuppressLint (android.annotation.SuppressLint)3 TargetApi (android.annotation.TargetApi)3 LinearInterpolator (android.view.animation.LinearInterpolator)3 OvershootInterpolator (android.view.animation.OvershootInterpolator)3 AbsListView (android.widget.AbsListView)3 ListView (android.widget.ListView)3 ValueAnimator (com.nineoldandroids.animation.ValueAnimator)3 SupportAnimator (io.codetail.animation.SupportAnimator)3