protected MapTileModuleProviderBase findNextAppropriateProvider ( final MapTileRequestState aState ) { MapTileModuleProviderBase provider ; boolean providerDoesntExist = false , providerCantGetDataConnection = false , providerCantServiceZoomlevel = false ; // The logic of the while statement is // "Keep looping until you get null, or a provider that still exists // and has a data connection if it needs one and can service the zoom level," do { provider = aState . getNextProvider ( ) ; // Perform some checks to see if we can use this provider // If any of these are true, then that disqualifies the provider for this tile request. if ( provider != null ) { providerDoesntExist = ! this . getProviderExists ( provider ) ; providerCantGetDataConnection = ! useDataConnection ( ) && provider . getUsesDataConnection ( ) ; int zoomLevel = MapTileIndex . getZoom ( aState . getMapTile ( ) ) ; providerCantServiceZoomlevel = zoomLevel > provider . getMaximumZoomLevel ( ) || zoomLevel < provider . getMinimumZoomLevel ( ) ; } } while ( ( provider != null ) && ( providerDoesntExist || providerCantGetDataConnection || providerCantServiceZoomlevel ) ) ; return provider ; }
We want to not use a provider that doesn t exist anymore in the chain and we want to not use a provider that requires a data connection when one is not available .