public class HttpZipLocator extends java.lang.Object implements AssetLocator
HttpZipLocator
is similar to ZipLocator
, except
it allows loading assets from a .ZIP
file on the web instead of
on the local filesystem.
The root path must be a valid HTTP(S) URL
pointing to ZIP or
ZIP-like file (such as a JAR). For example,
https://www.example.com/my/sub/path/assets.zip
.
The locator is designed in such a way that it does not require downloading
the entire .ZIP
file from the web in order to load
assets from it. Instead, the ZIP header is extracted first, and then
is used to lookup assets from within the ZIP file and download them
as requested by the user.
Constructor and Description |
---|
HttpZipLocator() |
Modifier and Type | Method and Description |
---|---|
void |
load(java.net.URL url) |
AssetInfo |
locate(AssetManager manager,
AssetKey key)
Request to locate an asset.
|
java.io.InputStream |
openStream(java.lang.String name) |
void |
setRootPath(java.lang.String path) |
public void load(java.net.URL url) throws java.io.IOException
java.io.IOException
public java.io.InputStream openStream(java.lang.String name) throws java.io.IOException
java.io.IOException
public void setRootPath(java.lang.String path)
setRootPath
in interface AssetLocator
path
- The root path where to look for assets.
Typically, this method will only be called once for each
instance of an asset locator.public AssetInfo locate(AssetManager manager, AssetKey key)
AssetLocator
AssetInfo
implementation provided should have a proper
return value for its AssetInfo.openStream()
method.locate
in interface AssetLocator
manager
- for managing assetskey
- identifies the asset to be locatedAssetInfo
that was located, or null if not found.