Hi all,
I am writing a "UI theme / UI skin" thing on a PlayN app where there is a "default theme" which defines colors, fonts, icons, etc. and then other themes which can optionally override some of the colors, fonts, or icons.
For this, I am organizing my assets as follows:
assets/fonts
assets/icons
assets/<theme>/fonts
assets/<theme>/icons
When selecting a theme, I need to reload fonts and icons. What I want to achieve is:
- If the theme overrides the font/icon, then the theme-specific version of the asset is loaded
- Otherwise, the generic version of the asset (from the default theme) is loaded.
My problem is that I can't find a way to check if an asset exists, given its path. Methods such as Platform.assets().getImage() will not fail even if the path does not exist. ONe option would be to load everything synchronously but I don't want to do that as this means the app will be less responsive. Ideally I would like to:
1. Use Platform.assets().getImage(), but have it fail immediately (i.e. return null or whatever) if the asset does not exist at the specified path. If the asset exists, then load it asynchronously as it does now
2. Use a separate API to check if an asset exists at a given path, so that I can select the right path before using assets().getImage()
Has anyone faced this problem before? Any suggestions?
Thanks,
Guillermo