/** * Loads parts of the asset asynchronously if the loader is an {@link AsynchronousAssetLoader}. */ @Override public Void call() throws Exception { AsynchronousAssetLoader asyncLoader = (AsynchronousAssetLoader) loader; if (dependenciesLoaded == false) { dependencies = asyncLoader.getDependencies(assetDesc.fileName, assetDesc.params); if (dependencies != null) { for (AssetDescriptor desc : dependencies) { manager.injectDependency(assetDesc.fileName, desc); } } else { // if we have no dependencies, we load the async part of the task immediately. asyncLoader.loadAsync(manager, assetDesc.fileName, assetDesc.params); asyncDone = true; } } else { asyncLoader.loadAsync(manager, assetDesc.fileName, assetDesc.params); } return null; }
private void handleAsyncLoader() { AsynchronousAssetLoader asyncLoader = (AsynchronousAssetLoader) loader; if (!dependenciesLoaded) { if (depsFuture == null) { depsFuture = threadPool.submit(this); } else { if (depsFuture.isDone()) { try { depsFuture.get(); } catch (Exception e) { throw new GdxRuntimeException( "Couldn't load dependencies of asset '" + assetDesc.fileName + "'", e); } dependenciesLoaded = true; if (asyncDone) { asset = asyncLoader.loadSync(manager, assetDesc.fileName, assetDesc.params); } } } } else { if (loadFuture == null && !asyncDone) { loadFuture = threadPool.submit(this); } else { if (asyncDone) { asset = asyncLoader.loadSync(manager, assetDesc.fileName, assetDesc.params); } else if (loadFuture.isDone()) { try { loadFuture.get(); } catch (Exception e) { throw new GdxRuntimeException("Couldn't load asset '" + assetDesc.fileName + "'", e); } asset = asyncLoader.loadSync(manager, assetDesc.fileName, assetDesc.params); } } } }