|
@@ -64,6 +64,7 @@ |
|
|
private boolean mIgnoreTabletLayout;
|
|
|
private boolean mIsTabletMode;
|
|
|
private boolean mIsShy;
|
|
|
+ private boolean mShyHeightAlreadyCalculated;
|
|
|
private boolean mUseExtraOffset;
|
|
|
|
|
|
private ViewGroup mUserContentContainer;
|
|
@@ -189,24 +190,6 @@ public static BottomBar attachShy(CoordinatorLayout coordinatorLayout, Bundle sa |
|
|
bottomBar.toughChildHood(ViewCompat.getFitsSystemWindows(coordinatorLayout));
|
|
|
bottomBar.onRestoreInstanceState(savedInstanceState);
|
|
|
|
|
|
- if (!coordinatorLayout.getContext().getResources().getBoolean(R.bool.bb_bottom_bar_is_tablet_mode)) {
|
|
|
- bottomBar.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
|
- @SuppressWarnings("deprecation")
|
|
|
- @Override
|
|
|
- public void onGlobalLayout() {
|
|
|
- ((CoordinatorLayout.LayoutParams) bottomBar.getLayoutParams())
|
|
|
- .setBehavior(new BottomNavigationBehavior(bottomBar.getOuterContainer().getHeight(), 0));
|
|
|
- ViewTreeObserver obs = bottomBar.getViewTreeObserver();
|
|
|
-
|
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
|
- obs.removeOnGlobalLayoutListener(this);
|
|
|
- } else {
|
|
|
- obs.removeGlobalOnLayoutListener(this);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
coordinatorLayout.addView(bottomBar);
|
|
|
return bottomBar;
|
|
|
}
|
|
@@ -591,7 +574,7 @@ private void initializeViews() { |
|
|
mIsTabletMode = !mIgnoreTabletLayout &&
|
|
|
mContext.getResources().getBoolean(R.bool.bb_bottom_bar_is_tablet_mode);
|
|
|
|
|
|
- View rootView = View.inflate(mContext, mIsTabletMode?
|
|
|
+ View rootView = View.inflate(mContext, mIsTabletMode ?
|
|
|
R.layout.bb_bottom_bar_item_container_tablet : R.layout.bb_bottom_bar_item_container,
|
|
|
null);
|
|
|
mTabletRightBorder = rootView.findViewById(R.id.bb_tablet_right_border);
|
|
@@ -616,6 +599,27 @@ private void initializeViews() { |
|
|
mUserContentContainer.addView(mPendingUserContentView, 0, params);
|
|
|
}
|
|
|
|
|
|
+ if (mIsShy && !mIsTabletMode) {
|
|
|
+ getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
|
+ @SuppressWarnings("deprecation")
|
|
|
+ @Override
|
|
|
+ public void onGlobalLayout() {
|
|
|
+ if (!mShyHeightAlreadyCalculated) {
|
|
|
+ ((CoordinatorLayout.LayoutParams) getLayoutParams())
|
|
|
+ .setBehavior(new BottomNavigationBehavior(getOuterContainer().getHeight(), 0));
|
|
|
+ }
|
|
|
+
|
|
|
+ ViewTreeObserver obs = getViewTreeObserver();
|
|
|
+
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
|
|
+ obs.removeOnGlobalLayoutListener(this);
|
|
|
+ } else {
|
|
|
+ obs.removeGlobalOnLayoutListener(this);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
addView(rootView);
|
|
|
}
|
|
|
|
|
@@ -631,6 +635,10 @@ protected boolean isShy() { |
|
|
return mIsShy;
|
|
|
}
|
|
|
|
|
|
+ protected void shyHeightAlreadyCalculated() {
|
|
|
+ mShyHeightAlreadyCalculated = true;
|
|
|
+ }
|
|
|
+
|
|
|
protected boolean useExtraOffset() {
|
|
|
return mUseExtraOffset;
|
|
|
}
|
|
@@ -717,7 +725,7 @@ private void updateItems(BottomBarItemBase[] bottomBarItems) { |
|
|
if (mIsShiftingMode && !mIsTabletMode) {
|
|
|
layoutResource = R.layout.bb_bottom_bar_item_shifting;
|
|
|
} else {
|
|
|
- layoutResource = mIsTabletMode?
|
|
|
+ layoutResource = mIsTabletMode ?
|
|
|
R.layout.bb_bottom_bar_item_fixed_tablet : R.layout.bb_bottom_bar_item_fixed;
|
|
|
}
|
|
|
|
|
@@ -1100,11 +1108,13 @@ private static void navBarMagic(Activity activity, final BottomBar bottomBar) { |
|
|
@SuppressWarnings("deprecation")
|
|
|
@Override
|
|
|
public void onGlobalLayout() {
|
|
|
+ bottomBar.shyHeightAlreadyCalculated();
|
|
|
+
|
|
|
int newHeight = outerContainer.getHeight() + navBarHeightCopy;
|
|
|
outerContainer.getLayoutParams().height = newHeight;
|
|
|
|
|
|
if (bottomBar.isShy()) {
|
|
|
- int defaultOffset = bottomBar.useExtraOffset()? navBarHeightCopy : 0;
|
|
|
+ int defaultOffset = bottomBar.useExtraOffset() ? navBarHeightCopy : 0;
|
|
|
bottomBar.setTranslationY(defaultOffset);
|
|
|
((CoordinatorLayout.LayoutParams) bottomBar.getLayoutParams())
|
|
|
.setBehavior(new BottomNavigationBehavior(newHeight, defaultOffset));
|
|
|
0 comments on commit
68535e1