Search in sources :

Example 76 with LayoutTransition

use of android.animation.LayoutTransition in project android_frameworks_base by AOSPA.

the class ViewGroup method setLayoutTransition.

/**
     * Sets the LayoutTransition object for this ViewGroup. If the LayoutTransition object is
     * not null, changes in layout which occur because of children being added to or removed from
     * the ViewGroup will be animated according to the animations defined in that LayoutTransition
     * object. By default, the transition object is null (so layout changes are not animated).
     *
     * <p>Replacing a non-null transition will cause that previous transition to be
     * canceled, if it is currently running, to restore this container to
     * its correct post-transition state.</p>
     *
     * @param transition The LayoutTransition object that will animated changes in layout. A value
     * of <code>null</code> means no transition will run on layout changes.
     * @attr ref android.R.styleable#ViewGroup_animateLayoutChanges
     */
public void setLayoutTransition(LayoutTransition transition) {
    if (mTransition != null) {
        LayoutTransition previousTransition = mTransition;
        previousTransition.cancel();
        previousTransition.removeTransitionListener(mLayoutTransitionListener);
    }
    mTransition = transition;
    if (mTransition != null) {
        mTransition.addTransitionListener(mLayoutTransitionListener);
    }
}
Also used : LayoutTransition(android.animation.LayoutTransition)

Example 77 with LayoutTransition

use of android.animation.LayoutTransition in project SunDay by iQuick.

the class CityActivity method addContentAnim.

/**
     * 添加内容动画
     */
private void addContentAnim() {
    mTransition = new LayoutTransition();
    mTransition.setDuration(ANIM_DURATON);
    mTransition.addTransitionListener(new LayoutTransition.TransitionListener() {

        @Override
        public void startTransition(LayoutTransition transition, ViewGroup container, View view, int transitionType) {
            animIsStart = true;
        }

        @Override
        public void endTransition(LayoutTransition transition, ViewGroup container, View view, int transitionType) {
            animIsStart = false;
        }
    });
    mLLCityContent.setLayoutTransition(mTransition);
}
Also used : ViewGroup(android.view.ViewGroup) LayoutTransition(android.animation.LayoutTransition) JazzyListView(tk.woppo.sunday.widget.jazzylistview.JazzyListView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 78 with LayoutTransition

use of android.animation.LayoutTransition in project android_frameworks_base by ResurrectionRemix.

the class ViewGroup method initFromAttributes.

private void initFromAttributes(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ViewGroup, defStyleAttr, defStyleRes);
    final int N = a.getIndexCount();
    for (int i = 0; i < N; i++) {
        int attr = a.getIndex(i);
        switch(attr) {
            case R.styleable.ViewGroup_clipChildren:
                setClipChildren(a.getBoolean(attr, true));
                break;
            case R.styleable.ViewGroup_clipToPadding:
                setClipToPadding(a.getBoolean(attr, true));
                break;
            case R.styleable.ViewGroup_animationCache:
                setAnimationCacheEnabled(a.getBoolean(attr, true));
                break;
            case R.styleable.ViewGroup_persistentDrawingCache:
                setPersistentDrawingCache(a.getInt(attr, PERSISTENT_SCROLLING_CACHE));
                break;
            case R.styleable.ViewGroup_addStatesFromChildren:
                setAddStatesFromChildren(a.getBoolean(attr, false));
                break;
            case R.styleable.ViewGroup_alwaysDrawnWithCache:
                setAlwaysDrawnWithCacheEnabled(a.getBoolean(attr, true));
                break;
            case R.styleable.ViewGroup_layoutAnimation:
                int id = a.getResourceId(attr, -1);
                if (id > 0) {
                    setLayoutAnimation(AnimationUtils.loadLayoutAnimation(mContext, id));
                }
                break;
            case R.styleable.ViewGroup_descendantFocusability:
                setDescendantFocusability(DESCENDANT_FOCUSABILITY_FLAGS[a.getInt(attr, 0)]);
                break;
            case R.styleable.ViewGroup_splitMotionEvents:
                setMotionEventSplittingEnabled(a.getBoolean(attr, false));
                break;
            case R.styleable.ViewGroup_animateLayoutChanges:
                boolean animateLayoutChanges = a.getBoolean(attr, false);
                if (animateLayoutChanges) {
                    setLayoutTransition(new LayoutTransition());
                }
                break;
            case R.styleable.ViewGroup_layoutMode:
                setLayoutMode(a.getInt(attr, LAYOUT_MODE_UNDEFINED));
                break;
            case R.styleable.ViewGroup_transitionGroup:
                setTransitionGroup(a.getBoolean(attr, false));
                break;
            case R.styleable.ViewGroup_touchscreenBlocksFocus:
                setTouchscreenBlocksFocus(a.getBoolean(attr, false));
                break;
        }
    }
    a.recycle();
}
Also used : TypedArray(android.content.res.TypedArray) LayoutTransition(android.animation.LayoutTransition) Paint(android.graphics.Paint)

Example 79 with LayoutTransition

use of android.animation.LayoutTransition in project android_frameworks_base by ResurrectionRemix.

the class RenderSessionImpl method moveView.

/**
     * Moves a View from its current parent to a new given parent at a new given location, with
     * an optional new {@link LayoutParams} instance
     *
     * @param previousParent the previous parent, still owning the child at the time of the call.
     * @param newParent the new parent
     * @param movedView the view to move
     * @param index the new location in the new parent
     * @param params an option (can be null) {@link LayoutParams} instance.
     *
     * @return a Result with {@link Status#SUCCESS} or
     *     {@link Status#ERROR_VIEWGROUP_NO_CHILDREN} if the given parent doesn't support
     *     adding views.
     */
private Result moveView(ViewGroup previousParent, final ViewGroup newParent, final View movedView, final int index, final LayoutParams params) {
    try {
        // check if there is a transition on the previousParent.
        LayoutTransition previousTransition = previousParent.getLayoutTransition();
        if (previousTransition != null) {
            // in this case there is an animation. This means we have to wait for the child's
            // parent reference to be null'ed out so that we can add it to the new parent.
            // It is technically removed right before the DISAPPEARING animation is done (if
            // the animation of this type is not null, otherwise it's after which is impossible
            // to handle).
            // Because there is no move animation, if the new parent is the same as the old
            // parent, we need to wait until the CHANGE_DISAPPEARING animation is done before
            // adding the child or the child will appear in its new location before the
            // other children have made room for it.
            // add a listener to the transition to be notified of the actual removal.
            previousTransition.addTransitionListener(new TransitionListener() {

                private int mChangeDisappearingCount = 0;

                @Override
                public void startTransition(LayoutTransition transition, ViewGroup container, View view, int transitionType) {
                    if (transitionType == LayoutTransition.CHANGE_DISAPPEARING) {
                        mChangeDisappearingCount++;
                    }
                }

                @Override
                public void endTransition(LayoutTransition transition, ViewGroup container, View view, int transitionType) {
                    if (transitionType == LayoutTransition.CHANGE_DISAPPEARING) {
                        mChangeDisappearingCount--;
                    }
                    if (transitionType == LayoutTransition.CHANGE_DISAPPEARING && mChangeDisappearingCount == 0) {
                        // add it to the parentView in the correct location
                        if (params != null) {
                            newParent.addView(movedView, index, params);
                        } else {
                            newParent.addView(movedView, index);
                        }
                    }
                }
            });
            // remove the view from the current parent.
            previousParent.removeView(movedView);
            // and return since adding the view to the new parent is done in the listener.
            return SUCCESS.createResult();
        } else {
            // standard code with no animation. pretty simple.
            previousParent.removeView(movedView);
            // add it to the parentView in the correct location
            if (params != null) {
                newParent.addView(movedView, index, params);
            } else {
                newParent.addView(movedView, index);
            }
            return SUCCESS.createResult();
        }
    } catch (UnsupportedOperationException e) {
        // looks like this is a view class that doesn't support children manipulation!
        return ERROR_VIEWGROUP_NO_CHILDREN.createResult();
    }
}
Also used : ViewGroup(android.view.ViewGroup) LayoutTransition(android.animation.LayoutTransition) TransitionListener(android.animation.LayoutTransition.TransitionListener) MenuView(com.android.internal.view.menu.MenuView) View(android.view.View) AdapterView(android.widget.AdapterView) ActionMenuItemView(com.android.internal.view.menu.ActionMenuItemView) IconMenuItemView(com.android.internal.view.menu.IconMenuItemView) ListView(android.widget.ListView) ListMenuItemView(com.android.internal.view.menu.ListMenuItemView) AbsListView(android.widget.AbsListView) ActionMenuView(android.widget.ActionMenuView) ExpandableListView(android.widget.ExpandableListView)

Example 80 with LayoutTransition

use of android.animation.LayoutTransition in project android_frameworks_base by ResurrectionRemix.

the class RenderSessionImpl method removeChild.

/**
     * Removes a child from its current parent.
     * <p>
     * {@link #acquire(long)} must have been called before this.
     *
     * @throws IllegalStateException if the current context is different than the one owned by
     *      the scene, or if {@link #acquire(long)} was not called.
     *
     * @see RenderSession#removeChild(Object, IAnimationListener)
     */
public Result removeChild(final View childView, IAnimationListener listener) {
    checkLock();
    invalidateRenderingSize();
    final ViewGroup parent = (ViewGroup) childView.getParent();
    if (listener != null) {
        new AnimationThread(this, "moveChild", listener) {

            @Override
            public Result preAnimation() {
                parent.setLayoutTransition(new LayoutTransition());
                return removeView(parent, childView);
            }

            @Override
            public void postAnimation() {
                parent.setLayoutTransition(null);
            }
        }.start();
        // always return success since the real status will come through the listener.
        return SUCCESS.createResult();
    }
    Result result = removeView(parent, childView);
    if (!result.isSuccess()) {
        return result;
    }
    return render(false);
}
Also used : AnimationThread(android.animation.AnimationThread) ViewGroup(android.view.ViewGroup) LayoutTransition(android.animation.LayoutTransition) Result(com.android.ide.common.rendering.api.Result)

Aggregations

LayoutTransition (android.animation.LayoutTransition)89 ViewGroup (android.view.ViewGroup)37 View (android.view.View)19 AnimationThread (android.animation.AnimationThread)18 Result (com.android.ide.common.rendering.api.Result)18 AdapterView (android.widget.AdapterView)13 ListView (android.widget.ListView)13 AbsListView (android.widget.AbsListView)12 ExpandableListView (android.widget.ExpandableListView)12 ActionMenuView (android.widget.ActionMenuView)10 ActionMenuItemView (com.android.internal.view.menu.ActionMenuItemView)10 IconMenuItemView (com.android.internal.view.menu.IconMenuItemView)10 ListMenuItemView (com.android.internal.view.menu.ListMenuItemView)10 MenuView (com.android.internal.view.menu.MenuView)10 Paint (android.graphics.Paint)8 TypedArray (android.content.res.TypedArray)7 LayoutParams (android.view.ViewGroup.LayoutParams)7 MarginLayoutParams (android.view.ViewGroup.MarginLayoutParams)7 TransitionListener (android.animation.LayoutTransition.TransitionListener)6 BridgeContext (com.android.layoutlib.bridge.android.BridgeContext)6