Class BundleAssetPackage

java.lang.Object
com.massifmaps.utils.AssetPackage
com.massifmaps.utils.BundleAssetPackage

public class BundleAssetPackage extends AssetPackage
An asset package based on the assets bundled with the application.
On Android these live inside the APK, where no file path reaches them - which is what
separates this from DirAssetPackage; on iOS and Windows they are the app bundle's own files.
Note: assets and directories with names starting with '.' are ignored.
  • Constructor Details

    • BundleAssetPackage

      public BundleAssetPackage(String basePath)
      Constructs a bundle asset package rooted at the specified bundled directory.
      Parameters:
      basePath - The path of the directory inside the bundle, "" for the bundle root.
    • BundleAssetPackage

      public BundleAssetPackage(String basePath, AssetPackage baseAssetPackage)
      Constructs a bundle asset package rooted at the specified bundled directory, with a
      fallback asset package.
      Parameters:
      basePath - The path of the directory inside the bundle, "" for the bundle root.
      baseAssetPackage - The base asset package. If an asset is not found in the bundle, base asset package is used.
  • Method Details

    • getBasePath

      public String getBasePath()
      Returns the path of the bundled directory the assets are read from.
      Returns:
      The path of the bundled directory containing the assets.
    • getLocalAssetNames

      public StringVector getLocalAssetNames()
      Returns the list of assets found in the bundle, ignoring the base asset package.
      Returns:
      The list of asset names found in the bundle.
    • reload

      public void reload()
      Rescans the bundled directory. Bundled assets do not change while the app runs, so this
      only matters when the listing was built before the platform could answer - on Android
      the asset manager is connected by the first MapView.
    • getAssetNames

      public StringVector getAssetNames()
      Description copied from class: AssetPackage
      Returns list of assets in the asset package.
      All listed assets can read using loadAsset API.
      Overrides:
      getAssetNames in class AssetPackage
      Returns:
      List of asset names.
    • loadAsset

      public BinaryData loadAsset(String name)
      Description copied from class: AssetPackage
      Loads the specified asset from the asset package.
      Overrides:
      loadAsset in class AssetPackage
      Parameters:
      name - The asset name to read.
      Returns:
      Asset data, if the asset exists and was successfully read. Null pointer otherwise.