protected ChromeAnimation<?> createUpdateDiscardAnimatorSet(StackTab[] tabs,int spacing,float warpSize,float discardRange){
  ChromeAnimation<Animatable<?>> set=new ChromeAnimation<Animatable<?>>();
  int dyingTabsCount=0;
  float firstDyingTabOffset=0;
  for (int i=0; i < tabs.length; ++i) {
    StackTab tab=tabs[i];
    addTiltScrollAnimation(set,tab.getLayoutTab(),0.0f,UNDISCARD_ANIMATION_DURATION,0);
    if (tab.isDying()) {
      dyingTabsCount++;
      if (dyingTabsCount == 1) {
        firstDyingTabOffset=getScreenPositionInScrollDirection(tab);
      }
    }
  }
  Interpolator interpolator=BakedBezierInterpolator.FADE_OUT_CURVE;
  int newIndex=0;
  for (int i=0; i < tabs.length; ++i) {
    StackTab tab=tabs[i];
    long startTime=(long)Math.max(0,TAB_REORDER_START_SPAN / getScreenSizeInScrollDirection() * (getScreenPositionInScrollDirection(tab) - firstDyingTabOffset));
    if (tab.isDying()) {
      float discard=tab.getDiscardAmount();
      if (discard == 0.0f)       discard=isDefaultDiscardDirectionPositive() ? 0.0f : -0.0f;
      float s=Math.copySign(1.0f,discard);
      long duration=(long)(DISCARD_ANIMATION_DURATION * (1.0f - Math.abs(discard / discardRange)));
      addAnimation(set,tab,DISCARD_AMOUNT,discard,discardRange * s,duration,startTime,false,interpolator);
    }
 else {
      if (tab.getDiscardAmount() != 0.f) {
        addAnimation(set,tab,DISCARD_AMOUNT,tab.getDiscardAmount(),0.0f,UNDISCARD_ANIMATION_DURATION,0);
      }
      float newScrollOffset=StackTab.screenToScroll(spacing * newIndex,warpSize);
      if (tab.getDiscardAmount() >= discardRange) {
        tab.setScrollOffset(newScrollOffset);
        tab.setScale(SCALE_AMOUNT);
      }
 else {
        float start=tab.getScrollOffset();
        if (start != newScrollOffset) {
          addAnimation(set,tab,SCROLL_OFFSET,start,newScrollOffset,TAB_REORDER_DURATION,startTime);
        }
      }
      newIndex++;
    }
  }
  return set;
}

protected ChromeAnimation < ? > createUpdateDiscardAnimatorSet ( StackTab [ ] tabs , int spacing , float warpSize , float discardRange ) { ChromeAnimation < Animatable < ? > > set = new ChromeAnimation < Animatable < ? > > ( ) ; int dyingTabsCount = 0 ; float firstDyingTabOffset = 0 ; for ( int i = 0 ; i < tabs . length ; ++ i ) { StackTab tab = tabs [ i ] ; addTiltScrollAnimation ( set , tab . getLayoutTab ( ) , 0.0f , UNDISCARD_ANIMATION_DURATION , 0 ) ; if ( tab . isDying ( ) ) { dyingTabsCount ++ ; if ( dyingTabsCount == 1 ) { firstDyingTabOffset = getScreenPositionInScrollDirection ( tab ) ; } } } Interpolator interpolator = BakedBezierInterpolator . FADE_OUT_CURVE ; int newIndex = 0 ; for ( int i = 0 ; i < tabs . length ; ++ i ) { StackTab tab = tabs [ i ] ; long startTime = ( long ) Math . max ( 0 , TAB_REORDER_START_SPAN / getScreenSizeInScrollDirection ( ) * ( getScreenPositionInScrollDirection ( tab ) - firstDyingTabOffset ) ) ; if ( tab . isDying ( ) ) { float discard = tab . getDiscardAmount ( ) ; if ( discard == 0.0f ) discard = isDefaultDiscardDirectionPositive ( ) ? 0.0f : - 0.0f ; float s = Math . copySign ( 1.0f , discard ) ; long duration = ( long ) ( DISCARD_ANIMATION_DURATION * ( 1.0f - Math . abs ( discard / discardRange ) ) ) ; addAnimation ( set , tab , DISCARD_AMOUNT , discard , discardRange * s , duration , startTime , false , interpolator ) ; } else { if ( tab . getDiscardAmount ( ) != 0.f ) { addAnimation ( set , tab , DISCARD_AMOUNT , tab . getDiscardAmount ( ) , 0.0f , UNDISCARD_ANIMATION_DURATION , 0 ) ; } float newScrollOffset = StackTab . screenToScroll ( spacing * newIndex , warpSize ) ; if ( tab . getDiscardAmount ( ) >= discardRange ) { tab . setScrollOffset ( newScrollOffset ) ; tab . setScale ( SCALE_AMOUNT ) ; } else { float start = tab . getScrollOffset ( ) ; if ( start != newScrollOffset ) { addAnimation ( set , tab , SCROLL_OFFSET , start , newScrollOffset , TAB_REORDER_DURATION , startTime ) ; } } newIndex ++ ; } } return set ; }
responsible for generating the animations that moves the tabs back in from discard attempt or commit the current discard ( if any ) . it also re - even the tabs if one of then is removed .
