Example usage for android.view ViewParent isLayoutRequested

List of usage examples for android.view ViewParent isLayoutRequested

Introduction

In this page you can find the example usage for android.view ViewParent isLayoutRequested.

Prototype

public boolean isLayoutRequested();

Source Link

Document

Indicates whether layout was requested on this view parent.

Usage

From source file:Main.java

public static void requestLayoutParent(View view, boolean isAll) {
    ViewParent parent = view.getParent();
    while (parent != null && parent instanceof View) {
        if (!parent.isLayoutRequested()) {
            parent.requestLayout();/*w  w  w.  java2s. co m*/
            if (!isAll) {
                break;
            }
        }
        parent = parent.getParent();
    }
}

From source file:android.support.design.widget.BottomSheetBehavior.java

/**
 * Sets the state of the bottom sheet. The bottom sheet will transition to that state with
 * animation./*  w w  w  .  j  a  v a  2 s  .  c  o m*/
 *
 * @param state One of {@link #STATE_COLLAPSED}, {@link #STATE_EXPANDED}, or
 *              {@link #STATE_HIDDEN}.
 */
public final void setState(final @State int state) {
    if (state == mState) {
        return;
    }
    if (mViewRef == null) {
        // The view is not laid out yet; modify mState and let onLayoutChild handle it later
        if (state == STATE_COLLAPSED || state == STATE_EXPANDED || (mHideable && state == STATE_HIDDEN)) {
            mState = state;
        }
        return;
    }
    final V child = mViewRef.get();
    if (child == null) {
        return;
    }
    // Start the animation; wait until a pending layout if there is one.
    ViewParent parent = child.getParent();
    if (parent != null && parent.isLayoutRequested() && ViewCompat.isAttachedToWindow(child)) {
        child.post(new Runnable() {
            @Override
            public void run() {
                startSettlingAnimation(child, state);
            }
        });
    } else {
        startSettlingAnimation(child, state);
    }
}

From source file:com.matcontrol.control.BottomSheetBehavior_v25.java

/**
 * Sets the state of the bottom sheet. The bottom sheet will transition to that state with
 * animation./*  w w  w  .j  a  v  a 2 s .c o m*/
 *
 * @param state One of {@link #STATE_COLLAPSED}, {@link #STATE_EXPANDED}, or
 *              {@link #STATE_HIDDEN}.
 */
public final void setState(final @BottomSheetBehavior_v25.State int state) {
    if (state == mState) {
        return;
    }
    if (mViewRef == null) {
        // The view is not laid out yet; modify mState and let onLayoutChild handle it later
        if (state == STATE_COLLAPSED || state == STATE_EXPANDED || (mHideable && state == STATE_HIDDEN)) {
            mState = state;
        }
        return;
    }
    final V child = mViewRef.get();
    if (child == null) {
        return;
    }
    // Start the animation; wait until a pending layout if there is one.
    ViewParent parent = child.getParent();
    if (parent != null && parent.isLayoutRequested() && ViewCompat.isAttachedToWindow(child)) {
        child.post(new Runnable() {
            @Override
            public void run() {
                startSettlingAnimation(child, state);
            }
        });
    } else {
        startSettlingAnimation(child, state);
    }
}

From source file:com.runzii.lib.widgets.behavior.BottomSheetAnchorBehavior.java

/**
 * Sets the state of the bottom sheet. The bottom sheet will transition to that state with
 * animation.//  w  ww . j  a v a 2 s . c om
 *
 * @param state One of {@link #STATE_COLLAPSED}, {@link #STATE_ANCHORED},
 *              {@link #STATE_EXPANDED} or {@link #STATE_HIDDEN}.
 */
public final void setState(@State final int state) {
    if (state == mState) {
        return;
    }
    if (mViewRef == null) {
        // The view is not laid out yet; modify mState and let onLayoutChild handle it later
        /**
         * New behavior (added: state == STATE_ANCHORED ||)
         */
        if (state == STATE_COLLAPSED || state == STATE_EXPANDED || state == STATE_ANCHORED
                || (mHideable && state == STATE_HIDDEN)) {
            mState = state;
        }
        return;
    }
    final V child = mViewRef.get();
    if (child == null) {
        return;
    }
    // Start the animation; wait until a pending layout if there is one.
    ViewParent parent = child.getParent();
    if (parent != null && parent.isLayoutRequested() && ViewCompat.isAttachedToWindow(child)) {
        child.post(new Runnable() {
            @Override
            public void run() {
                startSettlingAnimation(child, state);
            }
        });
    } else {
        startSettlingAnimation(child, state);
    }
}

From source file:com.trafi.anchorbottomsheetbehavior.AnchorBottomSheetBehavior.java

/**
 * Sets the state of the bottom sheet. The bottom sheet will transition to that state with
 * animation.//  ww w. j  a v  a 2  s. co  m
 *
 * @param state One of {@link #STATE_COLLAPSED}, {@link #STATE_EXPANDED},
 *              {@link #STATE_ANCHORED} or{@link #STATE_HIDDEN}.
 */
public final void setState(final @AnchorBottomSheetBehavior.State int state) {
    if (state == mState) {
        return;
    }
    if (mViewRef == null) {
        // The view is not laid out yet; modify mState and let onLayoutChild handle it later
        if (state == STATE_COLLAPSED || state == STATE_EXPANDED || state == STATE_ANCHORED
                || (mHideable && state == STATE_HIDDEN)) {
            mState = state;
        }
        return;
    }
    final V child = mViewRef.get();
    if (child == null) {
        return;
    }
    // Start the animation; wait until a pending layout if there is one.
    ViewParent parent = child.getParent();
    if (parent != null && parent.isLayoutRequested() && ViewCompat.isAttachedToWindow(child)) {
        child.post(new Runnable() {
            @Override
            public void run() {
                startSettlingAnimation(child, state);
            }
        });
    } else {
        startSettlingAnimation(child, state);
    }
}