private void adaptNavigationVisibility ( ) { if ( isSplitScreen ( ) ) { if ( navigationFragmentContainer != null && cardView != null && toolbarLarge != null ) { navigationFragmentContainer . setVisibility ( isNavigationHidden ( ) ? View . GONE : View . VISIBLE ) ; toolbarLarge . hideNavigation ( isNavigationHidden ( ) ) ; int preferenceScreenHorizontalMargin = getResources ( ) . getDimensionPixelSize ( R . dimen . card_view_horizontal_margin ) ; int preferenceScreenMarginRight = getResources ( ) . getDimensionPixelSize ( R . dimen . card_view_margin_right ) ; int cardViewIntrinsicMargin = getResources ( ) . getDimensionPixelSize ( R . dimen . card_view_intrinsic_margin ) ; FrameLayout . LayoutParams cardViewLayoutParams = ( FrameLayout . LayoutParams ) cardView . getLayoutParams ( ) ; cardViewLayoutParams . gravity = isNavigationHidden ( ) ? Gravity . CENTER_HORIZONTAL : Gravity . NO_GRAVITY ; int marginStart = ( isNavigationHidden ( ) ? preferenceScreenHorizontalMargin : navigationWidth ) - cardViewIntrinsicMargin ; int marginEnd = ( isNavigationHidden ( ) ? preferenceScreenHorizontalMargin : preferenceScreenMarginRight ) - cardViewIntrinsicMargin ; setMarginStart ( cardViewLayoutParams , marginStart ) ; setMarginEnd ( cardViewLayoutParams , marginEnd ) ; } } else { if ( getSelectedNavigationPreference ( ) != null ) { if ( isNavigationHidden ( ) ) { hideToolbarNavigationIcon ( ) ; } else { showToolbarNavigationIcon ( ) ; } } else if ( isNavigationHidden ( ) && navigationFragment != null && navigationFragment . getCallback ( ) == null ) { if ( navigationFragment . getNavigationPreferenceCount ( ) > 0 ) { navigationFragment . selectNavigationPreference ( 0 , null ) ; } else { finish ( ) ; } } } }
Adapts the visibility of the navigation .