public class OfflineManager
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
OfflineManager.CreateOfflineRegionCallback
This callback receives an asynchronous response containing the newly created
OfflineRegion in the database or an error message otherwise.
|
static interface |
OfflineManager.ListOfflineRegionsCallback
This callback receives an asynchronous response containing a list of all
OfflineRegion in the database or an error message otherwise.
|
static interface |
OfflineManager.MergeOfflineRegionsCallback
This callback receives an asynchronous response containing a list of all
OfflineRegion added to the database during the merge.
|
Modifier and Type | Method and Description |
---|---|
void |
createOfflineRegion(OfflineRegionDefinition definition,
byte[] metadata,
OfflineManager.CreateOfflineRegionCallback callback)
Create an offline region in the database.
|
protected void |
finalize() |
static OfflineManager |
getInstance(android.content.Context context)
Get the single instance of offline manager.
|
void |
listOfflineRegions(OfflineManager.ListOfflineRegionsCallback callback)
Retrieve all regions in the offline database.
|
void |
mergeOfflineRegions(java.lang.String path,
OfflineManager.MergeOfflineRegionsCallback callback)
Merge offline regions from a secondary database into the main offline database.
|
void |
putResourceWithUrl(java.lang.String url,
byte[] data,
long modified,
long expires,
java.lang.String etag,
boolean mustRevalidate)
Insert the provided resource into the ambient cache
This method mimics the caching that would take place if the equivalent
resource were requested in the process of map rendering.
|
void |
setOfflineDingiTileCountLimit(long limit)
Changing or bypassing this limit without permission from Dingi is prohibited
by the Dingi Terms of Service.
|
public static OfflineManager getInstance(@NonNull android.content.Context context)
context
- the context used to host the offline managerpublic void listOfflineRegions(@NonNull OfflineManager.ListOfflineRegionsCallback callback)
The query will be executed asynchronously and the results passed to the given callback on the main thread.
callback
- the callback to be invokedpublic void mergeOfflineRegions(@NonNull java.lang.String path, @NonNull OfflineManager.MergeOfflineRegionsCallback callback)
When the merge is completed, or fails, the OfflineManager.MergeOfflineRegionsCallback
will be invoked on the main thread.
The secondary database may need to be upgraded to the latest schema. This is done in-place and requires write-access to the provided path. If the app's process doesn't have write-access to the provided path, the file will be copied to the temporary, internal directory for the duration of the merge.
Only resources and tiles that belong to a region will be copied over. Identical regions will be flattened into a single new region in the main database.
The operation will be aborted and OfflineManager.MergeOfflineRegionsCallback.onError(String)
with an appropriate message
will be invoked if the merge would result in the offline tile count limit being exceeded.
Merged regions may not be in a completed status if the secondary database does not contain all the tiles or resources required by the region definition.
path
- secondary database writable pathcallback
- completion/error callbackpublic void createOfflineRegion(@NonNull OfflineRegionDefinition definition, @NonNull byte[] metadata, @NonNull OfflineManager.CreateOfflineRegionCallback callback)
When the initial database queries have completed, the provided callback will be executed on the main thread.
Note that the resulting region will be in an inactive download state; to begin downloading resources, call `OfflineRegion.setDownloadState(DownloadState.STATE_ACTIVE)`, optionally registering an `OfflineRegionObserver` beforehand.
definition
- the offline region definitionmetadata
- the metadata in bytescallback
- the callback to be invokedpublic void setOfflineDingiTileCountLimit(long limit)
limit
- the new tile count limit.protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public void putResourceWithUrl(java.lang.String url, byte[] data, long modified, long expires, java.lang.String etag, boolean mustRevalidate)
url
- The URL of the resource to insertdata
- Response data to store for this resource. Data is expected to be uncompressed;
internally, the cache will compress data as necessary.modified
- Optional "modified" response header, in seconds since 1970, or 0 if not setexpires
- Optional "expires" response header, in seconds since 1970, or 0 if not setetag
- Optional "entity tag" response headermustRevalidate
- Indicates whether response can be used after it's stale