public void loadPages ( ) { if ( optimalPageWidth == 0 || optimalPageHeight == 0 ) { return ; } // Cancel all current tasks renderingAsyncTask . removeAllTasks ( ) ; cacheManager . makeANewSet ( ) ; // Find current index in filtered user pages int index = currentPage ; if ( filteredUserPageIndexes != null ) { index = filteredUserPageIndexes [ currentPage ] ; } // Loop through the pages like [...][4][2][0][1][3][...] // loading as many parts as it can. int parts = 0 ; for ( int i = 0 ; i <= Constants . LOADED_SIZE / 2 && parts < CACHE_SIZE ; i ++ ) { parts += loadPage ( index + i , CACHE_SIZE - parts ) ; if ( i != 0 && parts < CACHE_SIZE ) { parts += loadPage ( index - i , CACHE_SIZE - parts ) ; } } invalidate ( ) ; }
Load all the parts around the center of the screen taking into account X and Y offsets zoom level and the current page displayed