Search in sources :

Example 21 with Animator

use of com.marshalchen.common.uimodule.nineoldandroids.animation.Animator in project UltimateAndroid by cymcsg.

the class AnimationAdapter method concatAnimators.

private Animator[] concatAnimators(final Animator[] childAnimators, final Animator[] animators, final Animator alphaAnimator) {
    Animator[] allAnimators = new Animator[childAnimators.length + animators.length + 1];
    int i;
    for (i = 0; i < animators.length; ++i) {
        allAnimators[i] = animators[i];
    }
    for (Animator childAnimator : childAnimators) {
        allAnimators[i] = childAnimator;
        ++i;
    }
    allAnimators[allAnimators.length - 1] = alphaAnimator;
    return allAnimators;
}
Also used : ObjectAnimator(com.marshalchen.common.uimodule.nineoldandroids.animation.ObjectAnimator) Animator(com.marshalchen.common.uimodule.nineoldandroids.animation.Animator) SuppressLint(android.annotation.SuppressLint)

Example 22 with Animator

use of com.marshalchen.common.uimodule.nineoldandroids.animation.Animator in project UltimateAndroid by cymcsg.

the class PanningViewAttacher method animate.

private void animate(float start, float end, long duration) {
    Log.d(TAG, "startPanning : " + start + " to " + end + ", in " + duration + "ms");
    mCurrentAnimator = ValueAnimator.ofFloat(start, end);
    mCurrentAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float value = (Float) animation.getAnimatedValue();
            mMatrix.reset();
            applyScaleOnMatrix();
            if (mIsPortrait) {
                mMatrix.postTranslate(value, 0);
            } else {
                mMatrix.postTranslate(0, value);
            }
            refreshDisplayRect();
            mCurrentPlayTime = animation.getCurrentPlayTime();
            setCurrentImageMatrix();
        }
    });
    mCurrentAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            Log.d(TAG, "animation has finished, startPanning in the other way");
            changeWay();
            animate_();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            Log.d(TAG, "panning animation canceled");
        }
    });
    mCurrentAnimator.setDuration(duration);
    mCurrentAnimator.setInterpolator(mLinearInterpolator);
    mCurrentAnimator.start();
}
Also used : ValueAnimator(com.marshalchen.common.uimodule.nineoldandroids.animation.ValueAnimator) Animator(com.marshalchen.common.uimodule.nineoldandroids.animation.Animator) AnimatorListenerAdapter(com.marshalchen.common.uimodule.nineoldandroids.animation.AnimatorListenerAdapter) ValueAnimator(com.marshalchen.common.uimodule.nineoldandroids.animation.ValueAnimator)

Example 23 with Animator

use of com.marshalchen.common.uimodule.nineoldandroids.animation.Animator in project UltimateAndroid by cymcsg.

the class AnimateDismissAdapter method animateDismiss.

/**
     * 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);
    }
}
Also used : AnimatorSet(com.marshalchen.common.uimodule.nineoldandroids.animation.AnimatorSet) View(android.view.View) ValueAnimator(com.marshalchen.common.uimodule.nineoldandroids.animation.ValueAnimator) Animator(com.marshalchen.common.uimodule.nineoldandroids.animation.Animator) AnimatorListenerAdapter(com.marshalchen.common.uimodule.nineoldandroids.animation.AnimatorListenerAdapter)

Example 24 with Animator

use of com.marshalchen.common.uimodule.nineoldandroids.animation.Animator in project UltimateAndroid by cymcsg.

the class FilckerAnimationListView method doAnimation.

private void doAnimation() {
    setEnabled(false);
    animating = true;
    final float durationUnit = (float) MAX_ANIM_DURATION / getHeight();
    animatePreLayout(durationUnit, new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(final Animator animation) {
            adapter.notifyDataSetChanged();
            getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {

                @Override
                public boolean onPreDraw() {
                    getViewTreeObserver().removeOnPreDrawListener(this);
                    animatePostLayout(durationUnit);
                    return true;
                }
            });
        }
    });
}
Also used : Animator(com.marshalchen.common.uimodule.nineoldandroids.animation.Animator) ObjectAnimator(com.marshalchen.common.uimodule.nineoldandroids.animation.ObjectAnimator) AnimatorListenerAdapter(com.marshalchen.common.uimodule.nineoldandroids.animation.AnimatorListenerAdapter) OnPreDrawListener(android.view.ViewTreeObserver.OnPreDrawListener)

Aggregations

Animator (com.marshalchen.common.uimodule.nineoldandroids.animation.Animator)24 ValueAnimator (com.marshalchen.common.uimodule.nineoldandroids.animation.ValueAnimator)15 AnimatorListenerAdapter (com.marshalchen.common.uimodule.nineoldandroids.animation.AnimatorListenerAdapter)14 View (android.view.View)8 ObjectAnimator (com.marshalchen.common.uimodule.nineoldandroids.animation.ObjectAnimator)8 AnimatorSet (com.marshalchen.common.uimodule.nineoldandroids.animation.AnimatorSet)5 ListView (android.widget.ListView)4 ViewPropertyAnimator (com.marshalchen.common.uimodule.nineoldandroids.view.ViewPropertyAnimator)4 SuppressLint (android.annotation.SuppressLint)3 HashMap (java.util.HashMap)2 Rect (android.graphics.Rect)1 ViewGroup (android.view.ViewGroup)1 OnPreDrawListener (android.view.ViewTreeObserver.OnPreDrawListener)1 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)1 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)1 LinearInterpolator (android.view.animation.LinearInterpolator)1 AbsListView (android.widget.AbsListView)1 AdapterView (android.widget.AdapterView)1 Techniques (com.marshalchen.common.uimodule.androidanimations.Techniques)1 AnimatorUpdateListener (com.marshalchen.common.uimodule.nineoldandroids.animation.ValueAnimator.AnimatorUpdateListener)1