Java Code Examples for android.view.ViewParent#isLayoutRequested()

The following examples show how to use android.view.ViewParent#isLayoutRequested() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MyBottomBehavior.java    From OpenWeatherPlus-Android with Apache License 2.0 6 votes vote down vote up
public final void setState(final int state) {
    if (state != this.state) {
        if (this.viewRef == null) {
            if (state == 4 || state == 3 || state == 6 || this.hideable && state == 5) {
                this.state = state;
            }

        } else {
            final View child = (View) this.viewRef.get();
            if (child != null) {
                ViewParent parent = child.getParent();
                if (parent != null && parent.isLayoutRequested() && ViewCompat.isAttachedToWindow(child)) {
                    child.post(new Runnable() {
                        public void run() {
                            MyBottomBehavior.this.startSettlingAnimation(child, state);
                        }
                    });
                } else {
                    this.startSettlingAnimation(child, state);
                }

            }
        }
    }
}
 
Example 2
Source File: ViewUtils.java    From DevUtils with Apache License 2.0 6 votes vote down vote up
/**
 * View 请求更新
 * @param view      {@link View}
 * @param allParent 是否全部父布局 View 都请求
 * @return {@link View}
 */
public static View requestLayoutParent(final View view, final boolean allParent) {
    if (view != null) {
        ViewParent parent = view.getParent();
        while (parent != null && parent instanceof View) {
            if (!parent.isLayoutRequested()) {
                parent.requestLayout();
                if (!allParent) {
                    break;
                }
            }
            parent = parent.getParent();
        }
    }
    return view;
}
 
Example 3
Source File: BottomSheetBehavior.java    From bottomsheetrecycler with Apache License 2.0 6 votes vote down vote up
private void startSettlingAnimationPendingLayout(@State int state) {
    final V child = viewRef.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)) {
        final int finalState = state;
        child.post(
                new Runnable() {
                    @Override
                    public void run() {
                        startSettlingAnimation(child, finalState);
                    }
                });
    } else {
        startSettlingAnimation(child, state);
    }
}
 
Example 4
Source File: BottomSheetBehavior.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
private void settleToStatePendingLayout(@State int state) {
  final V child = viewRef.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)) {
    final int finalState = state;
    child.post(
        new Runnable() {
          @Override
          public void run() {
            settleToState(child, finalState);
          }
        });
  } else {
    settleToState(child, state);
  }
}
 
Example 5
Source File: BottomSheetBehavior.java    From Mysplash with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void settleToStatePendingLayout(@State int state) {
    final V child = viewRef.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)) {
        final int finalState = state;
        child.post(
                new Runnable() {
                    @Override
                    public void run() {
                        settleToState(child, finalState);
                    }
                });
    } else {
        settleToState(child, state);
    }
}
 
Example 6
Source File: ViewPagerBottomSheetBehavior.java    From FabulousFilter with Apache License 2.0 5 votes vote down vote up
public final void setState(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
        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);
    }
}
 
Example 7
Source File: BottomSheetBehaviorV2.java    From paper-launcher with MIT License 5 votes vote down vote up
/**
 * Sets the state of the bottom sheet. The bottom sheet will transition to that state with
 * animation.
 *
 * @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);
    }
}
 
Example 8
Source File: AnchorSheetBehavior.java    From AnchorSheetBehavior with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the state of the bottom sheet. The bottom sheet will transition to that state with
 * animation.
 *
 * @param state One of {@link #STATE_COLLAPSED}, {@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
        if (state == STATE_COLLAPSED || state == STATE_EXPANDED || state == STATE_ANCHOR ||
                ((mHideable && state == STATE_HIDDEN) || state == STATE_FORCE_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() && isAttachedToWindow(child)) {
        child.post(new Runnable() {
            @Override
            public void run() {
                startSettlingAnimation(child, state);
            }
        });
    } else {
        startSettlingAnimation(child, state);
    }
}
 
Example 9
Source File: AnchorBottomSheetBehavior.java    From anchor-bottom-sheet-behavior with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the state of the bottom sheet. The bottom sheet will transition to that state with
 * animation.
 *
 * @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);
    }
}
 
Example 10
Source File: ViewPagerBottomSheetBehavior.java    From ViewPagerBottomSheet with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the state of the bottom sheet. The bottom sheet will transition to that state with
 * animation.
 *
 * @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);
    }
}
 
Example 11
Source File: GoogleMapsBottomSheetBehavior.java    From Google-Maps-BottomSheet with The Unlicense 5 votes vote down vote up
/**
 * Sets the state of the bottom sheet. The bottom sheet will transition to that state with
 * animation.
 *
 * @param state One of {@link #STATE_COLLAPSED}, {@link #STATE_EXPANDED},
 *              {@link #STATE_ANCHORED} 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;
    }
    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);
    }
}