question: public static ArrayList < Page > pageCreatorButtons ( ArrayList < Page > pages , Item manualType ) { ArrayList < Page > newPages = new ArrayList < > ( ) ; int pageAmount = pages . size ( ) ; int times = 0 ; while ( pageAmount > 0 ) { ArrayList < Page > pagesTemp = new ArrayList < > ( ) ; pagesTemp . addAll ( pages . subList ( 7 * times , ( pageAmount > 7 ? 7 + 7 * times : 7 * times + pageAmount ) ) ) ; int height = 0 ; ArrayList < ManualWidgetBase > widgets = new ArrayList < > ( ) ; for ( Page page : pagesTemp ) { widgets . add ( new ButtonWidget ( 15 , 10 + height , page ) ) ; height += 20 ; } newPages . add ( new Page ( "index" + times , ( ArrayList < ManualWidgetBase > ) widgets . clone ( ) , false , manualType ) ) ; widgets . clear ( ) ; pagesTemp . clear ( ) ; pageAmount -= 7 ; times ++ ; } return newPages ; }
target:  Creates the button pages for a category