Search in sources :

Example 26 with LayoutTransition

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

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 27 with LayoutTransition

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

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)

Example 28 with LayoutTransition

use of android.animation.LayoutTransition in project android_packages_apps_DUI by DirtyUnicorns.

the class BaseNavigationBar method createBaseViews.

// for when we don't inflate xml
protected void createBaseViews() {
    LinearLayout rot0NavButton = new LinearLayout(getContext());
    rot0NavButton.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    rot0NavButton.setOrientation(LinearLayout.HORIZONTAL);
    rot0NavButton.setClipChildren(false);
    rot0NavButton.setClipToPadding(false);
    rot0NavButton.setLayoutTransition(new LayoutTransition());
    rot0NavButton.setTag(Res.Common.NAV_BUTTONS);
    LinearLayout rot90NavButton = new LinearLayout(getContext());
    rot90NavButton.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    rot90NavButton.setOrientation(sIsTablet ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL);
    rot90NavButton.setClipChildren(false);
    rot90NavButton.setClipToPadding(false);
    rot90NavButton.setLayoutTransition(new LayoutTransition());
    rot90NavButton.setTag(Res.Common.NAV_BUTTONS);
    mRot0 = new FrameLayout(getContext());
    mRot0.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    mRot90 = new FrameLayout(getContext());
    mRot90.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    mRot90.setVisibility(View.GONE);
    mRot90.setPadding(mRot90.getPaddingLeft(), 0, mRot90.getPaddingRight(), mRot90.getPaddingBottom());
    if (!BarTransitions.HIGH_END) {
        setBackground(getContext().getDrawable(R.drawable.system_bar_background));
    }
    //        addBatteryBarLayout(mRot0);
    mRot0.addView(rot0NavButton);
    //        addBatteryBarLayout(mRot90);
    mRot90.addView(rot90NavButton);
    addView(mRot0);
    addView(mRot90);
    mRotatedViews[Surface.ROTATION_0] = mRotatedViews[Surface.ROTATION_180] = mRot0;
    mRotatedViews[Surface.ROTATION_90] = mRot90;
    mRotatedViews[Surface.ROTATION_270] = mRotatedViews[Surface.ROTATION_90];
    mCurrentView = mRotatedViews[Surface.ROTATION_0];
}
Also used : FrameLayout(android.widget.FrameLayout) LayoutTransition(android.animation.LayoutTransition) LinearLayout(android.widget.LinearLayout)

Example 29 with LayoutTransition

use of android.animation.LayoutTransition in project android_packages_apps_DUI by DirtyUnicorns.

the class BaseNavigationBar method updateLayoutTransitionsEnabled.

protected void updateLayoutTransitionsEnabled() {
    boolean enabled = !mWakeAndUnlocking && mLayoutTransitionsEnabled;
    ViewGroup navButtons = (ViewGroup) mCurrentView.findViewById(R.id.nav_buttons);
    if (navButtons == null) {
        navButtons = (ViewGroup) mCurrentView.findViewWithTag(Res.Common.NAV_BUTTONS);
    }
    LayoutTransition lt = navButtons.getLayoutTransition();
    if (lt != null) {
        if (enabled) {
            lt.enableTransitionType(LayoutTransition.APPEARING);
            lt.enableTransitionType(LayoutTransition.DISAPPEARING);
            lt.enableTransitionType(LayoutTransition.CHANGE_APPEARING);
            lt.enableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
        } else {
            lt.disableTransitionType(LayoutTransition.APPEARING);
            lt.disableTransitionType(LayoutTransition.DISAPPEARING);
            lt.disableTransitionType(LayoutTransition.CHANGE_APPEARING);
            lt.disableTransitionType(LayoutTransition.CHANGE_DISAPPEARING);
        }
    }
}
Also used : ViewGroup(android.view.ViewGroup) LayoutTransition(android.animation.LayoutTransition)

Example 30 with LayoutTransition

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

the class MLand method setScoreFieldHolder.

public void setScoreFieldHolder(ViewGroup vg) {
    mScoreFields = vg;
    if (vg != null) {
        final LayoutTransition lt = new LayoutTransition();
        lt.setDuration(250);
        mScoreFields.setLayoutTransition(lt);
    }
    for (Player p : mPlayers) {
        mScoreFields.addView(p.mScoreField, new MarginLayoutParams(MarginLayoutParams.WRAP_CONTENT, MarginLayoutParams.MATCH_PARENT));
    }
}
Also used : LayoutTransition(android.animation.LayoutTransition)

Aggregations

LayoutTransition (android.animation.LayoutTransition)87 ViewGroup (android.view.ViewGroup)36 AnimationThread (android.animation.AnimationThread)18 View (android.view.View)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