Source:
<code>public void showWithSheetView(View sheetView, ViewTransformer viewTransformer, OnSheetDismissedListener onSheetDismissedListener) { if (state != State.HIDDEN) { throw new IllegalStateException("A sheet view is already presented, make sure to dismiss it before showing another."); } LayoutParams params = (LayoutParams) sheetView.getLayoutParams(); if (params != null) { params.width = ViewGroup.LayoutParams.MATCH_PARENT; } else { params = generateDefaultLayoutParams(); } super.addView(sheetView, -1, params); initializeSheetValues(); this.viewTransformer = viewTransformer; this.onSheetDismissedListener = onSheetDismissedListener; getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { getViewTreeObserver().removeOnPreDrawListener(this); post(new Runnable() { @Override public void run() { if (getSheetView() != null) { peekSheet(); } } }); return true; } }); currentSheetViewHeight = sheetView.getMeasuredHeight(); sheetViewOnLayoutChangeListener = new OnLayoutChangeListener() { @Override public void onLayoutChange(View sheetView, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { int newSheetViewHeight = sheetView.getMeasuredHeight(); if (state != State.HIDDEN) { if (newSheetViewHeight < currentSheetViewHeight) { if (state == State.EXPANDED) { setState(State.PEEKED); } setSheetTranslation(sheetView.getMeasuredHeight()); } <START> } <END> currentSheetViewHeight = newSheetViewHeight; } }; sheetView.addOnLayoutChangeListener(sheetViewOnLayoutChangeListener); }</code><technical_language>logic simplified to: java if (state != State.HIDDEN && newSheetViewHeight < currentSheetViewHeight) { // sheet longer in expanded state if shrunk if (state == State.EXPANDED) { setState(State.PEEKED); } setSheetTranslation(newSheetViewHeight); }</technical_language>

Target:
public void showWithSheetView(View sheetView, ViewTransformer viewTransformer, OnSheetDismissedListener onSheetDismissedListener) { if (state != State.HIDDEN) { throw new IllegalStateException("A sheet view is already presented, make sure to dismiss it before showing another."); } LayoutParams params = (LayoutParams) sheetView.getLayoutParams(); if (params != null) { params.width = ViewGroup.LayoutParams.MATCH_PARENT; } else { params = generateDefaultLayoutParams(); } super.addView(sheetView, -1, params); initializeSheetValues(); this.viewTransformer = viewTransformer; this.onSheetDismissedListener = onSheetDismissedListener; getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { getViewTreeObserver().removeOnPreDrawListener(this); post(new Runnable() { @Override public void run() { if (getSheetView() != null) { peekSheet(); } } }); return true; } }); currentSheetViewHeight = sheetView.getMeasuredHeight(); sheetViewOnLayoutChangeListener = new OnLayoutChangeListener() { @Override public void onLayoutChange(View sheetView, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { int newSheetViewHeight = sheetView.getMeasuredHeight(); if (state != State.HIDDEN && newSheetViewHeight < currentSheetViewHeight) { if (state == State.EXPANDED) { setState(State.PEEKED); } setSheetTranslation(newSheetViewHeight); } currentSheetViewHeight = newSheetViewHeight; } }; sheetView.addOnLayoutChangeListener(sheetViewOnLayoutChangeListener); }