Search in sources :

Example 16 with Animator

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

the class DemoOfUiActivity method initShimmerTextView.

private void initShimmerTextView() {
    main_content_frame.setVisibility(View.INVISIBLE);
    shimmer = new Shimmer();
    shimmer.setRepeatCount(0).setDuration(800).setStartDelay(300).setDirection(Shimmer.ANIMATION_DIRECTION_LTR).setAnimatorListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            main_content_frame.setVisibility(View.VISIBLE);
            main_content_frame.startAnimation(AnimationUtils.loadAnimation(DemoOfUiActivity.this, R.anim.fade_ins));
            favShimmerReaLayout.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
    shimmer.start(favShimmerTextView);
}
Also used : Animator(com.marshalchen.common.uimodule.nineoldandroids.animation.Animator) Shimmer(com.marshalchen.common.uimodule.shimmer.Shimmer)

Example 17 with Animator

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

the class ContextualUndoAdapter method swipeView.

private void swipeView(final View view, final int dismissPosition) {
    ObjectAnimator animator = ObjectAnimator.ofFloat(view, X, view.getMeasuredWidth());
    animator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(final Animator animator) {
            onViewSwiped(((ContextualUndoView) view).getItemId(), dismissPosition);
        }
    });
    animator.start();
}
Also used : ValueAnimator(com.marshalchen.common.uimodule.nineoldandroids.animation.ValueAnimator) ObjectAnimator(com.marshalchen.common.uimodule.nineoldandroids.animation.ObjectAnimator) Animator(com.marshalchen.common.uimodule.nineoldandroids.animation.Animator) ObjectAnimator(com.marshalchen.common.uimodule.nineoldandroids.animation.ObjectAnimator) AnimatorListenerAdapter(com.marshalchen.common.uimodule.nineoldandroids.animation.AnimatorListenerAdapter)

Example 18 with Animator

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

the class ContextualUndoListViewTouchListener method handleUpCancelEvent.

@SuppressWarnings("UnusedParameters")
private boolean handleUpCancelEvent(final View view, final MotionEvent motionEvent) {
    mDisallowSwipe = false;
    if (mVelocityTracker == null) {
        return false;
    }
    float deltaX = motionEvent.getRawX() - mDownX;
    mVelocityTracker.addMovement(motionEvent);
    mVelocityTracker.computeCurrentVelocity(1000);
    float velocityX = Math.abs(mVelocityTracker.getXVelocity());
    float velocityY = Math.abs(mVelocityTracker.getYVelocity());
    boolean dismiss = false;
    boolean dismissRight = false;
    final float absDeltaX = Math.abs(deltaX);
    if (absDeltaX > mViewWidth / 2) {
        dismiss = true;
        dismissRight = deltaX > 0;
    } else if (mMinFlingVelocity <= velocityX && velocityX <= mMaxFlingVelocity && velocityY < velocityX && absDeltaX > mSlop) {
        dismiss = true;
        dismissRight = mVelocityTracker.getXVelocity() > 0;
    }
    if (dismiss) {
        // dismiss
        final long itemId = ((ContextualUndoView) mDownView).getItemId();
        // before animation ends
        final int downPosition = mDownPosition;
        animate(mDownView).translationX(dismissRight ? mViewWidth : -mViewWidth).alpha(0).setDuration(mAnimationTime).setListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(final Animator animation) {
                mCallback.onViewSwiped(itemId, downPosition);
            }
        });
    } else {
        // cancel
        animate(mDownView).translationX(0).alpha(1).setDuration(mAnimationTime).setListener(null);
    }
    mVelocityTracker.recycle();
    mVelocityTracker = null;
    mDownX = 0;
    mDownView = null;
    mDownPosition = AdapterView.INVALID_POSITION;
    mSwiping = false;
    return false;
}
Also used : Animator(com.marshalchen.common.uimodule.nineoldandroids.animation.Animator) AnimatorListenerAdapter(com.marshalchen.common.uimodule.nineoldandroids.animation.AnimatorListenerAdapter)

Example 19 with Animator

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

the class AnimationAdapter method cancelExistingAnimation.

private void cancelExistingAnimation(final View convertView) {
    int hashCode = convertView.hashCode();
    Animator animator = mAnimators.get(hashCode);
    if (animator != null) {
        animator.end();
        mAnimators.remove(hashCode);
    }
}
Also used : ObjectAnimator(com.marshalchen.common.uimodule.nineoldandroids.animation.ObjectAnimator) Animator(com.marshalchen.common.uimodule.nineoldandroids.animation.Animator) SuppressLint(android.annotation.SuppressLint)

Example 20 with Animator

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

the class AnimationAdapter method animateView.

private void animateView(final ViewGroup parent, final View view) {
    if (mAnimationStartMillis == -1) {
        mAnimationStartMillis = System.currentTimeMillis();
    }
    ViewHelper.setAlpha(view, 0);
    Animator[] childAnimators;
    if (mDecoratedBaseAdapter instanceof AnimationAdapter) {
        childAnimators = ((AnimationAdapter) mDecoratedBaseAdapter).getAnimators(parent, view);
    } else {
        childAnimators = new Animator[0];
    }
    Animator[] animators = getAnimators(parent, view);
    Animator alphaAnimator = ObjectAnimator.ofFloat(view, ALPHA, 0, 1);
    AnimatorSet set = new AnimatorSet();
    set.playTogether(concatAnimators(childAnimators, animators, alphaAnimator));
    set.setStartDelay(calculateAnimationDelay());
    set.setDuration(getAnimationDurationMillis());
    set.start();
    mAnimators.put(view.hashCode(), set);
}
Also used : ObjectAnimator(com.marshalchen.common.uimodule.nineoldandroids.animation.ObjectAnimator) Animator(com.marshalchen.common.uimodule.nineoldandroids.animation.Animator) AnimatorSet(com.marshalchen.common.uimodule.nineoldandroids.animation.AnimatorSet)

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