private void selectTabInternal ( int newPosition , boolean firstTab , boolean callListener , boolean forcedSelection ) { int oldPosition = mSelectedPosition ; if ( mSelectedPosition != newPosition ) { if ( mBackgroundStyle == BACKGROUND_STYLE_STATIC ) { if ( mSelectedPosition != - 1 ) mBottomNavigationTabs . get ( mSelectedPosition ) . unSelect ( true , mAnimationDuration ) ; mBottomNavigationTabs . get ( newPosition ) . select ( true , mAnimationDuration ) ; } else if ( mBackgroundStyle == BACKGROUND_STYLE_RIPPLE ) { if ( mSelectedPosition != - 1 ) mBottomNavigationTabs . get ( mSelectedPosition ) . unSelect ( false , mAnimationDuration ) ; mBottomNavigationTabs . get ( newPosition ) . select ( false , mAnimationDuration ) ; final BottomNavigationTab clickedView = mBottomNavigationTabs . get ( newPosition ) ; if ( firstTab ) { // Running a ripple on the opening app won't be good so on firstTab this won't run. mContainer . setBackgroundColor ( clickedView . getActiveColor ( ) ) ; mBackgroundOverlay . setVisibility ( View . GONE ) ; } else { mBackgroundOverlay . post ( new Runnable ( ) { @ Override public void run ( ) { // try { BottomNavigationHelper . setBackgroundWithRipple ( clickedView , mContainer , mBackgroundOverlay , clickedView . getActiveColor ( ) , mRippleAnimationDuration ) ; // } catch (Exception e) { // mContainer.setBackgroundColor(clickedView.getActiveColor()); // mBackgroundOverlay.setVisibility(View.GONE); // } } } ) ; } } mSelectedPosition = newPosition ; } if ( callListener ) { sendListenerCall ( oldPosition , newPosition , forcedSelection ) ; } }
Internal Method to select a tab