Search in sources :

Example 16 with AnimatorSet

use of android.animation.AnimatorSet in project FlexibleAdapter by davideas.

the class AnimatorAdapter method animateView.

/**
	 * Performs checks to scroll animate the itemView and in case, it animates the view.
	 * <p><b>Note:</b> If you have to change at runtime the LayoutManager <i>and</i> add
	 * Scrollable Headers too, consider to add them in post, using a {@code delay >= 0},
	 * otherwise scroll animations on all items will not start correctly.</p>
	 *
	 * @param holder   the ViewHolder just bound
	 * @param position the current item position
	 */
@SuppressWarnings("ConstantConditions")
protected final void animateView(final RecyclerView.ViewHolder holder, final int position) {
    if (mRecyclerView == null)
        return;
    // Use always the max child count reached
    if (mMaxChildViews < mRecyclerView.getChildCount()) {
        mMaxChildViews = mRecyclerView.getChildCount();
    }
    // Animate only during initial loading?
    if (onlyEntryAnimation && mLastAnimatedPosition >= mMaxChildViews) {
        shouldAnimate = false;
    }
    int lastVisiblePosition = Utils.findLastVisibleItemPosition(mRecyclerView.getLayoutManager());
    //		}
    if (holder instanceof FlexibleViewHolder && shouldAnimate && !isFastScroll && !mAnimatorNotifierObserver.isPositionNotified() && (position > lastVisiblePosition || isReverseEnabled || isScrollableHeaderOrFooter(position) || (position == 0 && mMaxChildViews == 0))) {
        // Cancel animation is necessary when fling
        int hashCode = holder.itemView.hashCode();
        cancelExistingAnimation(hashCode);
        // User animators
        List<Animator> animators = new ArrayList<>();
        FlexibleViewHolder flexibleViewHolder = (FlexibleViewHolder) holder;
        flexibleViewHolder.scrollAnimators(animators, position, position >= lastVisiblePosition);
        // Execute the animations together
        AnimatorSet set = new AnimatorSet();
        set.playTogether(animators);
        set.setInterpolator(mInterpolator);
        // Single view duration
        long duration = mDuration;
        for (Animator animator : animators) {
            if (animator.getDuration() != DEFAULT_DURATION) {
                duration = animator.getDuration();
            }
        }
        //Log.v(TAG, "duration=" + duration);
        set.setDuration(duration);
        set.addListener(new HelperAnimatorListener(hashCode));
        if (mEntryStep) {
            // Stop stepDelay when screen is filled
            set.setStartDelay(calculateAnimationDelay(position));
        }
        set.start();
        mAnimators.put(hashCode, set);
        if (DEBUG)
            Log.v(TAG, "animateView    Scroll animation on position " + position);
    }
    mAnimatorNotifierObserver.clearNotified();
    // Update last animated position
    mLastAnimatedPosition = position;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ArrayList(java.util.ArrayList) FlexibleViewHolder(eu.davidea.viewholders.FlexibleViewHolder) AnimatorSet(android.animation.AnimatorSet)

Example 17 with AnimatorSet

use of android.animation.AnimatorSet in project FlexibleAdapter by davideas.

the class AnimatorAdapter method animateView.

/**
	 * Animates the view based on the custom animator list built with {@link #getAnimators(View, int, boolean)}.
	 *
	 * @since 5.0.0-b1
	 * @deprecated New system in place. Implement {@link FlexibleViewHolder#scrollAnimators(List, int, boolean)}
	 * and add new animator(s) to the list of {@code animators}.
	 */
@Deprecated
public final void animateView(final View itemView, int position) {
    if (shouldAnimate && !isFastScroll && !mAnimatorNotifierObserver.isPositionNotified() && (isReverseEnabled || position > mLastAnimatedPosition || (position == 0 && mRecyclerView.getChildCount() == 0))) {
        //Cancel animation is necessary when fling
        cancelExistingAnimation(itemView.hashCode());
        //Retrieve user animators
        List<Animator> animators = getAnimators(itemView, position, position > mLastAnimatedPosition);
        //Add Alpha animator
        ViewCompat.setAlpha(itemView, 0);
        animators.add(ObjectAnimator.ofFloat(itemView, "alpha", 0f, 1f));
        Log.w(TAG, "Started Deprecated Animation on position " + position);
        //Execute the animations
        AnimatorSet set = new AnimatorSet();
        set.playTogether(animators);
        set.setInterpolator(mInterpolator);
        set.setDuration(mDuration);
        set.addListener(new HelperAnimatorListener(itemView.hashCode()));
        if (mEntryStep) {
            set.setStartDelay(calculateAnimationDelay(position));
        }
        set.start();
        mAnimators.put(itemView.hashCode(), set);
        //Animate only during initial loading?
        if (onlyEntryAnimation && mLastAnimatedPosition >= mMaxChildViews) {
            shouldAnimate = false;
        }
    }
    mAnimatorNotifierObserver.clearNotified();
    mLastAnimatedPosition = position;
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) AnimatorSet(android.animation.AnimatorSet)

Example 18 with AnimatorSet

use of android.animation.AnimatorSet in project android_frameworks_base by ParanoidAndroid.

the class ActionBarImpl method doHide.

public void doHide(boolean fromSystem) {
    if (mCurrentShowAnim != null) {
        mCurrentShowAnim.end();
    }
    if (mCurWindowVisibility == View.VISIBLE && (mShowHideAnimationEnabled || fromSystem)) {
        mTopVisibilityView.setAlpha(1);
        mContainerView.setTransitioning(true);
        AnimatorSet anim = new AnimatorSet();
        float endingY = -mTopVisibilityView.getHeight();
        if (fromSystem) {
            int[] topLeft = { 0, 0 };
            mTopVisibilityView.getLocationInWindow(topLeft);
            endingY -= topLeft[1];
        }
        AnimatorSet.Builder b = anim.play(ObjectAnimator.ofFloat(mTopVisibilityView, "translationY", endingY));
        if (mContentAnimations && mContentView != null) {
            b.with(ObjectAnimator.ofFloat(mContentView, "translationY", 0, endingY));
        }
        if (mSplitView != null && mSplitView.getVisibility() == View.VISIBLE) {
            mSplitView.setAlpha(1);
            b.with(ObjectAnimator.ofFloat(mSplitView, "translationY", mSplitView.getHeight()));
        }
        anim.setInterpolator(AnimationUtils.loadInterpolator(mContext, com.android.internal.R.interpolator.accelerate_cubic));
        anim.setDuration(250);
        anim.addListener(mHideListener);
        mCurrentShowAnim = anim;
        anim.start();
    } else {
        mHideListener.onAnimationEnd(null);
    }
}
Also used : AnimatorSet(android.animation.AnimatorSet)

Example 19 with AnimatorSet

use of android.animation.AnimatorSet in project android_frameworks_base by ParanoidAndroid.

the class ActionBarContextView method makeOutAnimation.

private Animator makeOutAnimation() {
    ObjectAnimator buttonAnimator = ObjectAnimator.ofFloat(mClose, "translationX", -mClose.getWidth() - ((MarginLayoutParams) mClose.getLayoutParams()).leftMargin);
    buttonAnimator.setDuration(200);
    buttonAnimator.addListener(this);
    buttonAnimator.setInterpolator(new DecelerateInterpolator());
    AnimatorSet set = new AnimatorSet();
    AnimatorSet.Builder b = set.play(buttonAnimator);
    if (mMenuView != null) {
        final int count = mMenuView.getChildCount();
        if (count > 0) {
            for (int i = 0; i < 0; i++) {
                View child = mMenuView.getChildAt(i);
                child.setScaleY(0);
                ObjectAnimator a = ObjectAnimator.ofFloat(child, "scaleY", 0);
                a.setDuration(300);
                b.with(a);
            }
        }
    }
    return set;
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) ActionMenuView(com.android.internal.view.menu.ActionMenuView) TextView(android.widget.TextView) View(android.view.View)

Example 20 with AnimatorSet

use of android.animation.AnimatorSet in project android_frameworks_base by ParanoidAndroid.

the class SizeAdaptiveLayout method initialize.

private void initialize() {
    mModestyPanel = new View(getContext());
    // If the SizeAdaptiveLayout has a solid background, use it as a transition hint.
    Drawable background = getBackground();
    if (background instanceof StateListDrawable) {
        StateListDrawable sld = (StateListDrawable) background;
        sld.setState(StateSet.WILD_CARD);
        background = sld.getCurrent();
    }
    if (background instanceof ColorDrawable) {
        mModestyPanel.setBackgroundDrawable(background);
    } else {
        mModestyPanel.setBackgroundColor(Color.BLACK);
    }
    SizeAdaptiveLayout.LayoutParams layout = new SizeAdaptiveLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    mModestyPanel.setLayoutParams(layout);
    addView(mModestyPanel);
    mFadePanel = ObjectAnimator.ofFloat(mModestyPanel, "alpha", 0f);
    mFadeView = ObjectAnimator.ofFloat(null, "alpha", 0f);
    mAnimatorListener = new BringToFrontOnEnd();
    mTransitionAnimation = new AnimatorSet();
    mTransitionAnimation.play(mFadeView).with(mFadePanel);
    mTransitionAnimation.setDuration(CROSSFADE_TIME);
    mTransitionAnimation.addListener(mAnimatorListener);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) StateListDrawable(android.graphics.drawable.StateListDrawable) AnimatorSet(android.animation.AnimatorSet) StateListDrawable(android.graphics.drawable.StateListDrawable) RemoteView(android.widget.RemoteViews.RemoteView) View(android.view.View)

Aggregations

AnimatorSet (android.animation.AnimatorSet)480 ObjectAnimator (android.animation.ObjectAnimator)336 Animator (android.animation.Animator)278 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)139 View (android.view.View)107 ValueAnimator (android.animation.ValueAnimator)103 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)52 ArrayList (java.util.ArrayList)47 Rect (android.graphics.Rect)43 ViewGroup (android.view.ViewGroup)42 ImageView (android.widget.ImageView)36 TextView (android.widget.TextView)32 PropertyValuesHolder (android.animation.PropertyValuesHolder)25 Paint (android.graphics.Paint)25 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)25 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)23 Bitmap (android.graphics.Bitmap)17 LinearInterpolator (android.view.animation.LinearInterpolator)15 OvershootInterpolator (android.view.animation.OvershootInterpolator)15 Point (android.graphics.Point)14