Skip to content
Browse files

Fixed issues on tablets when using the attachShy method.

  • Loading branch information...
1 parent 5424bad commit c61097a80a3c76ba1ae52533bd7cef8685ec8325 @roughike committed
Showing with 26 additions and 2 deletions.
  1. +26 −2 bottom-bar/src/main/java/com/roughike/bottombar/BottomBar.java
View
28 bottom-bar/src/main/java/com/roughike/bottombar/BottomBar.java
@@ -175,6 +175,15 @@ public static BottomBar attach(View view, Bundle savedInstanceState) {
}
/**
+ * Deprecated. Breaks support for tablets.
+ * Use {@link #attachShy(CoordinatorLayout, View, Bundle)} instead.
+ */
+ @Deprecated
+ public static BottomBar attachShy(CoordinatorLayout coordinatorLayout, Bundle savedInstanceState) {
+ return attachShy(coordinatorLayout, null, savedInstanceState);
+ }
+
+ /**
* Adds the BottomBar inside of your CoordinatorLayout and shows / hides
* it according to scroll state changes.
* <p/>
@@ -182,14 +191,21 @@ public static BottomBar attach(View view, Bundle savedInstanceState) {
* of your {@link Activity#onSaveInstanceState(Bundle)} to restore the state.
*
* @param coordinatorLayout a CoordinatorLayout for the BottomBar to add itself into
+ * @param userContentView the view (usually a NestedScrollView) that has your scrolling content.
+ * Needed for tablet support.
* @param savedInstanceState a Bundle for restoring the state on configuration change.
* @return a BottomBar at the bottom of the screen.
*/
- public static BottomBar attachShy(CoordinatorLayout coordinatorLayout, Bundle savedInstanceState) {
+ public static BottomBar attachShy(CoordinatorLayout coordinatorLayout, View userContentView, Bundle savedInstanceState) {
final BottomBar bottomBar = new BottomBar(coordinatorLayout.getContext());
bottomBar.toughChildHood(ViewCompat.getFitsSystemWindows(coordinatorLayout));
bottomBar.onRestoreInstanceState(savedInstanceState);
+ if (userContentView != null && coordinatorLayout.getContext()
+ .getResources().getBoolean(R.bool.bb_bottom_bar_is_tablet_mode)) {
+ bottomBar.setPendingUserContentView(userContentView);
+ }
+
coordinatorLayout.addView(bottomBar);
return bottomBar;
}
@@ -588,6 +604,10 @@ private void initializeViews() {
mBackgroundView = rootView.findViewById(R.id.bb_bottom_bar_background_view);
mBackgroundOverlay = rootView.findViewById(R.id.bb_bottom_bar_background_overlay);
+ if (mIsShy && mIgnoreTabletLayout) {
+ mPendingUserContentView = null;
+ }
+
if (mPendingUserContentView != null) {
ViewGroup.LayoutParams params = mPendingUserContentView.getLayoutParams();
@@ -596,6 +616,10 @@ private void initializeViews() {
ViewGroup.LayoutParams.MATCH_PARENT);
}
+ if (mIsTabletMode && mIsShy) {
+ ((ViewGroup) mPendingUserContentView.getParent()).removeView(mPendingUserContentView);
+ }
+
mUserContentContainer.addView(mPendingUserContentView, 0, params);
}
@@ -697,7 +721,7 @@ public boolean onLongClick(View v) {
return true;
}
- private void updateItems(BottomBarItemBase[] bottomBarItems) {
+ private void updateItems(final BottomBarItemBase[] bottomBarItems) {
if (mItemContainer == null) {
initializeViews();
}

0 comments on commit c61097a

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