Package com.massifmaps.utils
Class AndroidAssetPackage
java.lang.Object
com.massifmaps.utils.AssetPackage
com.massifmaps.utils.AndroidAssetPackage
An asset package based on the application-bundled Android assets (the 'assets' folder of
the APK). This is the counterpart of DirAssetPackage for assets that ship with the app:
APK assets are entries inside the package, not files, so they cannot be read through a
file system path.
Note: the asset manager must be connected before an instance is created, which happens
when a MapView is constructed.
the APK). This is the counterpart of DirAssetPackage for assets that ship with the app:
APK assets are entries inside the package, not files, so they cannot be read through a
file system path.
Note: the asset manager must be connected before an instance is created, which happens
when a MapView is constructed.
-
Constructor Summary
ConstructorsConstructorDescriptionAndroidAssetPackage(String basePath) Constructs an asset package from the given directory inside the application assets.AndroidAssetPackage(String basePath, AssetPackage baseAssetPackage) Constructs an asset package from the given directory inside the application assets,
with 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 asset directory this package reads from.Returns the list of assets bundled under the base path, ignoring the base asset package.Loads the specified asset from the asset package.voidreload()Rescans the asset directory.Methods inherited from class com.massifmaps.utils.AssetPackage
equals, hashCode
-
Constructor Details
-
AndroidAssetPackage
Constructs an asset package from the given directory inside the application assets.- Parameters:
basePath- The asset directory, relative to the assets root ("" is the root itself).- Throws:
Exception- If the directory contains no assets.IOException
-
AndroidAssetPackage
Constructs an asset package from the given directory inside the application assets,
with a fallback asset package.- Parameters:
basePath- The asset directory, relative to the assets root ("" is the root itself).baseAssetPackage- The base asset package. If an asset is not found in the assets,
the base asset package is used.- Throws:
Exception- If the directory contains no assets.IOException
-
-
Method Details
-
getBasePath
Returns the asset directory this package reads from.- Returns:
- The asset directory, relative to the assets root.
-
getLocalAssetNames
Returns the list of assets bundled under the base path, ignoring the base asset package.- Returns:
- The list of asset names, relative to the base path.
-
reload
public void reload()Rescans the asset directory. Bundled assets cannot change while the app runs, so this is
only needed if the asset manager was connected after this 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.
-