Skip to content
Browse files

Squashed some bugs related to the autohide feature.

  • Loading branch information...
1 parent bf66264 commit efedcdd395da74743a66044db0f12139d710de56 @roughike committed
Showing with 24 additions and 18 deletions.
  1. +24 −18 bottom-bar/src/main/java/com/roughike/bottombar/BottomBar.java
View
42 bottom-bar/src/main/java/com/roughike/bottombar/BottomBar.java
@@ -28,6 +28,7 @@
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
@@ -190,22 +191,6 @@ public static BottomBar attachShy(CoordinatorLayout coordinatorLayout, Bundle sa
bottomBar.toughChildHood(ViewCompat.getFitsSystemWindows(coordinatorLayout));
bottomBar.onRestoreInstanceState(savedInstanceState);
- 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;
}
@@ -576,8 +561,7 @@ private void init(Context context, AttributeSet attrs, int defStyleAttr, int def
private void initializeViews() {
- View rootView = View.inflate(mContext, mIsShy?
- R.layout.bb_bottom_bar_item_container_shy : R.layout.bb_bottom_bar_item_container, null);
+ View rootView = View.inflate(mContext, R.layout.bb_bottom_bar_item_container, null);
mTabletRightBorder = rootView.findViewById(R.id.bb_tablet_right_border);
mIsTabletMode = mTabletRightBorder != null;
@@ -680,6 +664,28 @@ private void updateItems(BottomBarItemBase[] bottomBarItems) {
darkThemeMagic();
}
+ if (mIsShy) {
+ if (!mIsTabletMode) {
+ if (!mDrawBehindNavBar && !mIsShiftingMode) {
+ getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
+ @SuppressWarnings("deprecation")
+ @Override
+ public void onGlobalLayout() {
+ ((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);
+ }
+ }
+ });
+ }
+ }
+ }
+
View[] viewsToAdd = new View[bottomBarItems.length];
for (BottomBarItemBase bottomBarItemBase : bottomBarItems) {

0 comments on commit efedcdd

Please sign in to comment.
Something went wrong with that request. Please try again.