Search in sources :

Example 16 with AnimationThread

use of android.animation.AnimationThread in project android_frameworks_base by DirtyUnicorns.

the class RenderSessionImpl method insertChild.

/**
     * Insert a new child into an existing 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#insertChild(Object, ILayoutPullParser, int, IAnimationListener)
     */
public Result insertChild(final ViewGroup parentView, ILayoutPullParser childXml, final int index, IAnimationListener listener) {
    checkLock();
    BridgeContext context = getContext();
    // create a block parser for the XML
    BridgeXmlBlockParser blockParser = new BridgeXmlBlockParser(childXml, context, false);
    // inflate the child without adding it to the root since we want to control where it'll
    // get added. We do pass the parentView however to ensure that the layoutParams will
    // be created correctly.
    final View child = mInflater.inflate(blockParser, parentView, false);
    blockParser.ensurePopped();
    invalidateRenderingSize();
    if (listener != null) {
        new AnimationThread(this, "insertChild", listener) {

            @Override
            public Result preAnimation() {
                parentView.setLayoutTransition(new LayoutTransition());
                return addView(parentView, child, index);
            }

            @Override
            public void postAnimation() {
                parentView.setLayoutTransition(null);
            }
        }.start();
        // always return success since the real status will come through the listener.
        return SUCCESS.createResult(child);
    }
    // add it to the parentView in the correct location
    Result result = addView(parentView, child, index);
    if (!result.isSuccess()) {
        return result;
    }
    result = render(false);
    if (result.isSuccess()) {
        result = result.getCopyWithData(child);
    }
    return result;
}
Also used : AnimationThread(android.animation.AnimationThread) BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) LayoutTransition(android.animation.LayoutTransition) 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) BridgeXmlBlockParser(com.android.layoutlib.bridge.android.BridgeXmlBlockParser) Result(com.android.ide.common.rendering.api.Result)

Example 17 with AnimationThread

use of android.animation.AnimationThread in project android_frameworks_base by DirtyUnicorns.

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 18 with AnimationThread

use of android.animation.AnimationThread 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

AnimationThread (android.animation.AnimationThread)18 LayoutTransition (android.animation.LayoutTransition)18 Result (com.android.ide.common.rendering.api.Result)18 ViewGroup (android.view.ViewGroup)12 View (android.view.View)6 LayoutParams (android.view.ViewGroup.LayoutParams)6 MarginLayoutParams (android.view.ViewGroup.MarginLayoutParams)6 AbsListView (android.widget.AbsListView)6 AdapterView (android.widget.AdapterView)6 ExpandableListView (android.widget.ExpandableListView)6 ListView (android.widget.ListView)6 BridgeContext (com.android.layoutlib.bridge.android.BridgeContext)6 BridgeLayoutParamsMapAttributes (com.android.layoutlib.bridge.android.BridgeLayoutParamsMapAttributes)6 BridgeXmlBlockParser (com.android.layoutlib.bridge.android.BridgeXmlBlockParser)6 ActionMenuView (android.widget.ActionMenuView)5 ActionMenuItemView (com.android.internal.view.menu.ActionMenuItemView)5 IconMenuItemView (com.android.internal.view.menu.IconMenuItemView)5 ListMenuItemView (com.android.internal.view.menu.ListMenuItemView)5 MenuView (com.android.internal.view.menu.MenuView)5