/** Returns try if this is a failed try, false if it is a successful try. */ public boolean isFailure () { return !isSuccess(); }
/** Returns try if this is a failed try, false if it is a successful try. */ public boolean isFailure () { return !isSuccess(); }
/** * Returns whether this image is successfully loaded. If it is still loading, or loading failed, * {@code false} will be returned. In general you'll want to react to {@link #state}, but this * method is useful when you need to assert that something is only allowed on a fully loaded * image. */ public boolean isLoaded () { Try<Image> cur = state.result(); return cur != null && cur.isSuccess(); }
/** * Returns whether this image is successfully loaded. If it is still loading, or loading failed, * {@code false} will be returned. In general you'll want to react to {@link #state}, but this * method is useful when you need to assert that something is only allowed on a fully loaded * image. */ public boolean isLoaded () { Try<Image> cur = state.result(); return cur != null && cur.isSuccess(); }
/** * Loads a JSON encoded library synchronously. * @param baseDir The base directory, containing library.json and texture atlases. */ public static Library loadLibrarySync (final Platform plat, String baseDir) throws Exception { final ImageLoader syncLoader = new ImageLoader() { @Override public Image load (String path) { return plat.assets().getImageSync(path); } }; String text = plat.assets().getTextSync(baseDir + "/library.json"); Try<Library> result = decodeLibrary(plat.json().parse(text), baseDir, syncLoader).result(); if (result.isSuccess()) return result.get(); Throwable error = result.getFailure(); if (error instanceof Exception) throw (Exception)error; else throw new RuntimeException(error); }