Package com.massifmaps.utils
Class DirAssetPackage
java.lang.Object
com.massifmaps.utils.AssetPackage
com.massifmaps.utils.DirAssetPackage
An asset package based on a file system directory.
Assets are read directly from the directory, thus the assets can be modified
on the fly without repackaging them into a ZIP archive. This is mostly useful
for style development.
Note: assets and directories with names starting with '.' are ignored.
Assets are read directly from the directory, thus the assets can be modified
on the fly without repackaging them into a ZIP archive. This is mostly useful
for style development.
Note: assets and directories with names starting with '.' are ignored.
-
Constructor Summary
ConstructorsConstructorDescriptionDirAssetPackage(String dirPath) Constructs a directory asset package from the specified directory.DirAssetPackage(String dirPath, AssetPackage baseAssetPackage) Constructs a directory asset package from the specified directory and a fallback asset package. -
Method Summary
Modifier and TypeMethodDescriptionReturns list of assets in the asset package.
All listed assets can read using loadAsset API.Returns the full path of the directory containing the assets.Returns the list of assets stored in the directory, ignoring the base asset package.Loads the specified asset from the asset package.voidreload()Rescans the directory.Methods inherited from class com.massifmaps.utils.AssetPackage
equals, hashCode
-
Constructor Details
-
DirAssetPackage
Constructs a directory asset package from the specified directory.- Parameters:
dirPath- The full path of the directory containing the assets.- Throws:
Exception- If the directory could not be opened.IOException
-
DirAssetPackage
Constructs a directory asset package from the specified directory and a fallback asset package.- Parameters:
dirPath- The full path of the directory containing the assets.baseAssetPackage- The base asset package. If an asset is not found in the directory, base asset package is used.- Throws:
Exception- If the directory could not be opened.IOException
-
-
Method Details
-
getDirPath
Returns the full path of the directory containing the assets.- Returns:
- The full path of the directory containing the assets.
-
getLocalAssetNames
Returns the list of assets stored in the directory, ignoring the base asset package.- Returns:
- The list of asset names stored in the directory.
-
reload
public void reload()Rescans the directory. Use this if assets were added to or removed from the directory
after the asset package was created. -
getAssetNames
Description copied from class:AssetPackageReturns list of assets in the asset package.
All listed assets can read using loadAsset API.- Overrides:
getAssetNamesin classAssetPackage- Returns:
- List of asset names.
-
loadAsset
Description copied from class:AssetPackageLoads the specified asset from the asset package.- Overrides:
loadAssetin classAssetPackage- Parameters:
name- The asset name to read.- Returns:
- Asset data, if the asset exists and was successfully read. Null pointer otherwise.
-